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

Commit 78d6bef

Browse files
committed
terminal nodes added
1 parent 9568d5b commit 78d6bef

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

src/ngAnimate/animation.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,13 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
8888
if (remainingLevelEntries <= 0) {
8989
remainingLevelEntries = nextLevelEntries;
9090
nextLevelEntries = 0;
91-
result.push(row);
91+
result = result.concat(row);
9292
row = [];
9393
}
94-
row.push(entry.fn);
94+
row.push({
95+
fn: entry.fn,
96+
terminal: entry.children.length === 0
97+
});
9598
entry.children.forEach(function(childEntry) {
9699
nextLevelEntries++;
97100
queue.push(childEntry);
@@ -100,7 +103,7 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
100103
}
101104

102105
if (row.length) {
103-
result.push(row);
106+
result = result.concat(row);
104107
}
105108

106109
return result;
@@ -217,14 +220,12 @@ var $$AnimationProvider = ['$animateProvider', function($animateProvider) {
217220
var anim = sortAnimations(toBeSortedAnimations);
218221
var finalLevel = anim.length - 1;
219222

220-
for (var i = 0; i < anim.length; i++) {
221-
forEach(anim[i], function(startAnimationFn) {
222-
if (i < finalLevel) {
223-
$$forceReflow();
224-
}
225-
startAnimationFn();
226-
});
227-
}
223+
forEach(anim, function(entry) {
224+
if (!entry.terminal) {
225+
$$forceReflow();
226+
}
227+
entry.fn();
228+
});
228229
});
229230

230231
return runner;

test/ngAnimate/integrationSpec.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe('ngAnimate integration tests', function() {
277277
});
278278
});
279279

280-
it('should issue a reflow for each parent class-based animation if one or more of them contain children with queued animations', function() {
280+
it('should issue a reflow for each parent class-based animation that contains active child animations', function() {
281281
module('ngAnimateMock');
282282
inject(function($animate, $compile, $rootScope, $rootElement, $$rAF, $document) {
283283
element = jqLite(
@@ -287,7 +287,10 @@ describe('ngAnimate integration tests', function() {
287287
'<div ng-class="{two:exp}">' +
288288
'<div ng-if="exp"></div>' +
289289
'</div>' +
290-
'<div ng-class="{three:exp}"></div>'
290+
'<div ng-class="{three:exp}">' +
291+
'<div ng-if="false"></div>' +
292+
'</div>' +
293+
'<div ng-class="{four:exp}"></div>'
291294
);
292295

293296
$rootElement.append(element);
@@ -299,7 +302,7 @@ describe('ngAnimate integration tests', function() {
299302

300303
$rootScope.exp = true;
301304
$rootScope.$digest();
302-
expect($animate.reflows).toBe(3);
305+
expect($animate.reflows).toBe(2);
303306
});
304307
});
305308

0 commit comments

Comments
 (0)