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

135
Visualizações
How to use Animated API to scale text small and up rather than smaller and right react native

Whenever I am trying to use the Animated API in react-native to make my text scale smaller and up it always goes to the right. Here are pictures of the scaling

enter image description here

Here is my code, id like to have it inline with the textbox border started. However, Scaling it to the left using translateX doesn't work for all screen sizes.

function OnboardingAnimatedLabel(props: OnboardingAnimatedLabelProps) {
  const { label, isFocused, value, onFocus } = props;

  const focusAnim = useRef(new Animated.Value(0)).current;

  useEffect(() => {
    Animated.timing(focusAnim, {
      toValue: isFocused || !!value ? 1 : 0,
      duration: 250,
      easing: Easing.bezier(0.4, 0, 0.2, 1),
      useNativeDriver: true,
    }).start();
  }, [focusAnim, isFocused, value]);

  let color = onFocus || value !== '' ? '#DADADA' : '#FFF';

  return (
    <TouchableWithoutFeedback>
      <Animated.View
        style={[
          styles.labelContainer,
          {
            transform: [
              {
                scale: focusAnim.interpolate({
                  inputRange: [0, 1],
                  outputRange: [1, 0.75],
                  extrapolate: 'clamp',
                  extrapolateLeft: 'clamp',
                }),
              },
              {
                translateY: focusAnim.interpolate({
                  inputRange: [0, 1],
                  outputRange: [30, 10],
                }),
              },
              // {
              //   translateX: focusAnim.interpolate({
              //     inputRange: [0, 1],
              //     outputRange: [0, -55],
              //   }),
              // },
            ],
          },
        ]}>
        <Text style={[styles.label, { color }]}>{label}</Text>
      </Animated.View>
    </TouchableWithoutFeedback>
  );
}

const styles = StyleSheet.create({
  labelContainer: {
    backgroundColor: 'transparent',
  },
  label: {
    fontFamily: 'Avenir-Heavy',
    fontSize: 20,
  },
});

export default OnboardingAnimatedLabel;

Any help to solve this for all screen sizes would be great! Thanks

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