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

@tanbo/bezier

v1.0.1

Published

A bezier library

Readme

贝塞尔曲线

在 web 开发中,我们经常会用动画来提高用户体验,但浏览器只提供了一个 css3 来实现动画的方式。css3 实现动画一般能满足大部分的需求,但当我们需要对动画做粗细的步长控制、暂停、重启等操作时,css3 提供的 transitionstart/transitionendanimationstart/animationend 接口明显不能满足我们需求。这时,就需要一个可定制、可编辑的贝塞尔曲线工具来实现我们想要的功能。

本库提供了两个贝塞尔曲线的工具类,分别为普通的贝塞尔曲线 Bezier 和 css3 的三次贝塞尔曲线 CubicBezier。两个类的使用方式是一致的,但 CubicBezier 类对时间因子 t 作了修正,计算结果和 css3 的表现一致,使之更符合我们的直觉。

import { CubicBezier } from '@tanbo/bezier';

const bezier = new CubicBezier(0.36, 0.66, 0.04, 1); 

const div = document.getElementById('box');

let i = 0;

const fn = function() {
    if (i < 100) {
        i++;
        // t 为当前进度百分比
        const t = 1 / 100;
        // result 为当前 bezier 坐标点的位置
        const result = bezier.update(t);
        div.style.transform = `translateX(${result.y * 400}px)`;

        requestAnimationFrame(fn);
    }
};

requestAnimationFrame(fn);

如果三次贝塞尔曲线不能满足你的需求,你还可以使用多次贝塞尔曲线。

import { Bezier } from '@tanbo/bezier';

// 可以传偶数个数字,且不少于4个
const bezier = new Bezier([
      -.9, -.7,
      -.8, .4,
      .1, -.6,
      .2, -1,
      .5, .6,
      .5, 1.3,
      0, .9,
      1, 1]); 

const div = document.getElementById('box');

let i = 0;

const fn = function() {
    if (i < 100) {
        i++;
        // result 为当前 bezier 坐标点的位置
        const result = bezier.update(i / 100);
        console.log(result);

        requestAnimationFrame(fn);
    }
};

requestAnimationFrame(fn);