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

Concurrent class-based animations, Promises API for Animations & Fixes to Staggering Animations #8637

Closed
wants to merge 3 commits into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Aug 16, 2014

Grouped Class-Based Animations

Now something like this works fine:

//feel free to call addClass, removeClass and set Class
//as much as you want within your directive code.
$animate.addClass(element, 'one');
$animate.addClass(element, 'two three');
$animate.removeClass(element, 'three');
$animate.setClass(element, 'five', 'one four');

//one animation is run that combines everything together
$rootScope.$digest(); 

//Now the following animations are run at the same time
// -> addClass : 'two five'
// -> removeClass : 'four'

Promise Callbacks for Animations

The doneCallback function parameter is no more. Use a promise instead.

//before
$animate.addClass(element, 'blue', doneCallback);

//after
$animate.addClass(element, 'blue').then(doneCallback);

$timeout-based Stagger Animations

This fix uses $timeout behind the scenes instead of animation-delay animation transition-delay. It also adds another CSS class called ng-EVENT-pending. This new setup allows for 3rd-party CSS keyframe animations to work with Angular-defined stagger styles nicely.

https://s3.amazonaws.com/angularjs-dev/class-based-fixes/animate.html

Closes

Closes #7228
Closes #7547
Closes #8297
Closes #8547

@matsko matsko changed the title feat($animate): coalesce concurrent class-based animations within a digest loop Concurrent class-based animations & Promises API for Animations Aug 16, 2014
…igest loop

All class-based animation methods (addClass, removeClass and setClass) on $animate
are now processed after the next digest occurs. This fix prevents any sequencing
errors from occuring from excessive calls to $animate.addClass or $animate.remoteClass.

BREAKING CHANGE

All directive code that expects any addClass, removeClass or setClass animations to kick
off immediately after being called must now be aware that the animation will only take place
once the next digest has kicked off. Also note that successive calls to $animate.addClass,
$animate.removeClass or $animate.setClass will be grouped together and will not cancel the former
class-based animation (once the digest has passed).

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
The $animate service (both the service inside of ng and ngAnimate) now
makes use of promises instead of callback functions.

BREAKING CHANGE

Any existing directive code that makes use of animation callbacks provided
directly into any of the methods available $animate must now be converted to
use promises instead. Also, the `cancel` function (which was the return value
from each of the $animate methods) is now returned as a member function on the
returned animation promise.

```js
//before
var cancelFn = $animate.enter(element, container, null, callbackFn);
cancelFn(); //cancels the animation

//after (without cancel)
var promise = $animate.enter(element, container).then(callbackFn);

//after (with cancellation method)
var promise = $animate.enter(element, container);
promise.then(callbackFn);
promise.cancel(); //cancels the animation
```
@matsko matsko changed the title Concurrent class-based animations & Promises API for Animations Concurrent class-based animations, Promises API for Animations & Fixes to Staggering Animations Aug 16, 2014
…mations

When transition-delay and animation-delay were used to drive the staggering
animation the result was unpredictable at times due to the browser not being
able to register the generated delay styles in time. This caused a hard to
track down bug that didn't have a solid solution when styles were being used.

This fix ensures that stagger delays are handled by the $timeout service.

Closes angular#7228
Closes angular#7547
Closes angular#8297
Closes angular#8547

BREAKING CHANGE

If any stagger code consisted of having BOTH transition staggers and delay staggers
together then that will not work the same way. Angular will no instead choose
the highest stagger delay value and set the timeout to wait for that before
applying the active CSS class.
@matsko
Copy link
Contributor Author

matsko commented Aug 26, 2014

MERGED
2f4437b
bf0f550
23da614

@matsko matsko closed this Aug 26, 2014
@matsko matsko deleted the animate_class_digest branch August 26, 2014 15:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.