mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-16 02:33:09 +00:00
fix($animator): remove dependency on window.setTimeout.
This commit is contained in:
parent
de296f1b52
commit
021bdf3922
3 changed files with 20 additions and 26 deletions
|
|
@ -975,12 +975,13 @@ function bootstrap(element, modules) {
|
||||||
}]);
|
}]);
|
||||||
modules.unshift('ng');
|
modules.unshift('ng');
|
||||||
var injector = createInjector(modules);
|
var injector = createInjector(modules);
|
||||||
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector',
|
injector.invoke(['$rootScope', '$rootElement', '$compile', '$injector', '$animator',
|
||||||
function(scope, element, compile, injector) {
|
function(scope, element, compile, injector, animator) {
|
||||||
scope.$apply(function() {
|
scope.$apply(function() {
|
||||||
element.data('$injector', injector);
|
element.data('$injector', injector);
|
||||||
compile(element)(scope);
|
compile(element)(scope);
|
||||||
});
|
});
|
||||||
|
animator.enabled(true);
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
return injector;
|
return injector;
|
||||||
|
|
|
||||||
|
|
@ -130,14 +130,6 @@ var $AnimatorProvider = function() {
|
||||||
this.$get = ['$animation', '$window', '$sniffer', '$rootElement', '$rootScope',
|
this.$get = ['$animation', '$window', '$sniffer', '$rootElement', '$rootScope',
|
||||||
function($animation, $window, $sniffer, $rootElement, $rootScope) {
|
function($animation, $window, $sniffer, $rootElement, $rootScope) {
|
||||||
$rootElement.data(NG_ANIMATE_CONTROLLER, rootAnimateController);
|
$rootElement.data(NG_ANIMATE_CONTROLLER, rootAnimateController);
|
||||||
var unregister = $rootScope.$watch(function() {
|
|
||||||
unregister();
|
|
||||||
if (rootAnimateController.running) {
|
|
||||||
$window.setTimeout(function() {
|
|
||||||
rootAnimateController.running = false;
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ngdoc function
|
* @ngdoc function
|
||||||
|
|
|
||||||
|
|
@ -28,20 +28,27 @@ describe("$animator", function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should disable and enable the animations", inject(function($animator, $rootScope, $window) {
|
it("should disable and enable the animations", function() {
|
||||||
expect($animator.enabled()).toBe(false);
|
var initialState = null;
|
||||||
|
var animator;
|
||||||
|
|
||||||
$rootScope.$digest();
|
angular.bootstrap(body, [function() {
|
||||||
$window.setTimeout.expect(0).process();
|
return function($animator) {
|
||||||
|
animator = $animator;
|
||||||
|
initialState = $animator.enabled();
|
||||||
|
}
|
||||||
|
}]);
|
||||||
|
|
||||||
expect($animator.enabled()).toBe(true);
|
expect(initialState).toBe(false);
|
||||||
|
|
||||||
expect($animator.enabled(0)).toBe(false);
|
expect(animator.enabled()).toBe(true);
|
||||||
expect($animator.enabled()).toBe(false);
|
|
||||||
|
|
||||||
expect($animator.enabled(1)).toBe(true);
|
expect(animator.enabled(0)).toBe(false);
|
||||||
expect($animator.enabled()).toBe(true);
|
expect(animator.enabled()).toBe(false);
|
||||||
}));
|
|
||||||
|
expect(animator.enabled(1)).toBe(true);
|
||||||
|
expect(animator.enabled()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -145,9 +152,6 @@ describe("$animator", function() {
|
||||||
ngAnimate : '{enter: \'custom\'}'
|
ngAnimate : '{enter: \'custom\'}'
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$digest(); // re-enable the animations;
|
|
||||||
window.setTimeout.expect(0).process();
|
|
||||||
|
|
||||||
expect(element.contents().length).toBe(0);
|
expect(element.contents().length).toBe(0);
|
||||||
animator.enter(child, element);
|
animator.enter(child, element);
|
||||||
window.setTimeout.expect(1).process();
|
window.setTimeout.expect(1).process();
|
||||||
|
|
@ -158,9 +162,6 @@ describe("$animator", function() {
|
||||||
ngAnimate : '{leave: \'custom\'}'
|
ngAnimate : '{leave: \'custom\'}'
|
||||||
});
|
});
|
||||||
|
|
||||||
$rootScope.$digest(); // re-enable the animations;
|
|
||||||
window.setTimeout.expect(0).process();
|
|
||||||
|
|
||||||
element.append(child);
|
element.append(child);
|
||||||
expect(element.contents().length).toBe(1);
|
expect(element.contents().length).toBe(1);
|
||||||
animator.leave(child, element);
|
animator.leave(child, element);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue