|
|
import { FluidValue, deprecateInterpolate } from '@react-spring/shared' |
|
|
import { |
|
|
Constrain, |
|
|
OneOrMore, |
|
|
Animatable, |
|
|
ExtrapolateType, |
|
|
InterpolatorConfig, |
|
|
InterpolatorFn, |
|
|
} from '@react-spring/types' |
|
|
import { Interpolation } from './Interpolation' |
|
|
|
|
|
|
|
|
export const to: Interpolator = (source: any, ...args: [any]) => |
|
|
new Interpolation(source, args) |
|
|
|
|
|
|
|
|
export const interpolate: Interpolator = (source: any, ...args: [any]) => ( |
|
|
deprecateInterpolate(), new Interpolation(source, args) |
|
|
) |
|
|
|
|
|
|
|
|
export type Interpolated<T extends ReadonlyArray<any>> = { |
|
|
[P in keyof T]: T[P] extends infer Element |
|
|
? Element extends FluidValue<infer U> |
|
|
? U |
|
|
: Element |
|
|
: never |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export interface Interpolator { |
|
|
|
|
|
<Input extends ReadonlyArray<any>, Output>( |
|
|
parents: Input, |
|
|
interpolator: (...args: Interpolated<Input>) => Output |
|
|
): Interpolation<Output> |
|
|
|
|
|
|
|
|
<Input, Output>( |
|
|
parent: FluidValue<Input> | Input, |
|
|
interpolator: InterpolatorFn<Input, Output> |
|
|
): Interpolation<Output> |
|
|
|
|
|
|
|
|
<Out>( |
|
|
parents: OneOrMore<FluidValue>, |
|
|
config: InterpolatorConfig<Out> |
|
|
): Interpolation<Animatable<Out>> |
|
|
|
|
|
|
|
|
<Out>( |
|
|
parents: OneOrMore<FluidValue<number>> | FluidValue<number[]>, |
|
|
range: readonly number[], |
|
|
output: readonly Constrain<Out, Animatable>[], |
|
|
extrapolate?: ExtrapolateType |
|
|
): Interpolation<Animatable<Out>> |
|
|
} |
|
|
|