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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wacaca

v1.0.5

Published

A light JavaScript Tween library for easy animations.

Downloads

20

Readme

wocaca

A light JavaScript Tween library for easy animations.

online demo

安装

您可以选择使用 wacaca.min.js

<script src="path/to/wacaca.min.js" />

也可以使用 npm

npm i wacaca

使用

import { Tween } from 'wacaca'

const oDemo = document.querySelector('.demo')

new Tween(0)
  .to(400)
  .duration(1500) // 在 1500ms 内数值从 0 变化到 400
  .onUpdate(val => {
    oDemo.style.left = val + 'px'
  })
  .start()

如果使用 script 引入方式,上述代码修改为:

<div class="demo"></div>
<script src="./wacaca.min.js"></script>
<script>
  const oDemo = document.querySelector('.demo')

  new WACACA.Tween(0)
    .to(400)
    .duration(1500) // 在 1500ms 内数值从 0 变化到 400
    .easing(WACACA.Easing.bounceInOut)
    .onUpdate(val => {
      oDemo.style.left = val + 'px'
    })
    .start()
</script>

点我查看动画效果

插值函数

wacaca 使用了 d3-interpolate 做插值函数,支持多种类型数据。

// 数组
new WACACA.Tween([0, 1, 2, 3])
  .to([0, 10, 20, 30])
  .duration(1500)
  .onUpdate(val => console.log(val)) // 输出类似:[0, 8.9262, 17.8524, 26.778599999999997]
  .start()

// 对象
new WACACA.Tween({ x: 0, y: 0 })
  .to({ x: 100, y: 200 })
  .duration(1500)
  .onUpdate(val => console.log(val)) // 输出类似:{x: 87.56845, y: 175.1369}
  .start()

// 颜色
new WACACA.Tween('#ff0000')
  .to('#00ffff')
  .duration(1500)
  .onUpdate(val => console.log(val)) // 输出类似:rgb(31, 224, 224)
  .start()

关于动画怎么做,就要看怎么用 update 返回的数据。

Easing

wacaca 内置了来自 tween.jseasing-functions

import { Tween, Easing } from 'wacaca'

new Tween(0)
  .to(400)
  .duration(1500)
  .easing(Easing.bounceInOut)
  .onUpdate(val => console.log(val))
  .start()

关于缓动函数曲线点此查看

LICENSE

MIT