npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tween-animate

v4.0.1

Published

a faster tween animate library

Downloads

57

Readme

tween-animate

usage

import Animate from 'tween-animate';

const { Easing } = Animate;

// internal global requestAnimationFrame start
Animate.play();

Animate(0, 10, 1000)
  .transform('yoyo')
  .transform('step', 20)
  .on('update', v => console.log(v));

// console.log
// 0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 0

Explore more with Codepen

get start

// Recommand the link below contains the current version
<script src="https://unpkg.com/tween-animate/dist/tween-animate.umd.js"></script>
yarn add tween-animate
npm install tween-animate

Animate

Animate(from, to, time, easing);
Animate(from).to(to, time, easing);

examples:

Animate(0, 100, 1000, Easing.Linear.None);

Animate({
  x: 0,
  y: 0
}).to({
    x: 100
  }, 1000)
  .to({
    y: 100
  }, 1000)
  .on('update', v => console.log(v));

events

  • start
  • update
  • complete
Animate(0, 100, 1000)
  .on('start', () => console.log('start'))
  .on('update', v => console.log('update', v))
  .on('complete', () => console.log('complete'))

transforms

transforms list. And all the transforms can be nested.

  • loop - transform('loop', count: number)
  • speed - transform('speed', speed: number)
  • reverse
  • yoyo
  • wait - transform('wait', waitTime: number)
Animate(0, 1, 1000).transform('wait', 1000).to(2, 1000);
  • step - transform('step', steps: number, type?: 'floor' | 'ceil')
Animate(0, 1, 1000); // last 1000ms
Animate(0, 1, 1000).transform('loop', 3); // last 3000ms
Animate(0, 1, 1000).transform('loop', 3).transform('loop', 2); // last 6000ms

// the following two behave different
Animate(0, 100, 1000).transform('loop', 2).transform('yoyo');
Animate(0, 100, 1000).transform('yoyo').transform('loop', 2);

Animate property

  • play - function
    // internal requestAnimationFrame start
    Animate.play();
  • stop - function
    // internal requestAnimationFrame stop
    Animate.stop();
  • update - function
    function ticker() {
      requestAnimationFrame(animate)
      Animate.update();
    }
    requestAnimationFrame(ticker);
  • updateElpased - function
    Animate.updateElpased(1000); // update 1000 ms;
  • Easing - Easing funciton list
    const { Easing } = Animate;

faster tween animate

parseFromTo(
  { x: [1, 2, 3], y: 1 }, // from
  { x: [1, 2, 6], y: 3 }, // to
);
/** update function is generated by "from" and "to"
 * @param a - from 
 * @param b - status - range 0 - 1
 */
function anonymous(a,b) {
  var a0=a["x"];a0["2"]=3+b*3;a["y"]=1+b*2;return a;
}

when "from" and "to" value have different structure, console will show friendly error message

v3 docs

if you are looking for v3's docs: https://github.com/voderl/tween-animate/blob/v3.1.4/README.md

develop

install

yarn

start

yarn watch

template

yarn template

then open http://localhost: 3000

test

yarn test

build

yarn build