Skip to content

Commit 32d5de4

Browse files
committed
fix($animate): retain inline styles for property-specific transition animations
Closes angular#7503
1 parent e9fad96 commit 32d5de4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/ngAnimate/animate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ angular.module('ngAnimate', ['ng'])
14331433
//the jqLite object, so we're safe to use a single variable to house
14341434
//the styles since there is always only one element being animated
14351435
var oldStyle = node.getAttribute('style') || '';
1436-
node.setAttribute('style', oldStyle + ' ' + style);
1436+
node.setAttribute('style', oldStyle + '; ' + style);
14371437
}
14381438

14391439
var startTime = Date.now();

test/ngAnimate/animateSpec.js

+20
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,26 @@ describe("ngAnimate", function() {
11671167
expect(element.css('width')).toBe("200px");
11681168
}));
11691169

1170+
it("should NOT overwrite styles when a transition with a specific property is used",
1171+
inject(function($animate, $rootScope, $compile, $sniffer, $timeout) {
1172+
1173+
if(!$sniffer.transitions) return;
1174+
1175+
var style = '-webkit-transition: border linear .2s;' +
1176+
'transition: border linear .2s;';
1177+
1178+
ss.addRule('.on', style);
1179+
element = $compile(html('<div style="height:200px"></div>'))($rootScope);
1180+
$animate.addClass(element, 'on');
1181+
1182+
$animate.triggerReflow();
1183+
1184+
var now = Date.now();
1185+
browserTrigger(element,'transitionend', { timeStamp: now + 1000, elapsedTime: 1 });
1186+
browserTrigger(element,'transitionend', { timeStamp: now + 2000, elapsedTime: 2 });
1187+
expect(element.css('height')).toBe("200px");
1188+
}));
1189+
11701190

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

0 commit comments

Comments
 (0)