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

93
Vistas
Animated.View style not changing even thought the value of animation variable is getting updated

I want the text to move up when i click it. But even though the topPosition value is updated on click to -40, the View doesnt ever move. How can I make the animation run?

const TabButton = () => {
  //Animation variables
  const topPosition = useRef(new Animated.Value(1)).current;
  const labelVisibility = useRef(false);

  const pushIconUp = () => {
    console.log('dwad');
    Animated.timing(topPosition, {
      toValue: -40,
      duration: 1000,
      useNativeDriver: false,
    }).start();
    console.log(topPosition);
  };
  const pushIconDown = () => {
    Animated.timing(topPosition, {
      toValue: 0,
      duration: 100,
      useNativeDriver: false,
    }).start();
  };

  return (
    <TouchableHighlight onPress={pushIconUp}>
      <Animated.View style={{marginTop: topPosition, borderColor: 'white'}}>
        <Text>daw</Text>
      </Animated.View>
    </TouchableHighlight>
  );
};

export default TabButton;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think it's better if you animate the translation instead and also the TouchableOpacity should be inside the Animated.View.

<Animated.View style={{ transform: [{ translateY: topPosition }], borderColor: 'white'}}>
    <TouchableHighlight onPress={pushIconUp}>
        <Text>daw</Text>
    </TouchableHighlight>
</Animated.View>

You can also enable useNativeDriver

about 4 years ago · Juan Pablo Isaza Denunciar
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