Primitive that creates tween functions
npm install @solid-primitives/tween



Creates an efficient tweening derived signal that smoothly transitions
a given signal from its previous value to its next value whenever it changes.
```
npm install @solid-primitives/tweenor
yarn add @solid-primitives/tween
`ts
import { createSignal } from "solid-js";
import { createTween } from "@solid-primitives/tween";
const [value, setValue] = createSignal(0);
const tweenedValue = createTween(value, { duration: 500 });
setMyNumber(100);
// tweenedValue will now smoothly transition from 0 to 100 over 500 ms
`
`ts`
function createTween(
target: Accessor
options: {
duration?: number = 100; // ms
easing?: (t: number) => number = (t) => t;
}
): Accessor
target can be any reactive value (signal, memo, or function that calls such).() => props.value
For example, to use a component prop, specify .
You can provide two options:
- duration is the number of milliseconds to perform the transitioneasing
from the previous value to the next value. Defaults to 100.
- is a function that maps a number between 0 and 1 to a number(t) => t
between 0 and 1, to speed up or slow down different parts of the transition.
The default easing function is linear (no easing).(t) => 0.5 - Math.cos(Math.PI * t) / 2
A common choice is .
Internally, createTween usesrequestAnimationFramerequestAnimationFrame` for efficiency.
to smoothly update the tweened value at the display refresh rate.
After the tweened value reaches the underlying signal value,
it will stop updating via
See CHANGELOG.md