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

138
Vistas
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 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