diff options
| author | Matias Niemelä | 2014-01-12 15:49:52 -0500 |
|---|---|---|
| committer | Matias Niemelä | 2014-01-14 13:21:19 -0500 |
| commit | 4ae3184c5915aac9aa00889aa2153c8e84c14966 (patch) | |
| tree | 3eab74b2750934456f8fb29beae748bbe688eac1 /src/ngMock | |
| parent | ed53100a0dbc9119d5dfc8b7248845d4f6989df2 (diff) | |
| download | angular.js-4ae3184c5915aac9aa00889aa2153c8e84c14966.tar.bz2 | |
feat($animate): use requestAnimationFrame instead of a timeout to issue a reflow
Closes #4278
Closes #4225
Diffstat (limited to 'src/ngMock')
| -rw-r--r-- | src/ngMock/angular-mocks.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index b53b4e02..803cedbd 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -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) { + 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, |
