Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
React Native- reseting scroll animation

I have a component that is moved up on scrolling.

  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
    }
  );

I have a problem with resetToInitialPosition. It works fine and sets animated value back to initial, however scrollYClamped and translateY are not being reset and the component goes all the way up immediately after any interaction with the scroll view. Any idea how to set those two variables back to initial values as well?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda