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

Commit 7ef9dbb

Browse files
matskomhevery
authored andcommitted
refactor($animate): avoid checking for transition/animation support during each animation
1 parent e819d21 commit 7ef9dbb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/ngAnimate/animate.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ angular.module('ngAnimate', ['ng'])
215215
//the empty string value is the default animation
216216
//operation which performs CSS transition and keyframe
217217
//animations sniffing. This is always included for each
218-
//element animation procedure
219-
classes.push('');
218+
//element animation procedure if the browser supports
219+
//transitions and/or keyframe animations
220+
if ($sniffer.transitions || $sniffer.animations) {
221+
classes.push('');
222+
}
220223

221224
for(var i=0; i < classes.length; i++) {
222225
var klass = classes[i],
@@ -477,7 +480,7 @@ angular.module('ngAnimate', ['ng'])
477480

478481
//skip the animation if animations are disabled, a parent is already being animated
479482
//or the element is not currently attached to the document body.
480-
if ((parent.inheritedData(NG_ANIMATE_STATE) || disabledAnimation).running) {
483+
if ((parent.inheritedData(NG_ANIMATE_STATE) || disabledAnimation).running || animations.length == 0) {
481484
//avoid calling done() since there is no need to remove any
482485
//data or className values since this happens earlier than that
483486
//and also use a timeout so that it won't be asynchronous
@@ -579,11 +582,7 @@ angular.module('ngAnimate', ['ng'])
579582
ELEMENT_NODE = 1;
580583

581584
function animate(element, className, done) {
582-
if (!($sniffer.transitions || $sniffer.animations)) {
583-
done();
584-
return;
585-
}
586-
else if(['ng-enter','ng-leave','ng-move'].indexOf(className) == -1) {
585+
if(['ng-enter','ng-leave','ng-move'].indexOf(className) == -1) {
587586
var existingDuration = 0;
588587
forEach(element, function(element) {
589588
if (element.nodeType == ELEMENT_NODE) {

0 commit comments

Comments
 (0)