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

Commit ad08638

Browse files
matskobtford
authored andcommitted
fix($animate): retain inline styles for property-specific transitions
Transitions that are run through ngAnimate which contain a specific property cause any inline styles to be erased after the animation is done. This has something to do with how the browsers handle transitions that do not use "all" as a transition property. Closes #7503
1 parent 093e76f commit ad08638

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/ngAnimate/animate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ angular.module('ngAnimate', ['ng'])
13681368
//the jqLite object, so we're safe to use a single variable to house
13691369
//the styles since there is always only one element being animated
13701370
var oldStyle = node.getAttribute('style') || '';
1371-
node.setAttribute('style', oldStyle + ' ' + style);
1371+
node.setAttribute('style', oldStyle + '; ' + style);
13721372
}
13731373

13741374
element.on(css3AnimationEvents, onAnimationProgress);

test/ngAnimate/animateSpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,25 @@ describe("ngAnimate", function() {
11531153
expect(element.css('width')).toBe("200px");
11541154
}));
11551155

1156+
it("should NOT overwrite styles when a transition with a specific property is used",
1157+
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
1158+
1159+
if(!$sniffer.transitions) return;
1160+
1161+
var style = '-webkit-transition: border linear .2s;' +
1162+
'transition: border linear .2s;';
1163+
1164+
ss.addRule('.on', style);
1165+
element = $compile(html('<div style="height:200px"></div>'))($rootScope);
1166+
$animate.addClass(element, 'on');
1167+
1168+
$animate.triggerReflow();
1169+
1170+
var now = Date.now();
1171+
browserTrigger(element,'transitionend', { timeStamp: now + 200, elapsedTime: 0.2 });
1172+
expect(element.css('height')).toBe("200px");
1173+
}));
1174+
11561175

11571176
it("should animate for the highest duration",
11581177
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {

0 commit comments

Comments
 (0)