mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-04 21:09:21 +08:00
Add extractOffset to Animated
Summary: `flattenOffset` has proven extremely useful, especially when dealing with pan responders and other gesture based animations, but I've also found a number of use cases for the inverse. This diff introduces `extractOffset`, which sets the offset value to the base value, and resets the base value to zero. A common use case would be to extractOffset onGrant and flattenOffset onRelease. Closes https://github.com/facebook/react-native/pull/10721 Differential Revision: D4145744 fbshipit-source-id: dc2aa31652df0b31450556f611db43548180c7dd
This commit is contained in:
committed by
Facebook Github Bot
parent
bf2b435322
commit
6535858c71
@@ -225,6 +225,18 @@ RCT_EXPORT_METHOD(flattenAnimatedNodeOffset:(nonnull NSNumber *)nodeTag)
|
||||
[valueNode flattenOffset];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(extractAnimatedNodeOffset:(nonnull NSNumber *)nodeTag)
|
||||
{
|
||||
RCTAnimatedNode *node = _animationNodes[nodeTag];
|
||||
if (![node isKindOfClass:[RCTValueAnimatedNode class]]) {
|
||||
RCTLogError(@"Not a value node.");
|
||||
return;
|
||||
}
|
||||
|
||||
RCTValueAnimatedNode *valueNode = (RCTValueAnimatedNode *)node;
|
||||
[valueNode extractOffset];
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(connectAnimatedNodeToView:(nonnull NSNumber *)nodeTag
|
||||
viewTag:(nonnull NSNumber *)viewTag)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user