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

feat($animator): support CSS3 transition-delay property detection #2488

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/ng/animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,11 @@ var $AnimatorProvider = function() {
var vendorTransitionProp = $sniffer.vendorPrefix + 'Transition';
var w3cTransitionProp = 'transition'; //one day all browsers will have this

var durationKey = 'Duration';
var duration = 0;
var durationKey = 'Duration',
delayKey = 'Delay',
duration = 0,
delay = 0;

//we want all the styles defined before and after
forEach(element, function(element) {
var globalStyles = $window.getComputedStyle(element) || {};
Expand All @@ -286,8 +289,14 @@ var $AnimatorProvider = function() {
parseFloat(globalStyles[vendorTransitionProp + durationKey]) ||
0,
duration);

delay = Math.max(
parseFloat(globalStyles[w3cTransitionProp + delayKey]) ||
parseFloat(globalStyles[vendorTransitionProp + delayKey]) ||
0,
delay);
});
$window.setTimeout(done, duration * 1000);
$window.setTimeout(done, (duration + delay) * 1000);
} else {
done();
}
Expand Down
21 changes: 20 additions & 1 deletion test/ng/animatorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ describe("$animator", function() {
module(function($animationProvider, $provide) {
$provide.value('$window', window = angular.mock.createMockWindow());
return function($sniffer, _$rootElement_, $animator) {
vendorPrefix = '-' + $sniffer.vendorPrefix + '-';
vendorPrefix = '-' + $sniffer.vendorPrefix.toLowerCase() + '-';
$rootElement = _$rootElement_;
$animator.enabled(true);
};
Expand Down Expand Up @@ -333,6 +333,25 @@ describe("$animator", function() {
}
expect(element[0].style.display).toBe('');
}));

it("should consider a CSS3 delay if set within the setup class",
inject(function($animator, $rootScope, $compile, $sniffer) {

var style = vendorPrefix + 'transition: 1s linear all;' +
vendorPrefix + 'transition-delay: 8s;';

element = $compile(html('<div style="' + style + '">1</div>'))($rootScope);
var animator = $animator($rootScope, {
ngAnimate : '{show: \'custom-show\'}'
});

animator.show(element);
if ($sniffer.supportsTransitions) {
window.setTimeout.expect(1).process();
window.setTimeout.expect(9000).process();
}
}));

});

it("should throw an error when an invalid ng-animate syntax is provided", inject(function($compile, $rootScope) {
Expand Down