@huth/animate
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

animate

A simple, bare bones animation utility for time-based animations of numbers and hex color values.

  1. npm install @huth/animate
  2. 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  
  • from and to can be either a number or a full CSS string hex color value (#FF0000), or an object with those values.
  • duration timing in milliseconds.
  • delay time before animation starts, in milliseconds.
  • easing easing function that returns a value between 0 and 1.
  • render callback called with the interpolated value for every animation step
  • start callback called when the animation starts (after delay)
  • end callback called when the animation has finished
  • cancel callback 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).

/@huth/animate/

    Package Sidebar

    Install

    npm i @huth/animate

    Weekly Downloads

    4

    Version

    3.0.0

    License

    MIT

    Unpacked Size

    5.72 kB

    Total Files

    5

    Last publish

    Collaborators

    • huth