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

@cutting-mat/director

v0.0.3

Published

A front-end automatic control library

Downloads

2

Readme

中文 | English

@cutting-mat/director

npm license

前端自动化脚本执行,灵活实现各种自动播放、演示场景

快速开始

  1. 安装:
npm i @cutting-mat/director --save
  1. 创建实例
import Director from "@cutting-mat/director";
const director = new Director({
  // 实例配置
});
  1. 装载 actions 并执行
director.loadAction([
  {
    action: () => {
      console.log(`Do somthing 1/3`)
    },
  },
  {
    action: () => {
      console.log(`Do somthing 2/3`)
    },
    {
    action: () => {
      console.log(`Do somthing 3/3`)
    }
]);

director.play()

实例配置

  • autoPlay

类型: Boolean

是否自动播放

默认: false

  • loop

类型: Boolean

是否循环播放(开启autoPlay时有效)

默认: false

  • delay

类型: Number

自动播放间隔时间,单位 ms(开启autoPlay时有效)

默认: 4000

实例属性

  • activated

类型: Boolean

是否正在自动播放

  • stepIndex

类型: Number

当前动作序号

实例方法

  • load(actions)

{Array} actions:Action 数组

批量装载动作,可用于初始化实例,重复执行数据会覆盖。

  • push(action)

{Object} action:Action

添加一个动作,可用于初始化实例

  • insert(actions)

{Array} actions:Action 数组

在当前步骤后批量添加动作,实例初始化之后有效。

  • next()

播放下一个动作

  • prev()

播放上一个动作

  • go(index)

{Number} index:动作序号

执行指定序号的动作

  • play()

开始播放

  • pause()

暂停播放

  • stop()

停止播放,stepIndex将归零。

  • destroy()

销毁实例

  • on(eventName, eventHandle)

{String} eventName:事件名称

{Function} eventHandle:回调方法

监听事件

  • off([eventName, [eventHandle]])

{String} eventName:取消监听的事件名称

{Function} eventHandle: 取消监听的回调方法,若不传将取消该事件的所有监听

取消监听事件

Action 对象属性

  • {Function} action: 动作函数,非必要

  • {Boolean} autoPlay: 是否自动播放下一个,优先级高于实例配置,非必要

  • {Number} delay: 自动播放间隔,开启自动播放有效,优先级高于实例配置,非必要

事件

  • change(activated, stepIndex)

播放位置(stepIndex)改变事件

  • ended()

播放结束事件

License

MIT