From 4382df03fa1962aed027742c1b463406c40653c9 Mon Sep 17 00:00:00 2001 From: Matias Niemelä Date: Wed, 28 Aug 2013 19:18:33 -0400 Subject: fix(ngAnimate): cut down on extra $timeout calls --- src/ngAnimate/animate.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/ngAnimate') diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js index 32bbd6d5..696e80b1 100644 --- a/src/ngAnimate/animate.js +++ b/src/ngAnimate/animate.js @@ -283,7 +283,7 @@ angular.module('ngAnimate', ['ng']) enter : function(element, parent, after, done) { $delegate.enter(element, parent, after); performAnimation('enter', 'ng-enter', element, parent, after, function() { - $timeout(done || noop, 0, false); + done && $timeout(done, 0, false); }); }, @@ -353,7 +353,7 @@ angular.module('ngAnimate', ['ng']) move : function(element, parent, after, done) { $delegate.move(element, parent, after); performAnimation('move', 'ng-move', element, null, null, function() { - $timeout(done || noop, 0, false); + done && $timeout(done, 0, false); }); }, @@ -615,10 +615,11 @@ angular.module('ngAnimate', ['ng']) activeClassName += (i > 0 ? ' ' : '') + klass + '-active'; }); - $timeout(function() { - element.addClass(activeClassName); - $timeout(done, duration * 1000, false); - },0,false); + //this triggers a reflow which allows for the transition animation to kick in + element.prop('clientWidth'); + element.addClass(activeClassName); + + $timeout(done, duration * 1000, false); //this will automatically be called by $animate so //there is no need to attach this internally to the -- cgit v1.2.3