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

Commit eed2333

Browse files
committed
fix(ngAnimate): ensure animations are disabled upon bootstrap for structrual animations
Closes #5130
1 parent a2809da commit eed2333

File tree

3 files changed

+2230
-2180
lines changed

3 files changed

+2230
-2180
lines changed

src/ngAnimate/animate.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,16 @@ angular.module('ngAnimate', ['ng'])
263263

264264
$rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
265265

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

271278
function lookup(name) {

test/ng/directive/ngClassSpec.js

+4
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ describe('ngClass animations', function() {
373373
// Enable animations by triggering the first item in the postDigest queue
374374
digestQueue.shift()();
375375

376+
// wait for the 2nd animation bootstrap digest to pass
377+
$rootScope.$digest();
378+
digestQueue.shift()();
379+
376380
$rootScope.val = 'crazy';
377381
var element = angular.element('<div ng-class="val"></div>');
378382
jqLite($document[0].body).append($rootElement);

0 commit comments

Comments
 (0)