-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Hidden animated panels are visible on page load #12825
Comments
Can you please post a demo via plnkr.co or similar that shows the problem? |
Demo: http://plnkr.co/edit/xWkbSWkKu2fMfUhRdvsk . When the application starts, you will see the hidden animated panel. |
A little more info: This seems to have been introduced in 1.4.0-rc.0 (aka the big What I haven't figured out yet, is what causes the |
Aha...it's the So, I am tempted to say that this works as expected (in the sense that it's a documented breaking change). |
As is usually the case, moving the directive on a child element solves the issue. E.g.: <!-- Change this: -->
<div ... ng-show="..." ng-include="...">Pane</div>
<!-- To that: -->
<div ... ng-show="..."><div ng-include="...">Pane></div></div> Here is an updated plnkr. So, like I said, I am inclined to calling this a |
Thanks for investigating @gkalpak! |
@Narretz, I'm not sure what you mean by "the ngInclude does not have actual animation code". |
That's right, it initiates an animation but when no styles are found the
|
@Narretz, you are right; it's not Here's what is going on in both cases (with 1. <div ... ng-show="..." ng-include="...">...
Compare this to: 2. <div ... ng-show="..."><div ng-include="...">...
That said, I still think this works as expected. It remains to be investigated, why it did work prior to |
Here is why it used to work prior to Class-based animations were "blocked" on elements currently performing a structural animation (see animate.js#L517-L525). So, not allowing class-based animations while a structural animation (like After all, allowing class-based animations along with structural ones is a feature (not a bug) 😃 |
If anyone's interested, here are two demos:
|
Interesting. In this comment #11492 (comment), Matias said that animate would wait for the templates to download ... |
As a workaround, you can put your templates into the templateCache when your module runs: http://plnkr.co/edit/Q6o13RNXjdRtmw8LW67W?p=preview There are also build tools that do this automatically for you, e.g. https://github.com/karlgoldstein/grunt-html2js |
Matias is right (obviously 😃). It (sort of) does. That's why there is no animation when |
The fact that it works (at least visually) when you add the template to the cache when the app runs, makes me think there is still a difference. Because template fetching is still async, even if the template is cached. It looks more like a timing issue. |
There's definitely something strange going on: ng-animate is adding these bogus classes on the initial hide / enter animation: Forked example with classList log: http://plnkr.co/edit/FDEAbvvjVJzZccuZWMwY?p=preview |
Yes, I've noticed it. This happens because the (non-structural) It would be nice to fix that, but I don't think it is causing any issues. |
I've talked with @matsko about this and he said he would do some investigating. It's expected that the animations are merged, but the way they are merged doesn't look right. The actual problem in the issue is caused by the way ngAnimate blocks animations on bootstrap. It waits two digest until animations are enabled. ngInclude calls $enter inside a watchActionFn, so it's happenind one digest later. We could delay animations further, but I'm not sure if that won't break some expectations. However, if you put it in the templateCache (best practice anyway) it doesn't animate, so it's probably more consistent to wait another digest. |
The way That being said, I don't think it is reasonable to change how
The current mechanism, tries to account for route and directive templates and it does it quite well. They can put them into wrappers, load templates into the |
Quick (& dirty) workaround is to add ng-hide class to the element. |
Hi,
I have hidden floating panel.
HTML:
<div class="modal animated left-modal " data-ng-hide="!showFormCreator" ng-cloak data-ng-controller="formCreatorController" data-ng-include="'/app/views/form-creator.html'"></div>
CSS:
In angular 1.3.13 works all fine.
After update to 1.4.4 and now to 1.4.5 all hidden animated panels are visible on page load for few seconds.
After page load is all fine.
Thanks for help.
Josef
The text was updated successfully, but these errors were encountered: