-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: patch react-native-reanimated-carousel (dohooo/react-native-rean…
- Loading branch information
Mathieu Meissonnier
committed
Sep 11, 2024
1 parent
83a7fff
commit 67604dd
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
patches/react-native-reanimated-carousel+4.0.0-alpha.12.patch
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,44 @@ | ||
diff --git a/node_modules/react-native-reanimated-carousel/src/components/ScrollViewGesture.tsx b/node_modules/react-native-reanimated-carousel/src/components/ScrollViewGesture.tsx | ||
index 80a3fe0..ff03ed6 100644 | ||
--- a/node_modules/react-native-reanimated-carousel/src/components/ScrollViewGesture.tsx | ||
+++ b/node_modules/react-native-reanimated-carousel/src/components/ScrollViewGesture.tsx | ||
@@ -65,7 +65,7 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => { | ||
const maxPage = dataLength; | ||
const isHorizontal = useDerivedValue(() => !vertical, [vertical]); | ||
const max = useSharedValue(0); | ||
- const panOffset = useSharedValue(0); | ||
+ const panOffset = useSharedValue<number | undefined>(undefined); | ||
const touching = useSharedValue(false); | ||
const validStart = useSharedValue(false); | ||
const scrollEndTranslation = useSharedValue(0); | ||
@@ -291,6 +291,10 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => { | ||
const onGestureUpdate = useCallback((e: PanGestureHandlerEventPayload) => { | ||
"worklet"; | ||
|
||
+ if (panOffset.value === undefined) { | ||
+ return; | ||
+ } | ||
+ | ||
if (validStart.value) { | ||
validStart.value = false; | ||
cancelAnimation(translation); | ||
@@ -335,6 +339,10 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => { | ||
const onGestureEnd = useCallback((e: GestureStateChangeEvent<PanGestureHandlerEventPayload>, _success: boolean) => { | ||
"worklet"; | ||
|
||
+ if (panOffset.value === undefined) { | ||
+ return; | ||
+ } | ||
+ | ||
const { velocityX, velocityY, translationX, translationY } = e; | ||
const scrollEndVelocityValue = isHorizontal.value | ||
? velocityX | ||
@@ -381,6 +389,8 @@ const IScrollViewGesture: React.FC<PropsWithChildren<Props>> = (props) => { | ||
|
||
if (!loop) | ||
touching.value = false; | ||
+ | ||
+ panOffset.value = undefined; | ||
}, [ | ||
size, | ||
loop, |