Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Animations not working with 1.4.x releases, ok with 1.3 #12267

Closed
zakhenry opened this issue Jul 3, 2015 · 60 comments
Closed

Animations not working with 1.4.x releases, ok with 1.3 #12267

zakhenry opened this issue Jul 3, 2015 · 60 comments

Comments

@zakhenry
Copy link

zakhenry commented Jul 3, 2015

I'm building a single page application with angular material and for some reason the animations are not functioning.

It looks like it is not just angular material as I can't get the basic example on the https://docs.angularjs.org/guide/animations page to work.

It appears that the classes that angular material relies on to be added for the css animations to hook on to are not being applied. Inspecting the elements in chrome I just see the hide and show classes but none of the transition classes.

Relevant parts of my bower file:

    "angular": "~1.4.1",
    "angular-animate": "~1.4.1",
    "angular-sanitize": "~1.4.1",
    "angular-messages": "~1.4.1",
    "angular-i18n": "~1.4.1",
    "angular-ui-router": "~0.2.15",
    "angular-material": "~0.10.0",

My site (in development) is at http://www.zakhenry.com and the animation test page is at http://www.zakhenry.com/#/blog
When the viewport is small (ie mobile width) I should be able to see the sidepane animate out like on the https://material.angularjs.org/latest/ site; instead it just appears and disappears.

Source code is at https://github.com/xiphiaz/zakhenry.com

update
I can actually access the nganimate api eg if I run $animate.leave(); in a controller I get an error thrown from angular-animate, indicating the module is loaded successfully. Also adding breakpoints in the ng animate vendor works.

If I call console.log($animate.enabled()) in the run() phase I get false in the console. I tried setting it to true with $animate.enabled(true), to no effect.

@lgalfaso
Copy link
Contributor

lgalfaso commented Jul 4, 2015

ping @matsko

@havenchyk
Copy link

@xiphiaz could you try exclude angular-material and investigate, is it a problem of ng-animate?

@matsko
Copy link
Contributor

matsko commented Jul 15, 2015

It looks like there is something going on within Material. I'll be pairing with @ThomasBurleson today to see what the issue is.

@Tathanen
Copy link

I think I'm suffering from this as well, using 1.4.x. No animation classes appear, despite ngAnimate being included as a module. console.log( $animate.enabled() ) returns false in all my controllers.

(not using material in my case)

@Tathanen
Copy link

Oh, and yes, reverting to 1.3.x solves the issue immediately.

@ThomasBurleson
Copy link

@Tathanen - do you have a small-sized demo that we can use to debug and investigate?

@zakhenry
Copy link
Author

@ThomasBurleson my (very much unfinished) personal site is fairly small with angular material and angular animate. Reverting to 1.3 works for me.

https://github.com/xiphiaz/zakhenry.com

@Tathanen
Copy link

@ThomasBurleson nothing public unfortunately. If @xiphiaz's site isn't enough I can see if I can get something together, though.

@matsko
Copy link
Contributor

matsko commented Jul 16, 2015

Please do. The more simple the demo, the faster we can get this fixed.

@Tathanen
Copy link

Alright, I've thrown together a super-pared-down example based on my codebase:

http://www.coryfaller.com/angular_animate/index.html#/admin/users

The table/array is supposed to show once it's non-empty, with a little fade-in effect. Which is effectively immediately, once the controller runs. On 1.4.x, the table just appears with no animation. I'm using angular-1-4.js in the example to load angular in there. Swapping for angular-1-3.js, and thus angular 1.3.x, makes the animation work.

@zakhenry
Copy link
Author

@Narretz can this issue have the milestone switched to 1.4.x as this has been confirmed and reproduced by multiples sources?

@Narretz
Copy link
Contributor

Narretz commented Jul 17, 2015

@xiphiaz Thanks for the repros. I still can't switch the milestone, since I have to check out your app and verify that it's working with 1.3.x and not working with 1.4.x. There's also still a lot of stuff in the repo, so getting the bottom of this is more difficult.
Anyway, can you please check if it works with the latest 1.4.x snapshot? It has a number of animation fixes.

@Narretz Narretz self-assigned this Jul 17, 2015
@zakhenry
Copy link
Author

@Narretz I have just tried with latest snapshot of both angular & angular-animate v1.4.4-build.4108+sha.344dffb however no success. I also earlier in the day tried the latest angular material, as I noticed others are reporting similar issues, but no dice.

@Tathanen
Copy link

I ran through some 1.4.0 beta releases to see if I could nail down when the issue first presented in my case, it looks like 1.4.0-rc.0 is the breaking build. Things still worked fine on 1.4.0-beta.6.

@Tathanen
Copy link

@matsko @ThomasBurleson were you able to see this issue using the example I provided? Is there anything else I can do to help this get diagnosed?

@ThomasBurleson
Copy link

@Taritsyn, @xiphiaz - The Angular Material fixes [to use $animateCss] are in both the

That branch will be merged into master on Monday or Tuesday... at which time you should be able to validate use of Angular Material with Angular 1.4.x

@Tathanen
Copy link

@ThomasBurleson The issue as demonstrated in my example makes no use of Angular Material, it's just stock Angular 1.4.x and angular-animate.

@ThomasBurleson
Copy link

@Tathanen - My apologies. I was tracking issues where Angular material and ngAnimate 1.4.x overlap. Please disregard [my comments] if you are not using Angular Material.

@Tathanen
Copy link

Tathanen commented Aug 4, 2015

So, a few things.

One, my demo is a bit misleadinig on the "animate enabled" flag. I've discovered that when first running the code in a controller, $animate.enabled() returns false, because the flag only sets to true after the first digest cycle is complete. If I put it in a timeout, it displays true.

Two, I've been able to make my animations work if I use ng-if instead of ng-show. The enter/leave classes appear as they should, when I do something like this:

.the-thing.ng-enter {
  transition: all ease 1s;
  opacity: 0;
}
.the-thing.ng-enter.ng-enter-active {
  opacity: 1;
}

When I use ng-show, though, my problems persist. The transition classes simply never appear. I've tried a wide variety of combinations to get things moving, referencing the doc here:

https://code.angularjs.org/1.4.3/docs/api/ng/directive/ngShow

The doc is pretty confusing, though, since the "note about animations" section and actual example at the bottom say different things. The note section claiming that you need to add a zero-duration transition at the start to properly apply all styling in 1.3.x, and another section requiring an alternative to display:none for hiding, but none of this is actually present in the example at the bottom, so I'm not really sure what is or isn't actually required.

Regardless, this is what I'm trying now, and it still does not produce the transition classes when my element goes from hidden to visible:

.animate-show.ng-hide:not(.ng-hide-animate) {
  /* this is just another form of hiding an element */
  display: block!important;
  position: absolute;
  top: -9999px;
  left: -9999px;
}

.animate-show.ng-hide-remove {
  transition: all linear 0s;
  opacity: 0;
}

.animate-show.ng-hide-remove.ng-hide-remove-active {
  transition: all linear 1s;
  opacity: 1;
}

I tried a more direct class-based animation but was met with similar issues.

.item {
  transition: all linear 1s;
  opacity: 0;
}
.item.showme-add {
  background-color: black;
}
.item.showme {
  background-color: white;
  opacity: 1;
}

This animates the opacity, but not the background color. Because the "-add" class is never added, it's an immediate transition to the .showme class when I toggle the class on.

So in summary, it looks like my issue here is with class-based animations in 1.4.x, and the intermediary add/remove classes never being added.

@Narretz Narretz removed their assignment Aug 8, 2015
@elciok
Copy link

elciok commented Aug 12, 2015

I've got a small snippet that might help getting a better insight about this issue. It works with Angular 1.3.17 but doesn't work with 1.4.3. It works if you don't include ngAnimate. It works if you replace ng-show with ng-if.

https://gist.github.com/elciok/b219709239f1c0d4fa62

@zakhenry
Copy link
Author

@ThomasBurleson really? Wouldn't That would mean that we can't have any angular bindings in the <head> - like title? It's worth noting both https://material.angularjs.org and https://docs.angularjs.org have their ng-app on the html tag.

@matsko
Copy link
Contributor

matsko commented Sep 18, 2015

It shouldn't matter if it's on body or html. The issue is that it somehow gets placed on a comment around where <ui-view> exists. We just need to change ngAnimate to somehow detect that the $rootElement exists on a comment node.

@ThomasBurleson
Copy link

@xiphiaz - I was recommending a generalized best-practice.
@matsko - Thx for the clarification. Agreed that would be a great check/fix.

@gkalpak
Copy link
Member

gkalpak commented Sep 18, 2015

I was recommending a generalized best-practice

Is there any reason why putting ng-app on <html> isn't a good practice (or do you mean that it is common to put it on the body) ?

(I personally think either is equally good a practice - but I might be missing something 😃)

@ThomasBurleson
Copy link

@gkalpak - IMO ng-app establishes the context for directives and controllers... I have never needed that functionality outside the body, hence the recommendation.

@gkalpak
Copy link
Member

gkalpak commented Sep 18, 2015

I usually like being able to ng-bind the <title> in <head>, but other than that I don't think I've ever done anything else with Angular outside of <body> (not that I haven't tried 😛).

@Tathanen
Copy link

Yeah, every Angular app I've developed has modified the meta title tag on route change, I'd certainly recommend ng-app as high up in the DOM as possible as the best practice. I'll also define a "site" controller on the HTML tag to contain the logic for those kind of high-level actions.

@ThomasBurleson
Copy link

@Tathanen - interesting. Thank you for this.
@ALL - Is this best practice in John Papa's AngularJS Best Practices / Style Guide?

@ddennis
Copy link

ddennis commented Sep 24, 2015

I am not sure if this is fixed or not ?
Which version is stabel?

@ThomasBurleson
Copy link

@MadMub
Copy link

MadMub commented Sep 28, 2015

Any updates?

Currently still experiencing animation issues when using material 0.11, UI router 0.2.15, and angular 1.4

I couldn't tell from the comments, is it fixed if the app is bootstrapped on the body and ui-view placed on a child div?

My project bootstraps on html and ui-views directly on body.

@Tathanen
Copy link

For the record, 1.4.4 fixed my usecase.

@MadMub
Copy link

MadMub commented Sep 28, 2015

Just tested today with 1.4.6, are you using ui-router, if so where is your top level UI router (mine currently on body tag). Thanks.

@MadMub
Copy link

MadMub commented Sep 28, 2015

Sorry, meant to say if so where is top-level ui-views.

@dannymcpherson
Copy link

In case it helps anyone, my sidebar animations were broken with

  • angular#1.4.4
  • angular-material#0.10.1
  • angular-animate#1.4.4
  • angular-ui-router#0.2.14

Upgrading to angular-animate#1.4.7 fixed the issue.

@ghost
Copy link

ghost commented Oct 6, 2015

I also have the same problem with $animate.addClass, animation classes are not being added. I am using:
#1.4.7
angular-animate#1.4.7
I am not using angular-material.

@Edorka
Copy link

Edorka commented Oct 9, 2015

Same from me with 1.4.7 in both angular and angular-animate

@russhendy
Copy link

Using 1.4.7 I found that the issue seemed to be that my BODY element was an ng-app and and ng-view. As discussed above I altered this like so:

 <body ng-app="myApp">
    <div class="bodycontainer" ng-view="">
    </div>
    ...
 </body>

... and my animations started to work.

@ThomasBurleson
Copy link

@russhendy 👍

@zakhenry
Copy link
Author

Angular 1.4.7 seems to have fixed my original issue - angular animate is now working again.

Also, to confirm setup with others, I'm using angular material and ui router, with the ng-app on the <html> and the ui-view on the <body>

<!DOCTYPE html>
<html ng-app="app" ng-strict-di>
    <head>
        <title>{{AppController.pageTitle}}</title>
        <base href="/" />

    </head>

    <body ui-view="app" layout="column" layout-fill></body>

</html>

@jherman
Copy link

jherman commented Nov 4, 2015

I'd like to add that I am also still seeing this issue. I had a hard time finding related google searches based on this issue, so instead I posted this issue on stackoverflow at the time:

http://stackoverflow.com/questions/33420664/angularjs-why-are-the-animation-classes-not-appended-during-ng-hide-show-transi

Just found this case issue today, and wanted to let you know I've tried the steps here, upgrading to

1.4.7 angular/angular-router
0.2.15 ui-router
0.11.4 angular material

My current ng-app is at <html> (I have a controller there too), and originally my ui-view was one child below <body>. Tried moving ui-view to <body>, but that didn't help. Any ideas?

@jherman
Copy link

jherman commented Nov 4, 2015

I've added a codepen showing this:

http://codepen.io/anon/pen/OyoyYX?editors=101

If you are using chrome, look into the debugger browser. You can see the enter/etc classes are not being attached.

@pauloinfotec
Copy link

Hi, i am trying to use animation with angular 1.4.7 and angular-strap to animate my modals and alert messages. Someone can help me ?

@SuneRadich
Copy link

I too see issues with ngAnimate, both in Angular 1.4.7 and Angular 1.5.0.b2. I am using ui.router 0.2.15.

The weird part is, that animations work as expected when switching states in ui.router, but the animation classes are not added for ng-repeat directives in the views.

@sDaniel
Copy link

sDaniel commented Nov 24, 2015

For me the cause for css classes not being applied seemed to have been an old version of angular-bootstrap (ui-bootstrap-tpls.js) which I updated from ~0.13.4 to ~0.14.3. (Angular 1.4.x)

@rschoenbichler
Copy link

same problem here,
animation classes are only added to the view container

@Narretz
Copy link
Contributor

Narretz commented Dec 2, 2015

@jherman Your ng-show / hide elements have no animation CSS associated with them, that's why the classes are never added.

@Narretz
Copy link
Contributor

Narretz commented Dec 2, 2015

Hi,
I'm going to lock this conversation for the following reasons:
The original problem has been fixed. Any new post here is basically lost, as the issue is closed. It's also quite possible that you have different problems, so it's just confusing to have all of them in one issue.
For anyone who still has problems with ngAnimate when switching to 1.4, please open a new issue with a minimal reproduction / demo, in plnkr.co or codepen. Thanks!

@angular angular locked and limited conversation to collaborators Dec 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests