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