From a2e555b8c47212021de5601b263a57f33458d770 Mon Sep 17 00:00:00 2001 From: ersefuril Date: Mon, 11 Dec 2023 14:59:08 +0100 Subject: [PATCH] prevent initial scroll jump --- src/context/animatedValueContext.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/context/animatedValueContext.tsx b/src/context/animatedValueContext.tsx index 6ff1ed5f..c615753b 100644 --- a/src/context/animatedValueContext.tsx +++ b/src/context/animatedValueContext.tsx @@ -89,6 +89,19 @@ function useSetupAnimatedValues() { return isTouchActiveNative.value && activeIndexAnim.value >= 0; }, []); + useAnimatedReaction( + () => { + return outerScrollOffset.value; + }, + (cur, prev) => { + if (isDraggingCell.value) { + return; + } + outerScrollInit.value = cur; + }, + [outerScrollInit, isDraggingCell] + ); + const autoScrollDistance = useDerivedValue(() => { if (!isDraggingCell.value) return 0; const innerScrollDiff = scrollOffset.value - scrollInit.value;