perf($animate): use rAF instead of timeouts to issue animation callbacks

This commit is contained in:
Matias Niemelä
2014-02-24 19:43:57 -05:00
parent 62761428ef
commit 4c4537e65e
7 changed files with 143 additions and 126 deletions

View File

@@ -757,21 +757,24 @@ angular.mock.TzDate.prototype = Date.prototype;
angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
.config(['$provide', function($provide) {
var reflowQueue = [];
var reflowQueue = [];
$provide.value('$$animateReflow', function(fn) {
var index = reflowQueue.length;
reflowQueue.push(fn);
return angular.noop;
return function cancel() {
reflowQueue.splice(index, 1);
};
});
$provide.decorator('$animate', function($delegate) {
$provide.decorator('$animate', function($delegate, $$asyncCallback) {
var animate = {
queue : [],
enabled : $delegate.enabled,
triggerCallbacks : function() {
$$asyncCallback.flush();
},
triggerReflow : function() {
if(reflowQueue.length === 0) {
throw new Error('No animation reflows present');
}
angular.forEach(reflowQueue, function(fn) {
fn();
});