From 3c53e7d6a79a1db31c9b06906c5af70380df214d Mon Sep 17 00:00:00 2001 From: Avinash Lingaloo Date: Thu, 28 Apr 2022 13:42:10 +0400 Subject: [PATCH] checks for ongoing animation --- app/screens/snack_bar/index.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/screens/snack_bar/index.tsx b/app/screens/snack_bar/index.tsx index cb7ce25f35..05d3e22e3f 100644 --- a/app/screens/snack_bar/index.tsx +++ b/app/screens/snack_bar/index.tsx @@ -44,6 +44,7 @@ const SnackBar = ({barType, componentId, onUndoPress, sourceScreen}: SnackBarPro const {width: windowWidth} = useWindowDimensions(); const offset = useSharedValue(0); const startY = useSharedValue(0); + const isPanning = useSharedValue(false); const config = SNACK_BAR_CONFIG[barType]; const styles = getStyleSheet(theme); @@ -117,6 +118,7 @@ const SnackBar = ({barType, componentId, onUndoPress, sourceScreen}: SnackBarPro Pan(). onStart((st) => { startY.value = st.absoluteY; + isPanning.value = true; }). activeOffsetY(20). onUpdate((e) => { @@ -126,11 +128,13 @@ const SnackBar = ({barType, componentId, onUndoPress, sourceScreen}: SnackBarPro }). onEnd(() => { runOnJS(hideSnackBar)(); + isPanning.value = false; }); const animateHiding = () => { - offset.value = withTiming(100, {duration: 500}); - setShowSnackBar(false); + if (!isPanning.value) { + offset.value = withTiming(100, {duration: 500}, () => runOnJS(hideSnackBar)()); + } }; useEffect(() => { @@ -145,7 +149,7 @@ const SnackBar = ({barType, componentId, onUndoPress, sourceScreen}: SnackBarPro if (showSnackBar === false) { t = setTimeout(() => { dismissOverlay(componentId); - }, 700); + }, 350); } return () => {