Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!