-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Native Animated] Support for animated tracking in native driver #17896
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2a3055e
Implement tracking animated node in native driver for iOS
kmagiera ea5353f
Add nodes manager as ref to native node to allow proper detaching of …
kmagiera ada41b0
Implement native driver tracking for Android
kmagiera e149b17
Implement resetConfig for frames and decay native drivers on Android
kmagiera 9a34873
Post update callback is not necessary on Android because of the prope…
kmagiera 0590afa
Tests for animated tracking on Android
kmagiera 9df5509
Tracking unit tests for iOS
kmagiera bfc6b58
Restore NS_REQUIRES_SUPER removed by accident for updateNodeIfNecessa…
kmagiera c29611b
Remove clone of animated.spring section from RNTester example app
kmagiera 27f5d43
Fix flow
kmagiera a64dbf6
Responding to comments - renaming
kmagiera e929b04
Fix build warning in RCTNativeAnimatedNodesManagerTests.m
kmagiera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "RCTAnimatedNode.h" | ||
|
||
|
||
@interface RCTTrackingAnimatedNode : RCTAnimatedNode | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
|
||
#import "RCTTrackingAnimatedNode.h" | ||
#import "RCTValueAnimatedNode.h" | ||
#import "RCTNativeAnimatedNodesManager.h" | ||
|
||
@implementation RCTTrackingAnimatedNode { | ||
NSNumber *_animationId; | ||
NSNumber *_toValueNodeTag; | ||
NSNumber *_valueNodeTag; | ||
NSMutableDictionary *_animationConfig; | ||
} | ||
|
||
- (instancetype)initWithTag:(NSNumber *)tag | ||
config:(NSDictionary<NSString *, id> *)config | ||
{ | ||
if ((self = [super initWithTag:tag config:config])) { | ||
_animationId = config[@"animationId"]; | ||
_toValueNodeTag = config[@"toValue"]; | ||
_valueNodeTag = config[@"value"]; | ||
_animationConfig = [NSMutableDictionary dictionaryWithDictionary:config[@"animationConfig"]]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)onDetachedFromNode:(RCTAnimatedNode *)parent | ||
{ | ||
[self.manager stopAnimation:_animationId]; | ||
[super onDetachedFromNode:parent]; | ||
} | ||
|
||
- (void)performUpdate | ||
{ | ||
[super performUpdate]; | ||
|
||
// change animation config's "toValue" to reflect updated value of the parent node | ||
RCTValueAnimatedNode *node = (RCTValueAnimatedNode *)[self.parentNodes objectForKey:_toValueNodeTag]; | ||
_animationConfig[@"toValue"] = @(node.value); | ||
|
||
[self.manager startAnimatingNode:_animationId | ||
nodeTag:_valueNodeTag | ||
config:_animationConfig | ||
endCallback:nil]; | ||
} | ||
|
||
@end | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call this
updateAnimationConfig
instead since it doesn't "reset" the animation completely but only updates certain parameters.