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

frame-player

v1.1.5

Published

Frame Player

Downloads

5

Readme

frame-player

License MIT NPM Version

图片序列帧播放器,代替 gif、video 播放

Install

  • 本地
npm i -S frame-player
import FramePlayer from 'frame-player'

const framePlayer = new FramePlayer(options)
  • CDN
<script src="//unpkg.com/frame-player"></script>

API

class: FramePlayer(options)

  • options <Object>
    • canvas <string|HTMLCanvasElement> 画布选择器 | 画布对象。默认 "canvas"
    • width <number> 绘制宽度(当设置了 css width 时,作为绘制比例)
    • height <number> 绘制高度(当设置了 css height 时,作为绘制比例)
    • images <Array<string>> 图片路径数组
    • fps <number> 帧率。默认 24
    • loop <number> 循环播放次数。-1 为无限循环,默认 0 不循环
    • alternate <boolean> 是否轮流反向播放,配合 loop 使用才有效果。默认 false
    • transparent <boolean> 图片是否透明,true 每次绘制前清空画布。默认 false
    • autoPlay <boolean> 是否自动播放,true 会在图片 ready 后立即播放。默认 false

FramePlayer.version

  • returns: <number> 获取当前版本号

event: 'loading'

正在加载图片的事件,可用于画面上显示加载进度

event: 'ready'

所有图片加载完成的事件

event: 'play'

开始播放的事件

event: 'update'

播放每一帧的事件

event: 'stop'

停止播放的事件

framePlayer.on(event, fn)

事件监听

framePlayer.play([desc])

  • desc <boolean> 是否反向播放。默认 false

播放动画,将从之前 stop() 的位置继续播放,默认从 0 开始

framePlayer.stop([frame])

  • frame <number> 停止的帧索引。默认 当前播放索引

停止播放,也可以传入 frame 跳帧到指定位置

framePlayer.frame

  • returns: <number> 获取当前播放帧索引