From 4328d9a1068a28817d12f4fb2ba066e419fad9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=9D=B1=E6=BE=94?= Date: Thu, 3 Mar 2022 18:09:02 +0800 Subject: [PATCH] fix: remove logic that touch the screent will stopped animation --- src/ScrollViewGesture.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ScrollViewGesture.tsx b/src/ScrollViewGesture.tsx index c3a0cb40..46230912 100644 --- a/src/ScrollViewGesture.tsx +++ b/src/ScrollViewGesture.tsx @@ -19,6 +19,7 @@ import type { WithTimingAnimation } from './types'; import { dealWithAnimation } from './utils/dealWithAnimation'; type GestureContext = { + validStart: boolean; panOffset: number; max: number; }; @@ -210,12 +211,16 @@ const IScrollViewGesture: React.FC = (props) => { { onStart: (_, ctx) => { touching.value = true; - cancelAnimation(translation); + ctx.validStart = true; onScrollBegin && runOnJS(onScrollBegin)(); ctx.max = (maxPage - 1) * size; ctx.panOffset = translation.value; }, onActive: (e, ctx) => { + if (ctx.validStart) { + ctx.validStart = false; + cancelAnimation(translation); + } touching.value = true; const { translationX, translationY } = e; let panTranslation = isHorizontal.value