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

fix(ngAnimate): let $animate.cancel() reject the runner promise #16373

Merged
merged 1 commit into from
Feb 2, 2018

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Dec 13, 2017

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
fix

What is the current behavior? (You can also link to an open issue here)
See #14204

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change?
Yes

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Fix/Feature: Docs have been added/updated
  • Fix/Feature: Tests have been added; existing tests pass

Other information:

There is another aspect to this problem that is not fixed by this PR:
2. Cancelling css animations should immediately abort the animation and set the DOM / css to its final state. This is currently broken in FF and IE11 (at least), see https://bugzilla.mozilla.org/show_bug.cgi?id=1425014. This must be tested with e2e test. Fixing this is not a BC.

Closes angular#14204

BREAKING CHANGE:

$animate.cancel(runner) now rejects the underlying
promise and calls the catch() handler on the runner
returned by $animate functions (enter, leave, move,
addClass, removeClass, setClass, animate).
Previously it would resolve the promise as if the animation
had ended successfully.

Example:

```js
var runner = $animate.addClass('red');
runner.then(function() { console.log('success')});
runner.catch(function() { console.log('cancelled')});

runner.cancel();
```

Pre-1.7.0, this logs 'success', 1.7.0 and later it logs 'cancelled'.
To migrate, add a catch() handler to your animation runners.
@Narretz Narretz changed the title WIP: fix(ngAnimate): let $animate.cancel() reject the runner promise fix(ngAnimate): let $animate.cancel() reject the runner promise Dec 21, 2017
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh nice, an example.
LGTM except I suspect it is being over-tested.

@@ -934,6 +935,195 @@ describe('animations', function() {
}));
});


describe('$animate.cancel()', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it enough to check that runner.cancel is called, since runner.cancel appears to have comprehensive tests of its own?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that's right, just the runner tests don't test with actual DOM elements and not with the $animate functions. Your call whether it should be simplified.

@Narretz Narretz merged commit 16b82c6 into angular:master Feb 2, 2018
@Narretz Narretz deleted the fix-animate-cancel branch February 2, 2018 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants