[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 <shuangzuan.he@icloud.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
Shuangzuan 2015-06-16 07:07:08 -07:00
parent bd081d84a7
commit 5793f5c4c4
1 changed files with 1 additions and 1 deletions

View File

@ -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);