diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index a5a1c13bee4d..8357df8cb584 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -1199,7 +1199,7 @@ angular.module('ngAnimate', ['ng']) //but it may not need to cancel out the existing timeout //if the timestamp is less than the previous one - var futureTimestamp = Date.now() + (totalTime * 1000); + var futureTimestamp = Date.now() + totalTime; if(futureTimestamp <= closingTimestamp) { return; } diff --git a/test/ngAnimate/animateSpec.js b/test/ngAnimate/animateSpec.js index b7bc212da34d..1f5e88f3ac68 100644 --- a/test/ngAnimate/animateSpec.js +++ b/test/ngAnimate/animateSpec.js @@ -1390,13 +1390,20 @@ describe("ngAnimate", function() { })); it("should intelligently cancel former timeouts and close off a series of elements a final timeout", function() { + var currentTimestamp = Date.now(); + spyOn(Date,'now').andCallFake(function() { + return currentTimestamp; + }); + var cancellations = 0; module(function($provide) { $provide.decorator('$timeout', function($delegate) { var _cancel = $delegate.cancel; - $delegate.cancel = function() { - cancellations++; - return _cancel.apply($delegate, arguments); + $delegate.cancel = function(timer) { + if(timer) { + cancellations++; + return _cancel.apply($delegate, arguments); + } }; return $delegate; }); @@ -1404,10 +1411,22 @@ describe("ngAnimate", function() { inject(function($animate, $rootScope, $compile, $sniffer, $timeout) { if (!$sniffer.transitions) return; - ss.addRule('.animate-me', '-webkit-transition:1s linear all;' + + ss.addRule('.animate-me div', '-webkit-transition:1s linear all;' + 'transition:1s linear all;'); - element = $compile(html('