Skip to content

Interpolated animation values as strings don't work in Android #1189

Open
@kg-currenxie

Description

@kg-currenxie

const interpolatedValue = Animated.interpolate(animatedValue, [0.0, 1.0], ['0', '-5'])

The typed values in the second array are supposed to be strings. However Android doesn't like that.

Changing above strings to numbers does work! But TypeScript complains about it.

Screenshot 2020-03-11 at 09 59 23

// Works in iOS
const interpolatedValue = Animated.interpolate(animatedValue, [0.0, 1.0], ['0', '-5'])

const animatedStyle = Styles.createAnimatedViewStyle({
  transform: [{ translateY: interpolatedValue }],
})

return (
  <View style={styles.loadingWrapper}>
    <Animated.View style={[styles.loadingDot, animatedStyle]} />
  </View>
)

The type is as follows:
let interpolate: (value: Animated.Value, inputRange: number[], outputRange: string[]) => Animated.Value

Edit: I've now tried Android, iOS, and web. All 3 work with just a number. Is this just a mis-typed parameter, or is there any other reason it was made a string?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions