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

Commit 21d6db3

Browse files
sreeramumatsko
authored andcommitted
fix($animate): ensure that class-based animations are properly applied when cancelled
Instead of merging existing animation option to new animation options we can merge in reverse and utilize old animation runner. Closes #12266 Closes #12007
1 parent fc7d2d2 commit 21d6db3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/ngAnimate/animateQueue.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,9 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
330330
// method which will call the runner methods in async.
331331
existingAnimation.close();
332332
} else {
333-
// this will merge the existing animation options into this new follow-up animation
334-
mergeAnimationOptions(element, newAnimation.options, existingAnimation.options);
333+
// this will merge the new animation options into existing animation options
334+
mergeAnimationOptions(element, existingAnimation.options, newAnimation.options);
335+
return existingAnimation.runner;
335336
}
336337
} else {
337338
// a joined animation means that this animation will take over the existing one

test/ngAnimate/animateSpec.js

+18
Original file line numberDiff line numberDiff line change
@@ -1206,6 +1206,24 @@ describe("animations", function() {
12061206
expect(r1).toBe(r2);
12071207
expect(r2).toBe(r3);
12081208
}));
1209+
1210+
it('should not skip or miss the animations when animations are executed sequential',
1211+
inject(function($animate, $rootScope, $$rAF, $rootElement) {
1212+
1213+
element = jqLite('<div></div>');
1214+
1215+
$rootElement.append(element);
1216+
1217+
$animate.addClass(element, 'rclass');
1218+
$animate.removeClass(element, 'rclass');
1219+
$animate.addClass(element, 'rclass');
1220+
$animate.removeClass(element, 'rclass');
1221+
1222+
$rootScope.$digest();
1223+
$$rAF.flush();
1224+
1225+
expect(element).not.toHaveClass('rclass');
1226+
}));
12091227
});
12101228
});
12111229

0 commit comments

Comments
 (0)