Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix($animate): $animate.enabled(false) should disable animations on…
… $animateCss as well

Closes #12696
Closes #12685
matsko committed Aug 27, 2015
commit 2aa14f646fda7aeb16c00f25bce8541e96a95080
14 changes: 7 additions & 7 deletions src/ngAnimate/animateCss.js
Original file line number Diff line number Diff line change
@@ -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) {
}
}
}
}
};
}];
}];
20 changes: 19 additions & 1 deletion test/ngAnimate/animateCssSpec.js
Original file line number Diff line number Diff line change
@@ -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) {