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

easy-keyframe-animation

v0.0.6

Published

一个使用 js 动态创建 animation 的库

Downloads

3

Readme

easy-keyframe-animation

使用 js 动态创建 animation 和 keyframe 的库,支持 typescript,兼容各类浏览器。

使用

安装

npm install -S easy-keyframe-animation

导出实例

import keyframeAnimation from 'easy-keyframe-animation';

注册 keyframe

keyframeAnimation.registerKeyframe('move', {
  0: {
    transform: `translate3d(0, 0, 0)`
  },
  100: {
    transform: `translate3d(0, 99px, 0)`
  }
});

挂载动画

keyframeAnimation.addAnimation(el, {
  name: 'move',
  duration: '4s',
});

API

registerKeyframe(name: string, options: KeyframeOptions): void

注册一个 keyframe

name

注册的 keyframe 名称

options

对应 keyframes 的每一项。key 可以是 from,to 等关键字,填入 number 时会自动添加百分号。Record<string, string> 对应动画的每一帧,左侧是变化的属性,右侧是变化的值(需要自行拼接成字符串)

unregisterKeyframe(name: string): void

注销一个 keyframe

name

注销的 keyframe 名称

addAnimation(el: HTMLElement, options: string | AnimationOptions, cb?: () => void): Promise<void>

挂载一个动画到 el 上,默认返回 Promise,动画完成后会 resolve

el

挂载dom

options

动画配置的可选项

cb

动画完成的回调函数

removeAnimation(el: HTMLElement): void

移除一个元素的动画

el

移除dom

pauseAnimation(el: HTMLElement): void

暂停一个元素的动画

el

暂停dom

recoverAnimation(el: HTMLElement): void

恢复一个暂停元素的动画

el

恢复dom