You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
When an ng-animate-ref element is cloned before an animation, I would expect it to look exactly the same as its source element. Instead, when the source element has styling applied because of the specific context it is in (e.g. .context .source-element { background: green; }), this styling is not applied to the cloned element.
This makes the animation weird: it first snaps to the styling the .source-element would have when in no context, and then animates to its new context. Example: http://plnkr.co/edit/AXzKmQcE5BUx4NXg4cCS?p=preview. When clicking an element, it first snaps to a blue background, before animating to a black background. I would expect it to animate directly from a green to a black background.
This can be worked around by simply applying all styling directly to the source element to be animated (e.g. .source-element-in-context { background: green; } (see this plunker: http://plnkr.co/edit/Odho9WnoOm9JFv3gzzZl?p=preview), but it makes much more sense to me when angular itself applies all styling of the source element to the cloned element.
In this case, the last row has a position: fixed. Right now it snaps before animating. It would be cool if angular would put the cloned element on exactly the same position as the fixed element is.
I agree. This is also an issue with elements nested inside the element and their contextual styles. I think there is only so much that you can do though.
The other method I was trying first was to call getCalculatedStyle() and use that as the new styles for the clone, but there are some issues with that that I couldn't get ironed out. I wonder if that method would be more smooth. Although it would come at the cost of performance probably.
Activity
Narretz commentedon Dec 2, 2015
Sounds resonable!
Fix(ng-animate-ref): copy contextual styling to clone
NickBolles commentedon Apr 4, 2016
I believe this is the behavior you are experiencing. Your plunker link didn't exhibit the issue for me. http://plnkr.co/edit/OLhhDaz8awp5wzLoeAr1?p=preview
I have made a PR #14366
Here is the Plunker with the modified version of ng-animate
http://plnkr.co/edit/EvBFwIGD40pHxewXCYGY?p=preview
Let me know what you think!
dweerd commentedon Apr 4, 2016
Hm I guess something went wrong with the plunker or its url. But your plunker shows what i meant. Your example of the modified ng-animate looks good!
But thinking about this some more, I would also expect this to work in more advanced cases. For example:
http://plnkr.co/edit/iZB1Y5pKFtRsJ6SLqg0w?p=preview
In this case, the last row has a
position: fixed
. Right now it snaps before animating. It would be cool if angular would put the cloned element on exactly the same position as the fixed element is.This also applies to width and height.
NickBolles commentedon Apr 5, 2016
I agree. This is also an issue with elements nested inside the element and their contextual styles. I think there is only so much that you can do though.
The other method I was trying first was to call getCalculatedStyle() and use that as the new styles for the clone, but there are some issues with that that I couldn't get ironed out. I wonder if that method would be more smooth. Although it would come at the cost of performance probably.
Fix(ng-animate-ref): copy contextual styling to clone
NickBolles commentedon Apr 8, 2016
Another example. ng-style causes this snapping behavior when going to an ng-style.
http://plnkr.co/edit/4QQ1RhHOsQ0w6lLKrJRY?p=preview
Compared to the modified:
http://plnkr.co/edit/TIQR2lv0Wa3zAwqeEhy0?p=preview