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

canvaskeyframes

v0.4.2

Published

The simplest sequence frame animation plugin of canvas .

Downloads

58

Readme

CanvasKeyFrames - HTML5 Canvas 图片序列帧播放工具npm Build Status

English Version

CanvasKeyFrames

图片序列帧播放工具,用canvas操作图片动画,封装了常用方法。

  • el [canvas容器,必须是DOM对象]
    • type [图片模式,'array'和 'sprite'模式,array是图片对象数组,sprite是基于宽度扩展的单张雪碧图]
    • imgs [图片帧对象数组或单图,对应不同模式]
    • options {
      cover: 10, //指定封面帧,默认是0
      fps: 30, //默认是24
      loop: 10 //初始化默认的循环数,在formTo中可以设置,默认是infinite
      width: 300, //注意,隐藏元素是拿不到宽度的,所以特殊情况下需要指定宽度
      height: 300,
      _iw: 300, // 雪碧图中单个图片的宽度
      _ih: 300, // 雪碧图中单个图片的高度
      framesCount: 10 // 雪碧图帧数
      }

API

CanvasKeyFrames(el, type, imgs, options)

  • el canvas容器,必须是DOM对象
  • type 图片模式,'array'和 'sprite'模式,array是图片对象数组,sprite是基于宽度扩展的单张雪碧图
  • imgs 图片帧对象数组或单图,对应不同模式
  • options
    • cover 指定封面帧,默认是0
    • fps 默认是24
    • loop 初始化默认的循环数,在formTo中可以设置,默认是infinite
    • width 隐藏元素是拿不到宽度的,所以特殊情况下需要指定宽度
    • height 隐藏元素是拿不到宽度的,所以特殊情况下需要指定宽度
    • _iw 雪碧图中单个图片的宽度
    • _ih 雪碧图中单个图片的高度
    • framesCount 雪碧图帧数

Install

  • base

your html

<script src="canvas-keyframes.js"></script>
  • npm
npm i canvaskeyframes

your app.js


import CanvasKeyFrames from 'canvaskeyframes'

方法介绍

goto(n) 跳转到某一帧
next() 下一帧
prev() 上一帧
fromTo(from, to, loop, callback)

from [启始帧(从0开始)] to [结束帧数] loop [循环次数,默认是infiniten] callback [回调函数]

toFrom(to, from, loop, callback)

to [启始帧(从高位开始)] from [结束帧数(从低位结束)] loop [循环次数,默认是infiniten] callback [回调函数]

repeatplay(from, to, loop, callback)

fromto正着播一遍,然后回调fromBack,倒着播一遍,然后再回调toBack,进行逻辑判断 from [启始帧(从0开始)] to [结束帧数] loop [循环次数,默认是infinite正播过去,再倒播回来] callback [回调函数]

from(from, loop, callback)

from [启始帧(从0开始)] loop [循环次数,默认是infinite] callback [回调函数]

to(to, loop, callback)

to [结束帧数] loop [循环次数,默认是infinite] callback [回调函数]

pause() 暂停动画
stop() 停止并回到第一帧或cover帧
play() 从当前位置播放动画,会继承上次使用fromTo、form或to的属性
destroy() 销毁对象

前端学习交流群,QQ群 : 692337464

License

MIT License