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

172
Visualizações
React Native Animated Rotation Anchor Point

I'm trying to get this rotation animation with an anchor point done, similar to the standard CSS attribute transform-origin. I've read about shifting the whole thing before the rotation like in this post, but i can't get that to work in my case.

My element is defined like this:

<Animated.View
    style={[ 
       styles.test,
       { transform: [{ rotate: rotateInterpolator }] },
    ]}
>
    <Text style={{ color: "white" }}>Test</Text>
</Animated.View>

with the following styles applied directly, since they are needed on mount:

test: {
    position: "absolute",
    top: 0,
    height: containerHeight,
    width: containerWidth,
    justifyContent: "center",
    alignItems: "center",
    backgroundColor: "green",
    transform: [{ translateX: -containerHeight / 2 }, { translateY: -containerHeight / 2 }],
},

I have defined my interpolator for the rotation like this:

const rotateInterpolator = rotateValue.interpolate({
    inputRange: [0, 1],
    outputRange: ["90deg", "0deg"],
});

On user input, i start the animation for the Animated Value rotateValue:

Animated.timing(rotateValue, {
    toValue: 1,
    duration: 500,
    easing: Easing.linear,
    useNativeDriver: false,
}).start();

But since there is no option to define the anchor point, the element will rotate around its center, which is the center of the container defined by containerWidth and containerHeight.

However I want the anchor to be at the center on the bottom of the container, which would be (containerWidth / 2, containerHeight).

Any help is appreciated :)

about 4 years ago · Santiago Trujillo
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