3.0.0 • Published 2 years ago
@huth/animate v3.0.0
animate
A simple, bare bones animation utility for time-based animations of numbers and hex color values.
npm install @huth/animate- Animate!
import animate from "@huth/animate"
let stop = animate({
from: 0,
to: 100,
duration: 750,
delay: 200,
easing: (t) => t ** 3,
render: (value) => console.log(value),
start: () => console.log("animation started"),
end: () => console.log("animation complete"),
cancel: () => console.log("animation stopped"),
})
// stop() call me to stop animation fromandtocan be either a number or a full CSS string hex color value (#FF0000), or an object with those values.durationtiming in milliseconds.delaytime before animation starts, in milliseconds.easingeasing function that returns a value between0and1.rendercallback called with the interpolated value for every animation stepstartcallback called when the animation starts (after delay)endcallback called when the animation has finishedcancelcallback called if the animation was stopped before it had a chance to finish
In addition, the animate method returns a function that when called will kill the animation (and trigger any cancel callback).