diff options
| author | Matias Niemelä | 2014-02-24 19:43:57 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-02-24 21:23:18 -0500 |
| commit | 4c4537e65e6cf911c9659b562d89e3330ce3ffae (patch) | |
| tree | 3f9e6736a314073b5516beab3c86d7709e887b6b /src/ngMock | |
| parent | 62761428eff3a53e69367449eb81869e59e75e39 (diff) | |
| download | angular.js-4c4537e65e6cf911c9659b562d89e3330ce3ffae.tar.bz2 | |
perf($animate): use rAF instead of timeouts to issue animation callbacks
Diffstat (limited to 'src/ngMock')
| -rw-r--r-- | src/ngMock/angular-mocks.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index bcd6cc1f..c9f31431 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -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(); }); |
