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

fix(ngAnimate): only buffer rAF requests within the animation runners #12619

Closed
wants to merge 2 commits into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Aug 18, 2015

Closes #12280

Here are demos to show that this works (test in IE):

Multiple RAF Requests in Angular 1.4 (#11791)

Material Design $$rAF perf issue (#12280)

@matsko matsko changed the title revert requestAnimationFrame batching and use timeouts for IE fix(ngAnimate): only buffer rAF requests within the animation runners Aug 19, 2015
@matsko
Copy link
Contributor Author

matsko commented Aug 19, 2015

@ThomasBurleson @AdriVanHoudt @MichhDiego this should fix the issues you guys are having.

@matsko
Copy link
Contributor Author

matsko commented Aug 19, 2015

@IgorMinar please review.


$animate.flush();
$rootScope.$digest();
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need the extra digest after flush? it wasn't necessary before and we digest just before flushing already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So beforehand what happened was:

https://github.com/angular/angular.js/blob/master/src/ngMock/angular-mocks.js#L782

  1. triggerCallbacks() issued a $$rAF.flush() internally when called.
  2. triggerCallbacks() also calls $timeout.flush(0) which calls a digest somewhere down the line.

But with the changes to use $animate.flush() we end up having to do this:

  1. $animate.flush() clears out the RAF for the runner.
  2. $rootScope.$digest() allows for the resolved promise to flush (which can only be done after the RAF has flushed).

So we need to call RAF + digest always.

@IgorMinar
Copy link
Contributor

the rest looks good. thanks!

@AdriVanHoudt
Copy link

thank you so much 👏

@matsko
Copy link
Contributor Author

matsko commented Aug 19, 2015

Closed with dc48aad

@matsko matsko closed this Aug 19, 2015
@matsko matsko deleted the raf_revert branch August 19, 2015 17:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

$$rAF performance issue in Angular Material
4 participants