diff options
| author | Matias Niemelä | 2013-05-26 20:28:47 -0400 |
|---|---|---|
| committer | Misko Hevery | 2013-05-30 22:01:42 -0700 |
| commit | a4b9a6aca9a0d4b1e3be2238cf549083776284ba (patch) | |
| tree | 8e0a661772ae7b484fb0a157a826b1864188efc0 /src/ng/animator.js | |
| parent | a2f9e78a56944b3c5024133770a4b436b4b06149 (diff) | |
| download | angular.js-a4b9a6aca9a0d4b1e3be2238cf549083776284ba.tar.bz2 | |
fix($animator): ensure $animator calculates the highest duration + delay for and transitions and animations together
Diffstat (limited to 'src/ng/animator.js')
| -rw-r--r-- | src/ng/animator.js | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/ng/animator.js b/src/ng/animator.js index b588de24..a9ec1616 100644 --- a/src/ng/animator.js +++ b/src/ng/animator.js @@ -345,28 +345,29 @@ var $AnimatorProvider = function() { var ELEMENT_NODE = 1; forEach(element, function(element) { if (element.nodeType == ELEMENT_NODE) { - var w3cProp = w3cTransitionProp, - vendorProp = vendorTransitionProp, - iterations = 1, - elementStyles = $window.getComputedStyle(element) || {}; + var elementStyles = $window.getComputedStyle(element) || {}; - //use CSS Animations over CSS Transitions - if(parseFloat(elementStyles[w3cAnimationProp + durationKey]) > 0 || - parseFloat(elementStyles[vendorAnimationProp + durationKey]) > 0) { - w3cProp = w3cAnimationProp; - vendorProp = vendorAnimationProp; - iterations = Math.max(parseInt(elementStyles[w3cProp + animationIterationCountKey]) || 0, - parseInt(elementStyles[vendorProp + animationIterationCountKey]) || 0, - iterations); - } + var transitionDelay = Math.max(parseMaxTime(elementStyles[w3cTransitionProp + delayKey]), + parseMaxTime(elementStyles[vendorTransitionProp + delayKey])); + + var animationDelay = Math.max(parseMaxTime(elementStyles[w3cAnimationProp + delayKey]), + parseMaxTime(elementStyles[vendorAnimationProp + delayKey])); - var parsedDelay = Math.max(parseMaxTime(elementStyles[w3cProp + delayKey]), - parseMaxTime(elementStyles[vendorProp + delayKey])); + var transitionDuration = Math.max(parseMaxTime(elementStyles[w3cTransitionProp + durationKey]), + parseMaxTime(elementStyles[vendorTransitionProp + durationKey])); - var parsedDuration = Math.max(parseMaxTime(elementStyles[w3cProp + durationKey]), - parseMaxTime(elementStyles[vendorProp + durationKey])); + var animationDuration = Math.max(parseMaxTime(elementStyles[w3cAnimationProp + durationKey]), + parseMaxTime(elementStyles[vendorAnimationProp + durationKey])); + + if(animationDuration > 0) { + animationDuration *= Math.max(parseInt(elementStyles[w3cAnimationProp + animationIterationCountKey]) || 0, + parseInt(elementStyles[vendorAnimationProp + animationIterationCountKey]) || 0, + 1); + } - duration = Math.max(parsedDelay + (iterations * parsedDuration), duration); + duration = Math.max(animationDelay + animationDuration, + transitionDelay + transitionDuration, + duration); } }); $window.setTimeout(done, duration * 1000); |
