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

ngAnimate cache prevents transitions on added classes in FF #8813

Closed
mike-suggitt opened this issue Aug 28, 2014 · 16 comments
Closed

ngAnimate cache prevents transitions on added classes in FF #8813

mike-suggitt opened this issue Aug 28, 2014 · 16 comments

Comments

@mike-suggitt
Copy link

ngAnimate uses "getElementAnimationDetails" to cache CSS transitions on load but currently i'm aiming to ensure that onload there are no transitions and then after load I assign a class that then enables transitions on new items.

Example sass might be:

.parent {
     .element {}

     &.isloaded {
          .element {
                transition: 5s linear all;
           }
     }
}

if I dynamically apply the "isloaded" class later on then the cache prevents ngAnimate from attaching the relevant "ng-enter" and "ng-enter-active" classes.

If I comment out the cache logic then the element gets re-evaluated and transitions are applied.

P.S seems to work in chrome bizarrely but not in firefox

@matsko
Copy link
Contributor

matsko commented Aug 28, 2014

The cache expires after the requestAnimationFrame is done so it shouldn't keep items in there afterwards. Can you provide some example code from your template or a demo?

@mike-suggitt
Copy link
Author

I can try and put something together. Interestingly I can't find requestAnimationFrame method in the code.

I'm using angular v1.2.16 and seperate angular-animate

@matsko
Copy link
Contributor

matsko commented Aug 28, 2014

@mike-suggitt
Copy link
Author

So are you suggesting that if I force a reflow on the element then the cache should be cleared and then I can go on my merry way with transitions?

@matsko
Copy link
Contributor

matsko commented Aug 28, 2014

I would need to see how your code is put together first.

@mike-suggitt
Copy link
Author

so it looks like afterReflow doesn't get called at all after i've assigned the dynamic class

@matsko
Copy link
Contributor

matsko commented Aug 28, 2014

Is this by chance inside of a leave animation or for enter?

@mike-suggitt
Copy link
Author

im aiming to use the "enter" animation

@matsko
Copy link
Contributor

matsko commented Aug 28, 2014

OK. Anyway you can post this online somewhere? I can then debug it and figure out what's going on.

@mike-suggitt
Copy link
Author

try this? http://jsfiddle.net/mDVgX/41/

@mike-suggitt
Copy link
Author

I can trick it into a reflow if I apply a transition to the element receiving the additional class

e.g. {transition:0.01s linear all;}

@matsko
Copy link
Contributor

matsko commented Aug 29, 2014

Yes there is definitely a bug going on here. Even on the latest master it's the same thing.

I'm working on a fix.

PS. Your demo is using a really old version of Angular. In the future please use the latest one via http:/code.angularjs.org/snapshot.

@mike-suggitt
Copy link
Author

Yes I know my apologies, just ripped off an existing setup as im pressed for time.

Thanks

@btford btford added this to the 1.3.0 milestone Sep 3, 2014
@jeffbcross jeffbcross modified the milestones: 1.3.0-rc.5, 1.3.0 Sep 29, 2014
@IgorMinar IgorMinar changed the title ngAnimate cache prevents transitions on added classes ngAnimate cache prevents transitions on added classes in FF Oct 1, 2014
@matsko matsko self-assigned this Oct 1, 2014
@matsko
Copy link
Contributor

matsko commented Oct 2, 2014

@mike-suggitt the bug is consistent across 1.2 and 1.3 for all browsers. Basically if you start toggling the button before your five second timeout has passed then it permanently caches the class details thus not allowing for anything to work.

1.3 (try with Chrome and Firefox):
http://jsfiddle.net/mDVgX/47/

1.2 (try with Chrome and Firefox):
http://jsfiddle.net/mDVgX/48/

@matsko
Copy link
Contributor

matsko commented Oct 2, 2014

I'm working on a fix at the moment.

@matsko
Copy link
Contributor

matsko commented Oct 2, 2014

Here's the fix: http://jsfiddle.net/mDVgX/51/.

I'm working on the tests for this now and then I'll merge into 1.2 and 1.3.

matsko added a commit to matsko/angular.js that referenced this issue Oct 2, 2014
$animate aims to speed up redundant calls to getComputedStyle to prevent
unessarry reflows in the event that similar elements are being animated
at the same time. A hidden bug was causing the GCS cache not to be reset
if an CSS-based animation was not found. This patch ensures that the
GCS lookup cache is always cleared after one animation reflow has
passed.

Closes angular#8813
matsko added a commit to matsko/angular.js that referenced this issue Oct 2, 2014
$animate aims to speed up redundant calls to getComputedStyle to prevent
unessarry reflows in the event that similar elements are being animated
at the same time. A hidden bug was causing the GCS cache not to be reset
if an CSS-based animation was not found. This patch ensures that the
GCS lookup cache is always cleared after one animation reflow has
passed.

Closes angular#8813
matsko added a commit to matsko/angular.js that referenced this issue Oct 3, 2014
$animate will cache subsequent calls to GCS in the event that the element
with the same CSS classes and the same parentNode is being animated. Once the
animation is started then $animate waits for one rAF before flushing the GCS
lookup cache. Prior to this fix, if GCS was unable to detect any transitions
or keyframes on the element then it would simply close the animation, but it
would not trigger the rAF code to flush the cache. This issue caused a bug
which made it difficult to detect why certain animations are not allowed to
fire if the element didn't contain any CSS-based animations beforehand.

Closes angular#8813
@matsko matsko closed this as completed in cb85cbc Oct 7, 2014
matsko added a commit that referenced this issue Oct 7, 2014
$animate will cache subsequent calls to GCS in the event that the element
with the same CSS classes and the same parentNode is being animated. Once the
animation is started then $animate waits for one rAF before flushing the GCS
lookup cache. Prior to this fix, if GCS was unable to detect any transitions
or keyframes on the element then it would simply close the animation, but it
would not trigger the rAF code to flush the cache. This issue caused a bug
which made it difficult to detect why certain animations are not allowed to
fire if the element didn't contain any CSS-based animations beforehand.

Closes #8813
bullgare pushed a commit to bullgare/angular.js that referenced this issue Oct 9, 2014
$animate will cache subsequent calls to GCS in the event that the element
with the same CSS classes and the same parentNode is being animated. Once the
animation is started then $animate waits for one rAF before flushing the GCS
lookup cache. Prior to this fix, if GCS was unable to detect any transitions
or keyframes on the element then it would simply close the animation, but it
would not trigger the rAF code to flush the cache. This issue caused a bug
which made it difficult to detect why certain animations are not allowed to
fire if the element didn't contain any CSS-based animations beforehand.

Closes angular#8813
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.