-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Animation Flicker #5262
Comments
Aside from the yearofmoo article, can you provide the 1.2 animation code you're using that is causing the flicker? |
I cut some pieces of code from my application and made it available at the Plunker. When the page is loaded, is possible see the effect (flicker) described above. |
The example wasn't fully useable, I changed a few variables so that the modal shows up when the page loads. Is this how it should function? http://plnkr.co/edit/YCd1l4HL9gw8Ummb9u3g?p=preview |
No. The modal should not open automatically, it should be hidden until the "modal open" event is triggered. |
Ahh now I understand. From what I can assume it's that the modal template loading too soon and the animation starting. It could also be that it's trying to remove the ng-hide CSS class when it isn't actually there. |
That's it (... too soon modal template loading and starting the animation). I changed the "templateUrl" property to "template", passing the template as a string, and the problem stopped happening. |
Very nice! :) Can I close the issue? |
Yep :/. But I still believe that this is still a bug, because all the custom directives that have CSS animation class (xyz-animate) in the main element, got a external template, and its default status is "display: none" (ngShow/ngHide) will have this bad behavior. I would like to help, but at the moment, I have no idea of where this error can be explored in the Angular. |
Hi, I fixed the error as follows:
At the time it was the best alternative to solve the problem. Note: The directive "ng-cloak" does not work in this case. |
@andrelom what should we do next? I'm still working on another PR that fixes a flicker, but that is related to CSS animations. With the example here you're using CSS transitions. The |
Hi @matsko I created the plunkr example. |
I've been looking at the source code of the "angular-animate.js (line 291, v1.2.6)" and found this in "$animateProvider": // disable animations during bootstrap, but once we bootstrapped, wait again
// for another digest until enabling animations. The reason why we digest twice
// is because all structural animations (enter, leave and move) all perform a
// post digest operation before animating. If we only wait for a single digest
// to pass then the structural animation would render its animation on page load.
// (which is what we're trying to avoid when the application first boots up.)
$rootScope.$$postDigest(function() {
$rootScope.$$postDigest(function() {
rootAnimateState.running = false;
});
}); Replacing the piece of code with the current code below, the error has stopped. $rootScope.$$postDigest(function() {
// Just a "jerry-rig" :P
$timeout(function () {
rootAnimateState.running = false;
}, 500);
}); I have little knowledge of the source code of ngAnimate, but reading the code and the comments, I believe the problem is at this point. |
The issue shows up in your plunkr example, but when replicated locally it doesn't. My guess is that plunkr loads things slower than if you do it locally and that way everything downloads in time. Any idea how we can replicate this? |
I've tested it using a server created with "Node" and "Express", this worked for me (the error appeared). https://www.dropbox.com/s/xbp4or1o0m0dbf5/issue.zip Previously I did a test and it worked, but it is not the best way, right now I'm just discussing an idea about a possible solution as follows: function isRequesting() {
return $http.pendingRequests.length > 0;
} $rootScope.$watch(isRequesting, function (value) {
if (value) {
rootAnimateState.running = true;
} else {
rootAnimateState.running = false;
}
}); I'll wait for new ideas about the error, before I can talk about this, possibly because this can be not the way, and I will lose the line. |
FWIW, I fixed this is with overwriting the ngShow directive with a delegate:
When the $watch is called for the first time, both values are equal. When these initial values are falsy, don't use $animate, just add the ng-hide class. The toBoolean function is necessary since it's not public. |
@matsko Can you take another look at this? The above fix might just fix the symptom, but this still an issue with the latest beta / snapshot. |
@matsko, have you had time to take a look at this? Thanks! |
…boostrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
@andrelom @Narretz Finally there's a fix for this: It should be released by the end of the week. |
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
Hi @matsko, thanks for the fix. Unfortunately, in this specific example your fix does not work: http://plnkr.co/edit/nbo5de9GpmBOZf9J29Hu?p=preview It's seems like these are two different bugs. In the example, there's a ng-show animation inside the modal, which fires after the modal opens, while it should stay hidden. |
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
…bootstrap Prior to this fix when an Angular application is bootstrapped it would only place an animation guard to prevent animations from running when the application starts for the first two digest cycles. However, if any controllers or directives, that are executed upon boostrap, trigger any remote code to be downloaded (via $http) then the guard does not put that into consideration. This fix now properly addresses that circumstance and removes the guard once all outbound HTTP requests are complete when an Angular application is bootstrapped. Closes angular#8275 Closes angular#5262
@Narretz thanks so much for the temporary decorator fix. saved me who knows how much time! |
I created a directive that uses the "ngShow" and "ngAnimate". When this directive is loaded by the first time, it appears and disappears (flicker).
Tried to fix by checking if the problem was in my code. I don't have idea if it is normal or not, but is strange.
For now, I fixed the problem by using the "element [0] style.display = 'none';".
In the "http://www.yearofmoo.com/2013/05/enhanced-animations-in-angularjs.html", Matias talk about this (Animations are skipped the first time after a directive is compiled).
I read others articles about that, but I believe the "problem" still happens in Angular 1.2.
The text was updated successfully, but these errors were encountered: