From 5793f5c4c4d0dd17905b6683779d479c7960ca57 Mon Sep 17 00:00:00 2001 From: Shuangzuan Date: Tue, 16 Jun 2015 07:07:08 -0700 Subject: [PATCH] [AnimationExperimental] Fixed CATransaction completion block invoke immediately Summary: [CATransaction Class Reference](https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CATransaction_class/index.html) In Tasks > Getting and Setting Completion Block Objects > Discussion: The completion block object that is guaranteed to be called (on the main thread) as soon as all animations subsequently added by this transaction group have completed (or have been removed.) If no animations are added before the current transaction group is committed (or the completion block is set to a different value,) the block will be invoked immediately. Closes https://github.com/facebook/react-native/pull/1400 Github Author: Shuangzuan Test Plan: Imported from GitHub, without a `Test Plan:` line. --- Libraries/Animation/RCTAnimationExperimentalManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Animation/RCTAnimationExperimentalManager.m b/Libraries/Animation/RCTAnimationExperimentalManager.m index 6bcda39ae..13c3f079a 100644 --- a/Libraries/Animation/RCTAnimationExperimentalManager.m +++ b/Libraries/Animation/RCTAnimationExperimentalManager.m @@ -235,7 +235,6 @@ RCT_EXPORT_METHOD(startAnimation:(NSNumber *)reactTag @try { [view.layer setValue:toValue forKey:keypath]; NSString *animationKey = [@"RCT" stringByAppendingString:RCTJSONStringify(@{@"tag": animationTag, @"key": keypath}, nil)]; - [view.layer addAnimation:animation forKey:animationKey]; if (!completionBlockSet) { strongSelf->_callbackRegistry[animationTag] = callback; [CATransaction setCompletionBlock:^{ @@ -247,6 +246,7 @@ RCT_EXPORT_METHOD(startAnimation:(NSNumber *)reactTag }]; completionBlockSet = YES; } + [view.layer addAnimation:animation forKey:animationKey]; } @catch (NSException *exception) { return RCTInvalidAnimationProp(strongSelf->_callbackRegistry, animationTag, keypath, toValue);