mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
perf($animate): use rAF instead of timeouts to issue animation callbacks
This commit is contained in:
15
src/ngMock/angular-mocks.js
vendored
15
src/ngMock/angular-mocks.js
vendored
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user