-
Notifications
You must be signed in to change notification settings - Fork 6.7k
refactor(modal): use $animate for animation #1772
Conversation
Yeeeeah, that is what I wanted to see. Two things I noticed. There is no need to load |
Wow, it starts to look interesting. I still wonder if it would be somehow possible to keep the |
@pkozlowski-opensource , unfortunately, if we want to allow users to be able to customize/replace the animations, they have to be in the JS code. There's also no way of telling which animation has ended without checking the event's data ( I think if we can restrict class names to be only in animation code (perhaps only used by "animator" services), I think it won't be so bad since AngularJS 1.2 animations use classes quite extensively. |
I am not so sure if I understood the problem so maybe what I am going to say have no sense, but here we go: If the class needs to be hardcoded. Can't we just configure it on a provider? So if someone decide to use don't know, foundation and they need the Maybe I am mixing things, but brainstorming is free :P |
@Foxandxss I've modified the animator so that one can override just the |
@chrisirhc I like the end result. Can you explain to me (for learning purposes) why $decorate it? A provider won't work in that case? |
@Foxandxss sure, I used $decorate here so that the animations can be overridden. This implementation sets up a default animation behavior. The intention is that users can read this implementation and be able to do the same |
Hi, I got a question about this. I am currently experimenting with using the modal as the basis for an off-canvas menu. For this I need to fire additional animations on different DOM elements at the same time the modal is opening. Would something like this be possible with this code? |
@Narretz , yes, you can do all the animations you need on the element and any sub-elements and call the |
Okay, but what I actually need to do is sync animations on the body and the modal, so no descendants. I need to test this then. I merged your changes into current master and put everything in a plunker to test. There's one problem: when I first open the modal, the visibleClass does not get set: click on the 'open' button, modal is not visible. Hit ESC to close, click 'open' again -> modal shows. I logged the element in 'afterEnter', and it appears to be a fragment / disconnected DOM tree. It appears to be a problem with the templateCache: in the first run, the template is an ajax request, and in subsequent 'openings' it is cached already. http://plnkr.co/edit/mIfavH64Z21132YrEh6K?p=preview In my app, the class doesn't get added at all, so there might be another problem. |
|
Ok, I have misunderstood how the integration works. From what I can say, $animate in the modal actually does not use the enter() and leave() classes and the css animations, but it simply handles adding and removing the modal element, while the transition / animations come from bootstrap, at least in the default implementation. |
@Narretz , that's right, it doesn't use the enter and leave classes because these classes don't exist on the bootstrap stylesheet unless you add them manually to your custom stylesheet. If you want to customize the animation, you need to override the default implementation of Is that clear? Does that work for your case of custom animations? |
Well, I have test if I can use $animate like I need. There is also another thing: in removeModalWindow(), the check for removing the backdrop is called in the modal window leave callbck:
But I think it should be called after / before it, so if the backdrop needs to be removed, both animations happen roughly at the same time. This is important if you want to change the animations in the $delegate. |
+1 for acceptance on this PR. I'd really like to be able to disable all my animations in my e2e tests, and ui-bootstraps implementation is currently preventing this. |
+1 I simply want to disable the modal slide-in effect. This solution worked for me, but looks like a bit of hack: http://stackoverflow.com/a/23373622 |
I played around with this a little more, and it works quite well (with the fixes I mentioned earlier): There's just one problem: It currently doesn't work very well to $animate.addClass an element inside the modal when you $animate.enter the modal window, because structural animations block all other animations inside them. There was some talk about explicitly enabling non-blocking animations here: angular/angular.js#7105 |
Closing this in favor of #2724. The new PR won't make use of $animate.enter and hence won't block animations in the modal. It's also minimal changes to the current code. |
The demo change is included just for convenience.