-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ngAnimate (v1.2.0rc1) : ngRepeat shows stale items #3613
Comments
After further investigation, I have found that the following lines of code are the culprit: https://github.com/angular/angular.js/blob/master/src/ngAnimate/animate.js#L552 Basically if you remove I think it comes down to |
Hey @damrbaby, the 1st $timeout is necessary so that the browser has a change to redraw the page and apply the styles. When we add the class onto the element then it can sniff the transition/keyframe durations and delays from the element. The 2nd one is absolutely required so that it can capture the animation in between. Here are my proposed solutions:
Can you possibly try setting the |
@matsko Unfortunately both of your suggestions didn't work. I tried changing the first $timeout for I also tried the above change in addition to just calling the done() callback without wrapping it in $timeout, with no luck (see this plunkr) The only solution is to change both of those lines to not use a $timeout at all. See this plunkr which results in the expected behavior. But that won't work if I did add CSS animations to the elements in question. |
@damrbaby turns out that both $timeout calls are required, but not to worry, changing them around seems to have helped. Can you take a look at the link and verify if it has the flicker/stale items bug that you mentioned? Here's the link: https://s3.amazonaws.com/angularjs-dev/reflow-bug/example/animate.html |
@matsko the issue remains. If you change the |
Just to add, I am noticing flickering issues absolutely everywhere in my apps which I started to port. As well as in situations with inline-block and floated adjacent elements, I am also experiencing similar issues in many other contexts. For example with elements which are absolute positioned, where their position is derived based on dynamic CSS classes (set using ngClass). Whenever the classes on the element change, it appears that momentarily the element resets it's position to 0,0 before adjusting to their correct position. It behaves as if there is a split second when it has no classes, even though that is not the case. |
@damrbaby the code is changed again, please try again (do a hard refresh since it's the same URL). And I copied your own demo to use the updated code: The non-animated code should not touch any $timeout operation now. |
Hey @matsko, I can confirm that the flickering issue is solved for non-animations using the above code! Thanks! |
You have no idea how happy I am to hear that @damrbaby! |
Yay! I don't want to ruin the party @matsko, but it appears that there is still a slight performance hit with an |
@damrbaby we can focus on performance issues with ngRepeat + ngAnimate once this is merged into master. |
Wouldn't it be possible to get rid of the timeout by forcing a reflow by accessing a property like offsetWidth? That would probably be a lot faster. See https://github.com/twbs/bootstrap/blob/f95ab89fb1da85ff0fcb95c43d4fe4af359e302a/js/tab.js#L77 for an example. |
@jwagner would this work in cases where the width isn't being transitioned/animated? Say you change the background color? |
…imations are used ngAnimate causes a 1ms flicker on the screen when no CSS animations are present on the element. The solution is to change $animate to only use $timeouts when a duration is found on the element before the transition/keyframe animation takes over. Closes angular#3613
@matsko yes. Quick example: http://plnkr.co/edit/pocTw4fTOp6olOoQcm4S?p=preview |
Ouuu nice! Testing it out with ngAnimate... |
Landed as ee2f3d2 |
@jwagner can you please make a new PR with your reflow fix? Just a small blurb with what you mentioned here. |
I'll have a look at it, but I'm not sure if I'll be able to find my way around the code in a reasonable amount of time. :) |
No it doesn't have to have any code in AngularJS. Just copy and paste what you wrote here. |
@matsko I'm not quite sure what you mean by 'Just copy and paste what you wrote here.'. The comments? In any case I think I've found the place where it belongs: But it has the side effect of breaking every other test (43 in total) for ng-animate. :( |
@jwagner I've been using your |
@matsko Do you have it in a branch somewhere? I'd be happy to take it on a little test drive. |
@jwagner it's in master now. |
@matsko sorry to say still having issues with |
@matsko digging into it I think the lag is coming from the Is there a reason why |
…imations are used ngAnimate causes a 1ms flicker on the screen when no CSS animations are present on the element. The solution is to change $animate to only use $timeouts when a duration is found on the element before the transition/keyframe animation takes over. Closes angular#3613
I am not sure why this is closed, but i still see this issue on current rc3 latest code? Can anyone kindly show me the fix? To further illustrate, here is my reproduction plunker: http://plnkr.co/edit/lnsxCySFGmUmAnYDqVm3?p=preview |
@cheahkhing The reason you are still seeing the old items still in the list, is because you actually have a 1 second leave transition on the items in your example, so that behaviour is expected. They take 1 second to fully disappear, and in that one second the new items will be appearing. Since you are adding and removing items at the same time, it is expected that both the enter and leave transitions would fire at that time. This issue was referring to a bug where even without a transition, there would be a momentary overlap of the two sets of items. |
…imations are used ngAnimate causes a 1ms flicker on the screen when no CSS animations are present on the element. The solution is to change $animate to only use $timeouts when a duration is found on the element before the transition/keyframe animation takes over. Closes angular#3613
I, it seems that I'm still facing this issue with latest angular version. Whenever I import ng-animate in my module I got this problem. Any idea ? |
Same here, |
Yes, this is serious. I'm also facing this issue with Angular 1.3.5. Ended up removing 'ngAnimate' module from the app. |
@bimal1331 Just add a css class like // Let ngAnimate know which elements to not handle
$animateProvider.classNameFilter(/^((?!(repeat-modify)).)*$/) Then you can continue using |
Thanks @kbdaitch for the suggestion. |
having the same issue with angular 1.3.15 and bootstrap .form-control class on the repeated items. is anyone looking into this? |
I have the same issue with Angular 1.3.16 on Foundation for Apps framework. @kbdaitch's solution works for me, and the elements are not being combined. |
@kbdaitch's solution definitely works. Thanks! |
Any test with angular 1.4 without having to modify something ? |
Seeing this in 1.4.1. The repeated elements have no transitions or keyframe animations. Will try and get a Plunker example going. |
Plunker example ~ http://plnkr.co/edit/uReg3o5JQ03zrVNN9t8P?p=preview Putting this together, I noticed that it actually is due to a transition on the item elements however that transition is only on the Overriding the transition with
fixes the issue. |
Had the same problem with 1.4.0 and @philBrown suggestion fixed it. |
The problem is that In addition to the other methods of side-stepping this, another solution is to simply do: .thumbnail.ng-animate { transition: none; } You can also place the thumbnail as its own element within the element containing the ng-repeat directive. Unfortunately there's nothing we can do to detect this due to the nature of specificity. Angular 2.0 will have a better approach to this, but Angular 1.x can't be changed. |
I will be locking this issue since anything involving CSS detection may result in a misinterpretation of detected transition and/or keyframe styles. So if you have a CSS style like: div { transition:0.5s linear all; }
div:hover { outline:5px solid red; } Then anytime a div is animated via ngAnimate it will assume that a transition of The unfortunate thing here is that some frameworks like boostrap and gumby spinkle transition values onto elements in a global way. The solutions to fix this are to:
If you do happen to have an issue that shows up despite using any of these solutions then please open a new issue. |
When updating an array that is used for an
ngRepeat
, the list will momentarily show what appears to be the previous items together with the new items before updating with the new items. This only happens whenngAnimate
is a dependency for the app.Please see http://plnkr.co/edit/fqrI0w1j0HqtV3CTzsFI?p=preview
When you click on the different lists in the above example, you will see how it momentarily shows a combination of the previous and current lists before showing the current one.
Watch carefully, it happens very fast!
This buggy behavior will not occur when you remove
ngAnimate
.This bug is serious because it makes
ngAnimate
virtually unusable for apps that usengRepeat
due to the flashing.The text was updated successfully, but these errors were encountered: