aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatias Niemelä2013-08-28 19:32:20 -0400
committerMisko Hevery2013-09-03 17:06:49 -0700
commit36ad40b18cfdd0690411a5169aa94e222946b5cf (patch)
tree221c73bebdd87e91fa56fb3bc55cbf67e59cc0c0 /src
parent4e15c4fb47e93c1f6619a09125bc9a350e39b113 (diff)
downloadangular.js-36ad40b18cfdd0690411a5169aa94e222946b5cf.tar.bz2
fix(ngAnimate): ensure that ngClass is always compiled before enter, leave and move animations
Closes #3727 Closes #3603
Diffstat (limited to 'src')
-rw-r--r--src/ngAnimate/animate.js34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/ngAnimate/animate.js b/src/ngAnimate/animate.js
index 696e80b1..ca136a50 100644
--- a/src/ngAnimate/animate.js
+++ b/src/ngAnimate/animate.js
@@ -201,9 +201,9 @@ angular.module('ngAnimate', ['ng'])
var NG_ANIMATE_STATE = '$$ngAnimateState';
var rootAnimateState = {running:true};
- $provide.decorator('$animate', ['$delegate', '$injector', '$sniffer', '$rootElement', '$timeout',
- function($delegate, $injector, $sniffer, $rootElement, $timeout) {
-
+ $provide.decorator('$animate', ['$delegate', '$injector', '$sniffer', '$rootElement', '$timeout', '$rootScope',
+ function($delegate, $injector, $sniffer, $rootElement, $timeout, $rootScope) {
+
$rootElement.data(NG_ANIMATE_STATE, rootAnimateState);
function lookup(name) {
@@ -282,8 +282,10 @@ angular.module('ngAnimate', ['ng'])
*/
enter : function(element, parent, after, done) {
$delegate.enter(element, parent, after);
- performAnimation('enter', 'ng-enter', element, parent, after, function() {
- done && $timeout(done, 0, false);
+ $rootScope.$$postDigest(function() {
+ performAnimation('enter', 'ng-enter', element, parent, after, function() {
+ done && $timeout(done, 0, false);
+ });
});
},
@@ -315,8 +317,10 @@ angular.module('ngAnimate', ['ng'])
* @param {function()=} done callback function that will be called once the animation is complete
*/
leave : function(element, done) {
- performAnimation('leave', 'ng-leave', element, null, null, function() {
- $delegate.leave(element, done);
+ $rootScope.$$postDigest(function() {
+ performAnimation('leave', 'ng-leave', element, null, null, function() {
+ $delegate.leave(element, done);
+ });
});
},
@@ -352,8 +356,10 @@ angular.module('ngAnimate', ['ng'])
*/
move : function(element, parent, after, done) {
$delegate.move(element, parent, after);
- performAnimation('move', 'ng-move', element, null, null, function() {
- done && $timeout(done, 0, false);
+ $rootScope.$$postDigest(function() {
+ performAnimation('move', 'ng-move', element, null, null, function() {
+ done && $timeout(done, 0, false);
+ });
});
},
@@ -550,6 +556,7 @@ angular.module('ngAnimate', ['ng'])
var durationKey = 'Duration',
delayKey = 'Delay',
+ propertyKey = 'Property',
animationIterationCountKey = 'IterationCount',
ELEMENT_NODE = 1;
@@ -610,6 +617,13 @@ angular.module('ngAnimate', ['ng'])
timeout is empty (this would cause a flicker bug normally
in the page */
if(duration > 0) {
+ var node = element[0];
+
+ //temporarily disable the transition so that the enter styles
+ //don't animate twice (this is here to avoid a bug in Chrome/FF).
+ node.style[w3cTransitionProp + propertyKey] = 'none';
+ node.style[vendorTransitionProp + propertyKey] = 'none';
+
var activeClassName = '';
forEach(className.split(' '), function(klass, i) {
activeClassName += (i > 0 ? ' ' : '') + klass + '-active';
@@ -617,6 +631,8 @@ angular.module('ngAnimate', ['ng'])
//this triggers a reflow which allows for the transition animation to kick in
element.prop('clientWidth');
+ node.style[w3cTransitionProp + propertyKey] = '';
+ node.style[vendorTransitionProp + propertyKey] = '';
element.addClass(activeClassName);
$timeout(done, duration * 1000, false);