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

mina-countdown

v1.0.1

Published

一个轻量、方便的小程序 倒计时 逻辑处理库

Downloads

6

Readme

mina-countdown

mina-countdown,一个方便、轻量的 小程序 倒计时逻辑库
时间处理逻辑使用tiny-timer库,在此做出声明和感谢

change log:

  1. 2021.01.21 init package

支持的事件

主动

  • 支持 start 事件
  • 支持 pause 事件
  • 支持 resume 事件
  • 支持 stop 事件

监听

  • 支持 tick 事件
  • 支持 done 事件
  • 支持 statusChanged 事件

demo 展示

  1. demo1:监听 pressMove 拖拽 手势 | | | | -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |

使用方法

大致可以分为 4 步:

  1. npm 安装 mina-countdown,开发工具构建 npm
  2. 引入 mina-countdown
  3. onload 实例化 mina-countdown
  4. wxml 展示倒计时

命令行

npm install mina-countdown
安装完成后,开发工具构建 npm

*.js

import Countdown from 'mina-countdown'; // 1. 引入mina-countdown

Page({
  onLoad: function (options) {
    // 2. onload实例化mina-countdown
    // 会创建this.countdown指向实例对象
    new Countdown(this, 'countdown', {
      // 大多数情况只需要监听 tick 事件,更新 this.data.countdown 即可满足大部分场景
      tick: function (countdown) {
        // 在Countdown倒计时过程中触发,触发事件间隔为1s,参数单位:秒
        console.log('countdown:' + countdown);
        // 更新 data.countdown 做渲染使用
        this.setData({
          countdown,
        });
      },
      done: function () {
        //在Countdown倒计时结束时触发
        console.log('done');
      },
      statusChanged: function (status) {
        //在Countdown状态改变时触发,status代表下一步的状态 'running' | 'paused' | 'stopped'
        console.log('status:' + status);
      },
    });
  },
  startCountdown: function (duration = 60) {
    this.countdown.start(duration); // 支持传入倒计时时间,单位:秒
  },
  pauseCountdown: function () {
    this.countdown.pause();
  },
  resumeCountdown: function () {
    this.countdown.resume();
  },
  stopCountdown: function () {
    this.countdown.stop();
  },
});

*.wxml

在 view 上利用 countdown 处理渲染逻辑

简单展示

<text wx:if="{{countdown>0}}"> 倒计时{{countdown}}秒 </text>

<text wx:else> 开始倒计时 </text>

配合 mina-tool 的 wxs 工具 formatCountdown 优化展示

使用 mina-tool,请参看 mina-tool.wxs

<wxs src="mina-tool/wxs/format.wxs" module="format" />

<text> {{format.formatCountdown(countdown)}} </text>

以上简单几步即可使用 mina-countdown