fix($animate): $animate.enabled(false) should disable animations on $animateCss as well
Closes #12696 Closes #12685
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}];
|
||||
}];
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user