From 753390dfe8b41a8d4b969d28f08a95a8d0c6c711 Mon Sep 17 00:00:00 2001 From: Arek Kubaczkowski Date: Thu, 21 Mar 2024 13:40:25 +0100 Subject: [PATCH] chore: better sticky view keyboard interpolation --- src/components/KeyboardStickyView/index.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/components/KeyboardStickyView/index.tsx b/src/components/KeyboardStickyView/index.tsx index 57f9e47f55..253c222a98 100644 --- a/src/components/KeyboardStickyView/index.tsx +++ b/src/components/KeyboardStickyView/index.tsx @@ -1,8 +1,5 @@ import React, { forwardRef, useMemo } from "react"; -import Reanimated, { - interpolate, - useAnimatedStyle, -} from "react-native-reanimated"; +import Reanimated, { clamp, useAnimatedStyle } from "react-native-reanimated"; import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller"; @@ -32,13 +29,13 @@ const KeyboardStickyView = forwardRef< { children, offset: { closed = 0, opened = 0 } = {}, style, ...props }, ref, ) => { - const { height, progress } = useReanimatedKeyboardAnimation(); + const { height } = useReanimatedKeyboardAnimation(); const stickyViewStyle = useAnimatedStyle(() => { - const offset = interpolate(progress.value, [0, 1], [closed, opened]); + const offset = clamp(height.value, closed, opened + height.value); return { - transform: [{ translateY: height.value + offset }], + transform: [{ translateY: offset }], }; }, [closed, opened]);