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

mot-plugin-apng

v0.2.0

Published

该插件可以单独使用也可搭配 mot 库使用 需要浏览器支持以下四种能力

Downloads

1

Readme

说明

该插件可以单独使用也可搭配 mot 库使用 需要浏览器支持以下四种能力

单独使用

import APNG from "mot-plugin-apng";
let apng = new APNG();

集成在 mot 库中使用

正在开发 💦

API

isSupport

用途:浏览器是否支持 apng 参数:无 返回:promise

apng
  .isSupport()
  .then(() => {
    console.log("not support");
  })
  .catch(() => {
    console.log("support");
  });

animateImage(img,autoplay,independent)

用途:将 apng 解析成 canvas 提供控制器

  • 参数 1 img :HTMLImgElement 需要解析的 img dom 元素
  • 参数 2 autoplay :boolean 是否自动播放
  • 参数 3 independent :boolean 是否需要独立控制器 >> 当检测到相同 url 地址时 为了性能 默认会共用一个控制器增加 canvas 上下文,当设置为 true 是 会为当前项独立新增一个控制器

返回:promise anim

var image1 = document.querySelector(".apng-image1");
apng.animateImage(image1, false).then((anim) => {
  anim.play([50, 70]);
  anim.before((ctx, f) => {
    ctx.fillStyle = "red";
    ctx.fillRect(0, 0, 100 + f * 3, 100 + f * 3);
  });
  anim.after((ctx, f) => {
    ctx.fillStyle = "blue";
    ctx.fillRect(200, 200, 100 + f * 3, 100 + f * 3);
  });
});

anim 控制器-属性

| 参数名 | 数据类型 | 用途 | | ------ | -------- | ------------------- | | width | number | 当前 canvas 宽度 px | | height | number | 当前 canvas 高度 px |

anim 控制器-方法

anim.play(frameArray)

用途:控制播放

  • 参数 1 frameArray: [start,end]数组 表示播放的帧数范围,只有 start 的时候播放至结尾

anim.stop()

用途:停止播放

anim.clear()

用途:清除内容

anim.start()

用途:搭配 pause 暂停使用,重新开始播放

anim.pause(frame)

用途:暂停播放

  • 参数 1 frame:当 frame 存在时,到达 frame 帧数时暂停播放

anim.setOptions({playNum,rate})

用途:设置选项

| 参数名 | 数据类型 | 用途 | 默认值 | | ------- | -------- | -------- | --------------- | | playNum | number | 播放次数 | 0:表示循环播放 | | rate | number | 播放速率 | 1 |

anim.before(func)

用途:表示在 apng 之前渲染

  • 参数 1 func: 要执行的函数 暴露两个参数 context:canvas 上下文 f:当前帧数

anim.after()

用途:表示在 apng 之后渲染

  • 参数 1 func: 要执行的函数 暴露两个参数 context:canvas 上下文 f:当前帧数

anim.on(hook,callback)

用途:状态监听

| 参数名 | 数据类型 | 用途 | 默认值 | | -------- | -------- | --------------------------------------- | ------ | | hook | string | 监听的状态 目前只开放了'stop','allStop' | | | callback | function | 回调函数 stop 时触发回调 | |

anim.once(hook,callback)

用途:一次性状态监听

| 参数名 | 数据类型 | 用途 | 默认值 | | -------- | -------- | --------------------------------------- | ------ | | hook | string | 监听的状态 目前只开放了'stop','allStop' | | | callback | function | 回调函数 stop 时触发回调 | |