-
Notifications
You must be signed in to change notification settings - Fork 27.5k
$animateProvider.classNameFilter causes ng-hide animation to play on element load #15426
Comments
Yeah, that's odd. Although I would expect the animation to play in both cases, with and without filter. Because you clearly have an animation defined. |
This is (kind of) expected behavior. I am not sure about 1.3, but in 1.5.x a class-based animation is (by default) disabed if there is structural ( When you are not using When using Possible solutions:
|
Narretz, in case it's not clear, I don't expect the animation to play when the element loads because ng-show is initialized to false thus the element is not initially visible. gkalpak, solution #1 works like a charm, albeit it is not intuitive to me why that is. |
I discovered an alternative solution. Replacing the ng-show with an ng-if with appropriate CSS changes, exhibits the behavior I expect. |
SIDE NOTE: The class name filter was added because a performance increase was observed with Angular 1,3. Today I reexamined the issue with 1.5 and I don't see any performance increase. Therefore I am considering solving this issue by simply removing the class name filter. |
Since the current behavior seems to be intended and you were able to make it work for you, I am going to close this. |
I'm still confused why this is the expected behavior. Is it expected behavior that an element initialized to ng-show=false should be initially visible? And if so, why does ng-if behave differently? |
The difference is that
-- With
With
--
The |
I think I understand why it behaves the way it does. I'm sorry I didn't make that clear. Referring to ng-if was probably a distraction. My question is, regardless of implementation details, why should we expect an element with ng-show initialized to false to be initially visible? |
Maybe we shouldn't. Part of the reason why this happens is 667183a. Because It might make sense to have the class applied immediatelly (e.g. via That is |
Upon upgrading from AngularJS 1.3 to 1.5, I think I have encountered a bug in ngAnimate.
When:
Upon load of the element, the ng-hide animation is played.
In 1.3 the ng-hide animation did not play and if I remove the call to $animateProvider.classNameFilter the animation does not play, so I do not expect the animation to play in the case above. Instead I expect the element to be hidden upon load.
A plnkr is here:
https://plnkr.co/edit/PwmgrB8X8SRHpOpNYnFb
Click on "Toggle Container Visibility" and observe that a sliding animation is played. Next, comment out $animateProvider.classNameFilter(/animate-/); in script.js and observe that the animation does not play.
The text was updated successfully, but these errors were encountered: