Skip to content

Commit

Permalink
fix(ngAnimate): ensure animations are disabled upon bootstrap for str…
Browse files Browse the repository at this point in the history
…uctrual animations

Closes angular#5130
  • Loading branch information
matsko authored and jamesdaily committed Jan 27, 2014
1 parent a163135 commit 321a3cf
Show file tree
Hide file tree
Showing 3 changed files with 2,230 additions and 2,180 deletions.
11 changes: 9 additions & 2 deletions src/ngAnimate/animate.js
Expand Up @@ -263,9 +263,16 @@ angular.module('ngAnimate', ['ng'])

$rootElement.data(NG_ANIMATE_STATE, rootAnimateState);

// disable animations during bootstrap, but once we bootstrapped, enable animations
// disable animations during bootstrap, but once we bootstrapped, wait again
// for another digest until enabling animations. The reason why we digest twice
// is because all structural animations (enter, leave and move) all perform a
// post digest operation before animating. If we only wait for a single digest
// to pass then the structural animation would render its animation on page load.
// (which is what we're trying to avoid when the application first boots up.)
$rootScope.$$postDigest(function() {
rootAnimateState.running = false;
$rootScope.$$postDigest(function() {
rootAnimateState.running = false;
});
});

function lookup(name) {
Expand Down
4 changes: 4 additions & 0 deletions test/ng/directive/ngClassSpec.js
Expand Up @@ -373,6 +373,10 @@ describe('ngClass animations', function() {
// Enable animations by triggering the first item in the postDigest queue
digestQueue.shift()();

// wait for the 2nd animation bootstrap digest to pass
$rootScope.$digest();
digestQueue.shift()();

$rootScope.val = 'crazy';
var element = angular.element('<div ng-class="val"></div>');
jqLite($document[0].body).append($rootElement);
Expand Down

0 comments on commit 321a3cf

Please sign in to comment.