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

Commit f7e3533

Browse files
committed
wip: apply duration: 0 at all times
1 parent 505c11a commit f7e3533

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/ngAnimate/animateCss.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
478478
var startTime;
479479
var events = [];
480480

481-
if (options.duration === 0 || (!$sniffer.animations && !$sniffer.transitions)) {
481+
if (!$sniffer.animations && !$sniffer.transitions) {
482482
return closeAndReturnNoopAnimator();
483483
}
484484

@@ -572,7 +572,8 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
572572

573573
var timings = computeTimings(node, fullClassName, cacheKey);
574574

575-
if (options.duration > 0) {
575+
if (options.duration >= 0) {
576+
dump('overwrite')
576577
// Duration in options overwrites duration set in style
577578
timings.transitionDuration = options.duration;
578579
}
@@ -595,14 +596,15 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
595596
var flags = {};
596597
flags.hasTransitions = timings.transitionDuration > 0;
597598
flags.hasAnimations = timings.animationDuration > 0;
598-
flags.applyTransitionDuration = options.duration > 0 || hasToStyles && flags.hasTransitions;
599+
flags.applyTransitionDuration = options.duration >= 0 || (hasToStyles && flags.hasTransitions);
599600
flags.applyAnimationDuration = options.duration && flags.hasAnimations;
600601
flags.applyTransitionDelay = truthyTimingValue(options.delay) && (flags.applyTransitionDuration || flags.hasTransitions);
601602
flags.applyAnimationDelay = truthyTimingValue(options.delay) && flags.hasAnimations;
602603
flags.recalculateTimingStyles = addRemoveClassName.length > 0;
603604

604605
if (flags.applyTransitionDuration || flags.applyAnimationDuration) {
605-
maxDuration = options.duration ? parseFloat(options.duration) : maxDuration;
606+
maxDuration = isDefined(options.duration) ? parseFloat(options.duration) : maxDuration;
607+
dump('apply', timings.transitionDuration, maxDuration)
606608

607609
if (flags.applyTransitionDuration) {
608610
flags.hasTransitions = true;
@@ -873,6 +875,8 @@ var $AnimateCssProvider = ['$animateProvider', function($animateProvider) {
873875
applyAnimationClasses(element, options);
874876
$$jqLite.addClass(element, activeClasses);
875877

878+
dump('T', timings, flags.recalculateTimingStyles)
879+
876880
if (flags.recalculateTimingStyles) {
877881
fullClassName = node.className + ' ' + preparationClasses;
878882
cacheKey = gcsHashFn(node, fullClassName);

test/ngAnimate/animateCssSpec.js

+23
Original file line numberDiff line numberDiff line change
@@ -2221,6 +2221,29 @@ describe("ngAnimate $animateCss", function() {
22212221
expect(animator.$$willAnimate).toBeFalsy();
22222222
}));
22232223

2224+
iit("should not prepare the animation at all if options.duration is 0 and transition styles are already on the element",
2225+
inject(function($animateCss, $rootElement, $window) {
2226+
2227+
ss.addRule('.animation', '-webkit-transition:1s linear all;' +
2228+
'transition:1s linear all;');
2229+
element.addClass('animation');
2230+
2231+
var options = {
2232+
duration: 0,
2233+
addClass: 'in'
2234+
};
2235+
2236+
var animator = $animateCss(element, options);
2237+
2238+
// expect(animator.$$willAnimate).toBeFalsy();
2239+
2240+
animator.start();
2241+
triggerAnimationStartFrame();
2242+
2243+
dump(element.attr('style'))
2244+
dump($window.getComputedStyle(element[0]).transitionDuration)
2245+
}));
2246+
22242247
it("should apply a transition and keyframe duration directly if both transitions and keyframe classes are detected",
22252248
inject(function($animateCss, $rootElement) {
22262249

0 commit comments

Comments
 (0)