Skip to content

Commit

Permalink
fix: patch react-native-reanimated-carousel (dohooo/react-native-rean…
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Meissonnier committed Sep 11, 2024
1 parent 83a7fff commit 67604dd
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions patches/react-native-reanimated-carousel+4.0.0-alpha.12.patch
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,

0 comments on commit 67604dd

Please sign in to comment.