Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

89
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda