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

Commit 6c51974

Browse files
committed
fix for igor
1 parent 08ac2d1 commit 6c51974

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/ngAnimate/animate.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -411,20 +411,21 @@ angular.module('ngAnimate', ['ng'])
411411

412412
$rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
413413

414-
// disable animations during bootstrap, but once we bootstrapped, wait again
415-
// for another 2 digests until enabling animations. Enter, leave and move require
416-
// a follow-up digest so having a watcher here is enough to let both digests pass.
417-
// However, when any directive or view templates are downloaded then we need to
418-
// handle postpone enabling animations until they are fully completed and then...
419-
var watchFn = $rootScope.$watch(
414+
// Wait until all directive and route-related templates are downloaded and
415+
// compile. The $templateRequest.totalPendingRequests variable keeps track of
416+
// all of the remote templates being currently downloaded. If there are no
417+
// templates currently downloading the watcher will still fire anyway.
418+
var deregisterWatch = $rootScope.$watch(
420419
function() { return $templateRequest.totalPendingRequests; },
421420
function(val, oldVal) {
422421
if (val !== 0) return;
423-
watchFn();
422+
deregisterWatch();
424423

425-
// ...when the template has been downloaded we digest twice again until the
426-
// animations are set to enabled (since enter, leave and move require a
427-
// follow-up). The same approach applies when there are no templates to download.
424+
// Now that all templates have been downloaded, $animate will wait until
425+
// the post digest queue is empty before enabling animations. By having two
426+
// calls to $postDigest calls we can ensure that the flag is enabled at the
427+
// very end of the post digest queue. This basically means that the page is
428+
// fully downloaded and compiled before any animations are triggered.
428429
$rootScope.$$postDigest(function() {
429430
$rootScope.$$postDigest(function() {
430431
rootAnimateState.running = false;

0 commit comments

Comments
 (0)