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

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 #5130
  • Loading branch information
matsko committed Nov 25, 2013
1 parent a2809da commit eed2333
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

1 comment on commit eed2333

@arthurmchr
Copy link

Choose a reason for hiding this comment

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

Is there a way to undo this and enable enter animations upon bootstrap ? I tried using $timeout without success.

Please sign in to comment.