Easy Timer/Countdown/Chronometer Library – easytimer.js

Category: Date & Time , Javascript | September 25, 2021
Author:albert-gonzalez
Views Total:71 views
Official Page:Go to website
Last Update:September 25, 2021
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:

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

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

2. Create a new easyTimer.

var myTimer = new Timer();

3. Start the timer and done.

myTimer.start();

4. Stop/pause/reset the timer.

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

5. All possible configuration options:

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

6. Check if the timer is running/paused.

myTimer.isRunning();
myTimer.isPaused();

7. Get the current/total values.

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

8. 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.5.1 (09/25/2021)

  • removeAllEventListeners added to index.d.ts
  • Vendors updated

v4.5.0 (08/13/2021)

  • removeAllEventListeners method added
  • Vendors updated

v4.4.0 (06/24/2021)

  • startValues and target parameters now are casted to integer, so strings which contain a number can be used.

v4.3.4 (03/16/2021)

  • Added two functions: isPaused() & getConfig()

v4.3.2 (03/13/2021)

  • EasyTimer React Hook info added to docs

v4.3.2 (03/01/2021)

  • Bug fixed updating negative values in tenth of a second counter

v4.3.1 (11/14/2020)

  • Vendors updated

v4.3.0 (06/21/2020)

  • The library now uses a polyfill of a simple EventEmitter, so it does not depend on any platform anymore.

v4.2.0 (06/15/2020)

  • Bugfixes

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:


2 thoughts 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