How to use the @popmotion/popcorn.interpolate function in @popmotion/popcorn

To help you get started, we’ve selected a few @popmotion/popcorn examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github framer / motion / _src / utils / use-transform.ts View on Github external
() => {
            if (transformedValue.current) transformedValue.current.destroy()

            // This cast is needed because interpolate does not base it's return type on the to type (yet)
            const transformer = interpolate(from, to) as Transformer
            transformedValue.current = value.addChild({ transformer })
            return transformedValue.current
        },
        [value, ...from, ...to]
github framer / motion / src / utils / transform.ts View on Github external
export function transform(
    ...args:
        | [number, number[], T[], TransformOptions?]
        | [number[], T[], TransformOptions?]
) {
    const useImmediate = !Array.isArray(args[0])
    const argOffset = useImmediate ? 0 : -1
    const inputValue = args[0 + argOffset] as number
    const inputRange = args[1 + argOffset] as number[]
    const outputRange = args[2 + argOffset] as T[]
    const options = args[3 + argOffset] as TransformOptions

    const interpolator = interpolate(inputRange, outputRange, {
        mixer: getMixer(outputRange[0]),
        ...options,
    })

    return useImmediate ? interpolator(inputValue) : interpolator
}