fix crash on reload during animation

Summary:
closes #11719

**Test plan (required)**

Cmd+r during native animation in uiexplorer
Closes https://github.com/facebook/react-native/pull/11720

Differential Revision: D4386449

fbshipit-source-id: a7b5ea2c77de260e8b95b5983438f9cef4d1d752
This commit is contained in:
Sokovikov 2017-01-05 21:48:10 -08:00 committed by Facebook Github Bot
parent 07a2a71df3
commit e8a45c96a7
3 changed files with 15 additions and 1 deletions

View File

@ -20,6 +20,11 @@ typedef void (^AnimatedOperation)(RCTNativeAnimatedNodesManager *nodesManager);
RCT_EXPORT_MODULE();
- (void)invalidate
{
[_nodesManager stopAnimationLoop];
}
- (void)dealloc
{
[self.bridge.eventDispatcher removeDispatchObserver:self];

View File

@ -60,6 +60,8 @@
- (void)stopAnimation:(nonnull NSNumber *)animationId;
- (void)stopAnimationLoop;
// events
- (void)addAnimatedEventToView:(nonnull NSNumber *)viewTag

View File

@ -321,7 +321,14 @@
- (void)stopAnimationLoopIfNeeded
{
if (_displayLink && _activeAnimations.count == 0) {
if (_activeAnimations.count == 0) {
[self stopAnimationLoop];
}
}
- (void)stopAnimationLoop
{
if (_displayLink) {
[_displayLink invalidate];
_displayLink = nil;
}