Easy Timer/Countdown/Chronometer Library – easytimer.js

Category: Date & Time , Javascript | December 22, 2019
Author: albert-gonzalez
Views Total: 4,048
Official Page: Go to website
Last Update: December 22, 2019
License: MIT

Preview:

Easy Timer/Countdown/Chronometer Library – easytimer.js

Description:

easytimer.js is an easy-to-use Timer/Countdown/Chronometer library built in pure JavaScript that allows to count up to or countdown from a given value with callback support.

Installation:

# NPM
$ npm install easytimer.js

# Bower
$ bower install easytimer.js

How to use it:

Insert the minified version of the easytimer.js script into the document.

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

Create a new easyTimer.

var myTimer = new Timer();

Start the timer and done.

myTimer.start();

Stop/pause/reset the timer.

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

Configuration options:

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

Check if the timer is running.

myTimer.isRunning();

Get the current/total 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
});

Changelog:

v4.1.1 (12/22/2019)

  • Instance now accepts a default config

v4.0.2 (11/01/2019)

  • Bugfixes

v4.0.1 (07/23/2019)

  • Update

v4.0.0 (07/22/2019)

  • Update

v3.2.0 (06/10/2019)

  • Vendors updated to the last version
  • toString function shows right day values >= 100

v3.1.0 (03/19/2019)

  • Validation added in the parameters: startValues, target and precision
  • Vendor updates

01/13/2019

  • v3.0.1: bugfix

You Might Be Interested In:


One thought on “Easy Timer/Countdown/Chronometer Library – easytimer.js

  1. travis

    Seems as if the reset() does not exist on the npm package like the original EasyTimer.js has.
    Is there a reason the reset function was removed?

    Reply

Leave a Reply