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

Commit e0e1b52

Browse files
matskopetebacondarwin
authored andcommitted
fix($animateCss): ensure that custom durations do not confuse the gcs cache
Closes #11723 Closes #11852
1 parent 462f444 commit e0e1b52

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/ngAnimate/animateCss.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
660660
// we need to recalculate the delay value since we used a pre-emptive negative
661661
// delay value and the delay value is required for the final event checking. This
662662
// property will ensure that this will happen after the RAF phase has passed.
663-
if (timings.transitionDuration > 0) {
663+
if (options.duration == null && timings.transitionDuration > 0) {
664664
flags.recalculateTimingStyles = flags.recalculateTimingStyles || isFirst;
665665
}
666666

test/ngAnimate/animateCssSpec.js

+37
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,43 @@ describe("ngAnimate $animateCss", function() {
12031203
});
12041204
});
12051205

1206+
it('should avoid applying the same cache to an element a follow-up animation is run on the same element',
1207+
inject(function($animateCss, $rootElement, $document) {
1208+
1209+
function endTransition(element, elapsedTime) {
1210+
browserTrigger(element, 'transitionend',
1211+
{ timeStamp: Date.now(), elapsedTime: elapsedTime });
1212+
}
1213+
1214+
function startAnimation(element, duration, color) {
1215+
$animateCss(element, {
1216+
duration: duration,
1217+
to: { background: color }
1218+
}).start();
1219+
triggerAnimationStartFrame();
1220+
}
1221+
1222+
var element = jqLite('<div></div>');
1223+
$rootElement.append(element);
1224+
jqLite($document[0].body).append($rootElement);
1225+
1226+
startAnimation(element, 0.5, 'red');
1227+
expect(element.attr('style')).toContain('transition');
1228+
1229+
endTransition(element, 0.5);
1230+
expect(element.attr('style')).not.toContain('transition');
1231+
1232+
startAnimation(element, 0.8, 'blue');
1233+
expect(element.attr('style')).toContain('transition');
1234+
1235+
// Trigger an extra transitionend event that matches the original transition
1236+
endTransition(element, 0.5);
1237+
expect(element.attr('style')).toContain('transition');
1238+
1239+
endTransition(element, 0.8);
1240+
expect(element.attr('style')).not.toContain('transition');
1241+
}));
1242+
12061243
it('should apply a custom temporary class when a non-structural animation is used',
12071244
inject(function($animateCss, $rootElement, $document) {
12081245

0 commit comments

Comments
 (0)