Press "Enter" to skip to content

Easy To Use Timer/Stopwatch/Countdown library compatible with AMD | easytimer.js

Easy Timer JS is an easy-to-use Timer / Chronometer / Countdown library compatible with AMD and NodeJS that allows to count up or countdown to a specific value with callback support.

Features:

  • The refresh interval can be configured in tenths of seconds, seconds, minutes, and hours.
  • Sends events when the counter starts to pause and pause and when each type of unit changes.
  • A custom callback can be defined and will be executed in every timer update.
  • Two timer modes: normal and countdown.
  • Configurable starting and goal values.

How to make use of it:

Installation:

# NPM
$ npm install easytimer.js

# Bower
$ bower install easytimer.js

Insert the minified model of the easytimer.js script into the doc.

<script src="dist/easytimer.min.js"></script>

Create a brand new straightforward timer.

var myTimer = new Timer();

Start the timer and achieved.

myTimer.start();

Stop/pause/reset the timer.

myTimer.stop();
myTimer.pause();
myTimer.reset();

Configuration choices:

myTimer.start({
  precision: SECONDS,
  callback: customCallback,
  countdown: false,
  target: target,
  startValues: 0
});

Check if the timer is working.

myTimer.isRunning();

Get the current/whole values.

myTimer.getTimeValues();
myTimer.getTotalTimeValues();

Event handlers.

// myTimer.addEventListener(eventType, callback);
// myTimer.on(eventType, callback);
// myTimer.removeEventListener(eventType, callback);
// myTimer.off(eventType, callback);

timer.addEventListener('secondTenthsUpdated', function (e) {
  // do something
});

timer.addEventListener('secondsUpdated', function (e) {
  // do something
});

timer.addEventListener('minutesUpdated', function (e) {
  // do something
});

timer.addEventListener('hoursUpdated', function (e) {
  // do something
});

timer.addEventListener('daysUpdated', function (e) {
  // do something
});

timer.addEventListener('targetAchieved', function (e) {
  // do something
});

timer.addEventListener('stopped', function (e) {
  // do something
});

timer.addEventListener('reset', function (e) {
  // do something
});

timer.addEventListener('started', function (e) {
  // do something
});

timer.addEventListener('paused', function (e) {
  // do something
});

Easy Timer/Countdown/Chronometer Library, easytimer.js Plugin/Github


See Demo And Download

Official Website(albert-gonzalez): Click Here

This superior jQuery/javascript plugin is developed by albert-gonzalez. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *