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

hease

v0.3.3

Published

> 一个超级精简的缓动库

Downloads

10

Readme

hease

一个超级精简的缓动库

publish npm-downloads npm-version
内置缓动函数速查表请参考: https://easings.net/zh-cn

安装

npm install hease

例子

import { hease, EASE } from 'hease';
// 播放,并注册相关事件
const ani = hease(0, 1, 2000, EASE.linear)
    .onUpdate((val) => {
        console.log(val);
    })
    .onComplate(() => {
        console.log('动画播放完成');
    })
    .play();
// 停止动画
ani.stop();
// 立即完成动画
ani.complete();

如何播放无数次动画?

// ...
// 只需要在播放数传入Infinity
ani.play(Infinity)
// ...

注意:无限播放动画将无法触发onComplete,但是可以通过手动调用complete方法触发

如何创建一个yoyo动画?

import { hease, EASE, yoyo } from 'hease';
// 使用内部实现的yoyoy辅助函数
const ani = hease(0, 1, 2000, yoyo(EASE.linear));

注意:时间正向和时间回溯的动画效果时不一样的,内置实现的时按照时间回溯的方式实现的

相关API补充

hease(from: number|number[], to: number|number[], duration = 1000, ease = EASE.linear)
创建一个缓动器
Hease.play()
直接播放1次动画,或者继续播放动画
Hease.play(num: number)
播放num次动画
bindTicker(fn: HeaseTicker)
绑定自定义刷新器
createUpdate(fn: (dt: number) => void)
创建一个刷新运行对象