-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,6 +248,28 @@ angular.module('ngAnimate', ['ng']) | |
* Please visit the {@link ngAnimate `ngAnimate`} module overview page learn more about how to use animations in your application. | ||
* | ||
*/ | ||
.factory('$$animateReflow', ['$window', '$timeout', function($window, $timeout) { | ||
var requestAnimationFrame = $window.requestAnimationFrame || | ||
$window.mozRequestAnimationFrame || | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
$window.webkitRequestAnimationFrame || | ||
function(fn) { | ||
return $timeout(fn, 10, false); | ||
}; | ||
This comment has been minimized.
Sorry, something went wrong.
mgol
Member
|
||
|
||
var cancelAnimationFrame = $window.cancelAnimationFrame || | ||
$window.mozCancelAnimationFrame || | ||
This comment has been minimized.
Sorry, something went wrong. |
||
$window.webkitCancelAnimationFrame || | ||
function(timer) { | ||
return $timeout.cancel(timer); | ||
}; | ||
return function(fn) { | ||
var id = requestAnimationFrame(fn); | ||
return function() { | ||
cancelAnimationFrame(id); | ||
}; | ||
}; | ||
}]) | ||
|
||
.config(['$provide', '$animateProvider', function($provide, $animateProvider) { | ||
var noop = angular.noop; | ||
var forEach = angular.forEach; | ||
|
@@ -872,7 +894,8 @@ angular.module('ngAnimate', ['ng']) | |
} | ||
}]); | ||
|
||
$animateProvider.register('', ['$window', '$sniffer', '$timeout', function($window, $sniffer, $timeout) { | ||
$animateProvider.register('', ['$window', '$sniffer', '$timeout', '$$animateReflow', | ||
function($window, $sniffer, $timeout, $$animateReflow) { | ||
// Detect proper transitionend/animationend event names. | ||
var CSS_PREFIX = '', TRANSITION_PROP, TRANSITIONEND_EVENT, ANIMATION_PROP, ANIMATIONEND_EVENT; | ||
|
||
|
@@ -917,11 +940,13 @@ angular.module('ngAnimate', ['ng']) | |
var parentCounter = 0; | ||
var animationReflowQueue = []; | ||
var animationElementQueue = []; | ||
var animationTimer; | ||
var cancelAnimationReflow; | ||
var closingAnimationTime = 0; | ||
var timeOut = false; | ||
function afterReflow(element, callback) { | ||
$timeout.cancel(animationTimer); | ||
if(cancelAnimationReflow) { | ||
cancelAnimationReflow(); | ||
} | ||
|
||
animationReflowQueue.push(callback); | ||
|
||
|
@@ -942,7 +967,7 @@ angular.module('ngAnimate', ['ng']) | |
//a follow-up animation is midway in its animation | ||
elementData.animationCount = animationCounter; | ||
|
||
animationTimer = $timeout(function() { | ||
cancelAnimationReflow = $$animateReflow(function() { | ||
forEach(animationReflowQueue, function(fn) { | ||
fn(); | ||
}); | ||
|
@@ -963,11 +988,11 @@ angular.module('ngAnimate', ['ng']) | |
|
||
animationReflowQueue = []; | ||
animationElementQueue = []; | ||
animationTimer = null; | ||
cancelAnimationReflow = null; | ||
lookupCache = {}; | ||
closingAnimationTime = 0; | ||
animationCounter++; | ||
}, 10, false); | ||
}); | ||
} | ||
|
||
function closeAllAnimations(elements, count) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -756,6 +756,26 @@ angular.mock.TzDate = function (offset, timestamp) { | |
angular.mock.TzDate.prototype = Date.prototype; | ||
/* jshint +W101 */ | ||
|
||
angular.module('ngAnimate').config(['$provide', function($provide) { | ||
This comment has been minimized.
Sorry, something went wrong.
IgorMinar
Contributor
|
||
var reflowQueue = []; | ||
$provide.value('$$animateReflow', function(fn) { | ||
reflowQueue.push(fn); | ||
return angular.noop; | ||
}); | ||
$provide.decorator('$animate', function($delegate) { | ||
$delegate.triggerReflow = function() { | ||
if(reflowQueue.length === 0) { | ||
throw new Error('No animation reflows present'); | ||
} | ||
angular.forEach(reflowQueue, function(fn) { | ||
fn(); | ||
}); | ||
reflowQueue = []; | ||
}; | ||
return $delegate; | ||
}); | ||
}]); | ||
|
||
angular.mock.animate = angular.module('mock.animate', ['ng']) | ||
|
||
.config(['$provide', function($provide) { | ||
|
@@ -1913,7 +1933,6 @@ angular.mock.clearDataCache = function() { | |
}; | ||
|
||
|
||
|
||
if(window.jasmine || window.mocha) { | ||
|
||
var currentSpec = null, | ||
|
This has not been needed since Firefox 23 (current version is 26). I'd drop that.