Tengo un componente que se mueve hacia arriba al desplazarse.
const [topBarHeight, setTopBarHeight] = useState(0); const scrollY = useRef(new Animated.Value(0)); const scrollYClamped = diffClamp(scrollY.current, 0, topBarHeight); const translateY = scrollYClamped.interpolate({ inputRange: [0, topBarHeight], outputRange: [0, -topBarHeight] }); const resetToInitialPosition = () => { scrollY.current.setValue(0); }; const handleScroll = Animated.event( [ { nativeEvent: { contentOffset: { y: scrollY.current } } } ], { useNativeDriver: true } ); Tengo un problema con resetToInitialPosition . Funciona bien y establece el valor animado de nuevo en el valor inicial, sin embargo, scrollYClamped y translateY no se restablecen y el componente sube inmediatamente después de cualquier interacción con la vista de desplazamiento. ¿Alguna idea de cómo restablecer esas dos variables a los valores iniciales también?