fix($animate): $animate.enabled(false) should disable animations on $animateCss as well

Closes #12696
Closes #12685
This commit is contained in:
Matias Niemelä
2015-08-27 14:17:55 -07:00
parent 2f6b6fb7a1
commit c3d5e33e18
2 changed files with 26 additions and 8 deletions
+7 -7
View File
@@ -328,8 +328,8 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
var gcsLookup = createLocalCacheLookup();
var gcsStaggerLookup = createLocalCacheLookup();
this.$get = ['$window', '$$jqLite', '$$AnimateRunner', '$timeout', '$$forceReflow', '$sniffer', '$$rAF',
function($window, $$jqLite, $$AnimateRunner, $timeout, $$forceReflow, $sniffer, $$rAF) {
this.$get = ['$window', '$$jqLite', '$$AnimateRunner', '$timeout', '$$forceReflow', '$sniffer', '$$rAF', '$animate',
function($window, $$jqLite, $$AnimateRunner, $timeout, $$forceReflow, $sniffer, $$rAF, $animate) {
var applyAnimationClasses = applyAnimationClassesFactory($$jqLite);
@@ -411,8 +411,6 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
});
}
return init;
function computeTimings(node, className, cacheKey) {
var timings = computeCachedCssStyles(node, className, cacheKey, DETECT_CSS_PROPERTIES);
var aD = timings.animationDelay;
@@ -427,9 +425,11 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
return timings;
}
function init(element, options) {
return function init(element, options) {
var node = getDomNode(element);
if (!node || !node.parentNode) {
if (!node
|| !node.parentNode
|| !$animate.enabled()) {
return closeAndReturnNoopAnimator();
}
@@ -930,6 +930,6 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
}
}
}
}
};
}];
}];
+19 -1
View File
@@ -18,9 +18,10 @@ describe("ngAnimate $animateCss", function() {
var ss, prefix, triggerAnimationStartFrame;
beforeEach(module(function() {
return function($document, $window, $sniffer, $$rAF) {
return function($document, $window, $sniffer, $$rAF, $animate) {
prefix = '-' + $sniffer.vendorPrefix.toLowerCase() + '-';
ss = createMockStyleSheet($document, $window);
$animate.enabled(true);
triggerAnimationStartFrame = function() {
$$rAF.flush();
};
@@ -52,6 +53,23 @@ describe("ngAnimate $animateCss", function() {
describe('when active', function() {
if (!browserSupportsCssAnimations()) return;
it("should not attempt an animation if animations are globally disabled",
inject(function($animateCss, $animate, $rootElement, $$body) {
$animate.enabled(false);
var animator, element = jqLite('<div></div>');
$rootElement.append(element);
$$body.append($rootElement);
animator = $animateCss(element, {
duration: 10,
to: { 'height': '100px' }
});
expect(animator.$$willAnimate).toBeFalsy();
}));
it("should silently quit the animation and not throw when an element has no parent during preparation",
inject(function($animateCss, $rootScope, $document, $rootElement) {