alorel/alo-timer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alorel/alo-timer

最新稳定版本:1.1

Composer 安装命令:

composer create-project alorel/alo-timer

包简介

A simple countdown class when you need accuracy

README 文档

README

For most things a simple setTimeout() or setInterval() is enough - but Javascript timers get throttled when the page is minimised/tabbed out of and you will end up with imprecise timings in the long run. This is where AloTimer comes in - you set a timer and poll it with as much precision as you need - while individual polling calls might get throttled, the end result will always be accurate.

Coverage Status Build Status Deps Deps

NPM

Functionality

Greenkeeper badge

  • Add or subtract any amount of miliseconds/seconds/minutes/hours/days
  • Get the amount of any of the above left individually
  • Output time left as a DD:HH:mm:ss string (customisable)
  • A simple check whether the timeout has finished
  • Pause and unpause the timer

Installation

<script src="path-to-alotimer.min.js"></script>

Or, if you prefer Node,

npm install alo-timer --save

Usage example

var span       = document.getElementById("my-countdown"),
    timer      = new AloTimer(3600000, ["hours", "minutes", "seconds"]), // 1 hr
    intervalCb = function () {
       if (!timer.hasFinished) {
           span.innerText = timer.toString();
       } else {
           span.innerText = "YOUR SCHNITZEL IS DONE!";
           clearInterval(interval);
       }
   },
   interval   = setInterval(intervalCb, 1000);

More information:

统计信息

  • 总下载量: 215
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 2
  • 开发语言: CSS

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-07-12