From 72f46ed7349f5044d7b89fc8c7f5414b0805a67b Mon Sep 17 00:00:00 2001
From: Hailey <me@haileyok.com>
Date: Thu, 6 Jun 2024 06:28:02 -0700
Subject: cancel animations before updating value for min-shell animation
 (#4386)

* cancel animations before updating value

* comment
---
 src/view/com/util/MainScrollProvider.tsx | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'src/view/com/util/MainScrollProvider.tsx')

diff --git a/src/view/com/util/MainScrollProvider.tsx b/src/view/com/util/MainScrollProvider.tsx
index f45229dc4..b602da432 100644
--- a/src/view/com/util/MainScrollProvider.tsx
+++ b/src/view/com/util/MainScrollProvider.tsx
@@ -1,6 +1,10 @@
 import React, {useCallback, useEffect} from 'react'
 import {NativeScrollEvent} from 'react-native'
-import {interpolate, useSharedValue} from 'react-native-reanimated'
+import {
+  cancelAnimation,
+  interpolate,
+  useSharedValue,
+} from 'react-native-reanimated'
 import EventEmitter from 'eventemitter3'
 
 import {ScrollProvider} from '#/lib/ScrollContext'
@@ -117,6 +121,8 @@ export function MainScrollProvider({children}: {children: React.ReactNode}) {
         const newValue = clamp(startMode.value + dProgress, 0, 1)
         if (newValue !== mode.value) {
           // Manually adjust the value. This won't be (and shouldn't be) animated.
+          // Cancel any any existing animation
+          cancelAnimation(mode)
           mode.value = newValue
         }
       } else {
-- 
cgit 1.4.1

