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

Commit 98b9d68

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 cee429f commit 98b9d68

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
@@ -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

+19
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,25 @@ 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 + 200, elapsedTime: 0.2 });
1186+
expect(element.css('height')).toBe("200px");
1187+
}));
1188+
11701189

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

0 commit comments

Comments
 (0)