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

countdown-plugin

v2.1.0

Published

countdown

Downloads

4

Readme

countdown

countdown 一个轻量级倒计时插件,不依赖任何框架。

countdown演示:demo

如何使用

  • 首先,引入 countdown.min.js(该文件包含在demo目录)
<script src="countdown.min.js"></script>

或者,你也可以使用模块的形式引入到代码中,只需要先安装它:

npm install countdown-plugin

再引入模块:

// 普通引入
var Countdown = require('countdown-plugin');

// es6引入
import Countdown from 'countdown-plugin'
  • 然后,在页面里实例化它:
var c1 = new Countdown();
  • 最后,通过 start 方法启动定时器:
c1.start();

当需要暂停定时器时,可通过 stop 方法:

c1.stop();

参数

当用户需要自定义倒计时,可以给实例化的 Countdown 方法传递相关参数。这些参数包括一些内容:

| 参数 | 描述 | 默认值 | 格式 | |----------|----------|------------|----------| | begin | 开始时间 | new Date(),即当前时间 | String 或 Date object | | end | 结束时间 | '2030/01/01' | String | | timestamp | 时间戳,常用于设置倒计时的时间,单位为。当设置此项时,begin 和 end 会被忽略 | 0 | String 或 Number | | isFormat | 是否格式化输出的时间格式,比如 年-yyyy, 天-dd | false,即不格式 | Boolean | | isMilliSecond | 是否输出毫秒 | false,即不输出 | Boolean | | change | 时间每次更新后的回调函数。它包含一个参数,该参数是一个包含了年、天、时、分、秒、毫秒这些属性的对象 | function(res) {console.log(res);} | Function | | over | 倒计时结束后的回调函数。 | function() {console.log('The countdown is over');} | Function |

方法

countdown 提供了两个实例方法:

| 参数 | 描述 | 默认值 | 格式 | |----------|----------|------------|----------| | start | 启动倒计时 | | Function | | stop | 暂停倒计时 | | Function |