Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

$animator: chaining or cancelling animations (show/hide) #2332

Closed
olostan opened this issue Apr 8, 2013 · 5 comments
Closed

$animator: chaining or cancelling animations (show/hide) #2332

olostan opened this issue Apr 8, 2013 · 5 comments
Assignees
Milestone

Comments

@olostan
Copy link
Contributor

olostan commented Apr 8, 2013

Currently there is no way to cancel/chain animations.

This leads to unexpected behaviour: if you have some elements under ngShow and quickly change expression (not waiting until animation is finished) you'll have your elements hidden even if ngShow expression is true.

Here is example: http://plnkr.co/edit/67Q96KmExV78Kd84tq4g?p=preview - wait until elements will show and quickly toggle checkbox (on and off) and you'll see that no elments would be shown.

I assume the solution should be to stop animation on element (so removing all added classes in case of CSS3) AND call afterFn button in case if new animation is about to be started. Or there is better solution (chaining of animations?)

@olostan
Copy link
Contributor Author

olostan commented Apr 12, 2013

Tested with AngularJS v1.1.5-570463a - issue still actual. Updated plunker.

@matsko
Copy link
Contributor

matsko commented May 27, 2013

Animations are cancelled as soon as another animation is called in 1.1.5. Chaining them isn't supported yet. However there are plans for 1.1.6 with promises since 1.1.5 supports custom animations.

@pdf
Copy link
Contributor

pdf commented Jul 19, 2013

The real pain-point here is that ngShow/ngHide can land in an inconsistent state if, for example, there is animation in only one direction (hide or show), and the expression changes while the animation is in progress. This means that elements can end up permanently hidden because there is no secondary animation to trigger cancellation of existing, in-progress animations, and the show/hide state never gets updated (or, more precisely, for ngHide, the element is still hidden on the back of the animation even though the expression changed to falsy while the animation was in progress, and vice-versa for ngShow).

This could be handled by one if the proposed animation completion callbacks, but it shouldn't need to be handled in client code IMO.

@matsko
Copy link
Contributor

matsko commented Oct 23, 2013

Fixed with PR: #4612

Here's the working code:
http://plnkr.co/edit/vMgX3H9r9nlMbKxZOzBL?p=preview

matsko added a commit to matsko/angular.js that referenced this issue Oct 24, 2013
Skip addClass animations if the element already contains the class that is being
added to element. Also skip removeClass animations if the element does not contain
the class that is being removed.

Closes angular#4401
Closes angular#2332
@matsko matsko closed this as completed in 76b628b Oct 24, 2013
@matsko
Copy link
Contributor

matsko commented Oct 24, 2013

Landed as #2332

@matsko matsko reopened this Oct 24, 2013
@matsko matsko closed this as completed Oct 24, 2013
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Skip addClass animations if the element already contains the class that is being
added to element. Also skip removeClass animations if the element does not contain
the class that is being removed.

Closes angular#4401
Closes angular#2332
jamesdaily pushed a commit to jamesdaily/angular.js that referenced this issue Jan 27, 2014
Skip addClass animations if the element already contains the class that is being
added to element. Also skip removeClass animations if the element does not contain
the class that is being removed.

Closes angular#4401
Closes angular#2332
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants