You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
744 B
17 lines
744 B
import {Interpolation, InterpolatorArgs, InterpolatorFn, Arrify} from "@react-spring/web";
|
|
import {getAnimated} from "@react-spring/animated";
|
|
|
|
export class FixedInterpolation<Input = any, Output = any> extends Interpolation<Input, Output> {
|
|
constructor(readonly source: unknown, args: InterpolatorArgs<Input, Output>) {
|
|
super(source, args);
|
|
getAnimated(this)!.setValue(this._get())
|
|
}
|
|
}
|
|
|
|
export function altTo<Input = any, Output = any>(source: unknown, args: InterpolatorArgs<Input, Output>|InterpolatorFn<Arrify<Input>, Output>): Interpolation<Input, Output> {
|
|
if (Array.isArray(args)) {
|
|
return new FixedInterpolation(source, args)
|
|
} else {
|
|
return new FixedInterpolation(source, [args])
|
|
}
|
|
} |