mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
listen to onUserDrivenAnimationEnded in passive effects versions of useAnimatedPropsLifecycle (#46361)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46361 changelog: [internal] to support onScroll native animated event, subscribe to onUserDrivenAnimationEnded event in passive effects version of useAnimatedPropsLifecycle. Reviewed By: javache Differential Revision: D62236130 fbshipit-source-id: 850e6cb5544eb0377492fd030f735b159f24ab8d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4c55e94dc5
commit
8ebddf3715
@@ -330,6 +330,17 @@ function useAnimatedPropsLifecycle_passiveEffects(node: AnimatedProps): void {
|
||||
|
||||
useEffectImpl(() => {
|
||||
node.__attach();
|
||||
let drivenAnimationEndedListener: ?EventSubscription = null;
|
||||
|
||||
if (node.__isNative) {
|
||||
drivenAnimationEndedListener =
|
||||
NativeAnimatedHelper.nativeEventEmitter.addListener(
|
||||
'onUserDrivenAnimationEnded',
|
||||
data => {
|
||||
node.update();
|
||||
},
|
||||
);
|
||||
}
|
||||
if (prevNodeRef.current != null) {
|
||||
const prevNode = prevNodeRef.current;
|
||||
// TODO: Stop restoring default values (unless `reset` is called).
|
||||
@@ -344,6 +355,8 @@ function useAnimatedPropsLifecycle_passiveEffects(node: AnimatedProps): void {
|
||||
} else {
|
||||
prevNodeRef.current = node;
|
||||
}
|
||||
|
||||
drivenAnimationEndedListener?.remove();
|
||||
};
|
||||
}, [node]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user