A number to transform between the input and output ranges.
A linear series of numbers (either all increasing or decreasing).
A series of numbers, colors, strings, or arrays/objects of those. Must be the same length as inputRange.
Optional options: TransformOptions<T>Clamp: Clamp values to within the given range. Defaults to true.
Given an input range of [0, 200] and an output range of
[0, 1], this function will return a value between 0 and 1.
The input range must be a linear series of numbers. The output range
can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
Every value in the output range must be of the same type and in the same format.
import * as React from "react"
import { transform } from "framer-motion"
export function MyComponent() {
const inputRange = [0, 200]
const outputRange = [0, 1]
const output = transform(100, inputRange, outputRange)
// Returns 0.5
return <div>{output}</div>
}
Transforms numbers into other values by mapping them from an input range to an output range.
Given an input range of [0, 200] and an output range of
[0, 1], this function will return a value between 0 and 1.
The input range must be a linear series of numbers. The output range
can be any supported value type, such as numbers, colors, shadows, arrays, objects and more.
Every value in the output range must be of the same type and in the same format.
import * as React from "react"
import { Frame, transform } from "framer"
export function MyComponent() {
const inputRange = [-200, -100, 100, 200]
const outputRange = [0, 1, 1, 0]
const convertRange = transform(inputRange, outputRange)
const output = convertRange(-150)
// Returns 0.5
return <div>{output}</div>
}
Generated using TypeDoc
Transforms numbers into other values by mapping them from an input range to an output range. Returns the type of the input provided.