Skip to content

Commit a23e509

Browse files
committed
fix($animate): ensure transition-property is not changed when only keyframe animations are in use
Closes angular#3933
1 parent 0a63adc commit a23e509

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

src/ngAnimate/animate.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,10 @@ angular.module('ngAnimate', ['ng'])
627627

628628
//temporarily disable the transition so that the enter styles
629629
//don't animate twice (this is here to avoid a bug in Chrome/FF).
630-
node.style[w3cTransitionProp + propertyKey] = 'none';
631-
node.style[vendorTransitionProp + propertyKey] = 'none';
630+
if(transitionTime > 0) {
631+
node.style[w3cTransitionProp + propertyKey] = 'none';
632+
node.style[vendorTransitionProp + propertyKey] = 'none';
633+
}
632634

633635
var activeClassName = '';
634636
forEach(className.split(' '), function(klass, i) {
@@ -637,8 +639,10 @@ angular.module('ngAnimate', ['ng'])
637639

638640
//this triggers a reflow which allows for the transition animation to kick in
639641
element.prop('clientWidth');
640-
node.style[w3cTransitionProp + propertyKey] = '';
641-
node.style[vendorTransitionProp + propertyKey] = '';
642+
if(transitionTime > 0) {
643+
node.style[w3cTransitionProp + propertyKey] = '';
644+
node.style[vendorTransitionProp + propertyKey] = '';
645+
}
642646
element.addClass(activeClassName);
643647

644648
var css3AnimationEvents = [w3cAnimationEvent, vendorAnimationEvent,

test/ngAnimate/animateSpec.js

+30
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,36 @@ describe("ngAnimate", function() {
12701270
expect(child.hasClass('ng-enter-active')).toBe(false);
12711271
}));
12721272

1273+
it("should not set the transition property flag if only CSS animations are used",
1274+
inject(function($compile, $rootScope, $animate, $sniffer) {
1275+
1276+
if (!$sniffer.animations) return;
1277+
1278+
ss.addRule('.ani.ng-enter', 'my_animation 2s linear;' +
1279+
vendorPrefix + 'animation: my_animation 2s linear');
1280+
1281+
ss.addRule('.trans.ng-enter', 'transition:1s linear all;' +
1282+
vendorPrefix + 'transition:1s linear all');
1283+
1284+
var element = html($compile('<div>...</div>')($rootScope));
1285+
var child = $compile('<div class="ani">...</div>')($rootScope);
1286+
child.css('transition-property','background-color');
1287+
1288+
$animate.enter(child, element);
1289+
$rootScope.$digest();
1290+
1291+
browserTrigger(child,'transitionend', { timeStamp: Date.now() + 2000 });
1292+
1293+
expect(child.css('transition-property')).toBe('background-color');
1294+
child.remove();
1295+
1296+
child.attr('class','trans');
1297+
$animate.enter(child, element);
1298+
$rootScope.$digest();
1299+
1300+
expect(child.css('transition-property')).not.toBe('background-color');
1301+
}));
1302+
12731303
it("should skip animations if the browser does not support CSS3 transitions and CSS3 animations",
12741304
inject(function($compile, $rootScope, $animate, $sniffer) {
12751305

0 commit comments

Comments
 (0)