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

Commit

Permalink
fix($animate): ensure transition-property is not changed when only ke…
Browse files Browse the repository at this point in the history
…yframe animations are in use

Closes #3933
  • Loading branch information
matsko authored and btford committed Sep 30, 2013
1 parent 448bd14 commit 2df3c9f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,10 @@ angular.module('ngAnimate', ['ng'])

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

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

//this triggers a reflow which allows for the transition animation to kick in
element.prop('clientWidth');
node.style[w3cTransitionProp + propertyKey] = '';
node.style[vendorTransitionProp + propertyKey] = '';
if(transitionTime > 0) {
node.style[w3cTransitionProp + propertyKey] = '';
node.style[vendorTransitionProp + propertyKey] = '';
}
element.addClass(activeClassName);

var css3AnimationEvents = [w3cAnimationEvent, vendorAnimationEvent,
Expand Down
30 changes: 30 additions & 0 deletions test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,36 @@ describe("ngAnimate", function() {
expect(child.hasClass('ng-enter-active')).toBe(false);
}));

it("should not set the transition property flag if only CSS animations are used",
inject(function($compile, $rootScope, $animate, $sniffer) {

if (!$sniffer.animations) return;

ss.addRule('.ani.ng-enter', 'my_animation 2s linear;' +
vendorPrefix + 'animation: my_animation 2s linear');

ss.addRule('.trans.ng-enter', 'transition:1s linear all;' +
vendorPrefix + 'transition:1s linear all');

var element = html($compile('<div>...</div>')($rootScope));
var child = $compile('<div class="ani">...</div>')($rootScope);
child.css('transition-property','background-color');

$animate.enter(child, element);
$rootScope.$digest();

browserTrigger(child,'transitionend', { timeStamp: Date.now() + 2000 });

expect(child.css('transition-property')).toBe('background-color');
child.remove();

child.attr('class','trans');
$animate.enter(child, element);
$rootScope.$digest();

expect(child.css('transition-property')).not.toBe('background-color');
}));

it("should skip animations if the browser does not support CSS3 transitions and CSS3 animations",
inject(function($compile, $rootScope, $animate, $sniffer) {

Expand Down

0 comments on commit 2df3c9f

Please sign in to comment.