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

Commit

Permalink
fix($animateCss): make sure that skipBlocking avoids the pre-emptiv…
Browse files Browse the repository at this point in the history
…e transition-delay styling
  • Loading branch information
matsko committed Jul 20, 2015
1 parent cce084e commit 11695ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/ngAnimate/animateCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
// transition delay to allow for the transition to naturally do it's thing. The beauty here is
// that if there is no transition defined then nothing will happen and this will also allow
// other transitions to be stacked on top of each other without any chopping them out.
if (isFirst) {
if (isFirst && !options.skipBlocking) {
blockTransitions(node, SAFE_FAST_FORWARD_DURATION_VALUE);
}

Expand Down Expand Up @@ -683,12 +683,13 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
}

applyAnimationFromStyles(element, options);
if (!flags.blockTransition) {

if (flags.blockTransition || flags.blockKeyframeAnimation) {
applyBlocking(maxDuration);
} else if (!options.skipBlocking) {
blockTransitions(node, false);
}

applyBlocking(maxDuration);

// TODO(matsko): for 1.5 change this code to have an animator object for better debugging
return {
$$willAnimate: true,
Expand Down
11 changes: 10 additions & 1 deletion test/ngAnimate/animateCssSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ describe("ngAnimate $animateCss", function() {
they('should not place a CSS transition block if options.skipBlocking is provided',
['enter', 'leave', 'move', 'addClass', 'removeClass'], function(event) {

inject(function($animateCss, $rootElement, $$body) {
inject(function($animateCss, $rootElement, $$body, $window) {
var element = jqLite('<div></div>');
$rootElement.append(element);
$$body.append($rootElement);
Expand All @@ -1441,14 +1441,23 @@ describe("ngAnimate $animateCss", function() {
data.event = event;
}

var blockSpy = spyOn($window, 'blockTransitions').andCallThrough();

data.skipBlocking = true;
var animator = $animateCss(element, data);

expect(blockSpy).not.toHaveBeenCalled();

expect(element.attr('style')).toBeFalsy();
animator.start();
triggerAnimationStartFrame();

expect(element.attr('style')).toBeFalsy();

// just to prove it works
data.skipBlocking = false;
var animator = $animateCss(element, { addClass: 'test' });
expect(blockSpy).toHaveBeenCalled();
});
});

Expand Down

0 comments on commit 11695ca

Please sign in to comment.