Skip to content

Simple, lightweight and very easy to use JS Countdown package.

License

Notifications You must be signed in to change notification settings

tiagocastro070/countdown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Countdown

Simple, lightweight and very easy to use Countdown package.

Installation

npm install countdown-tmr

import Countdown from 'countdown-tmr';
const elm = document.querySelector('#my-countdown')
const options = {
  date: '3 Jul 2020 08:00:00',
  labels: {
    days: 'd',
    hours: 'h',
    minutes: 'm',
    seconds: 's'
  }
}
const countdown = new Countdown(elm, settings).play()

Properties

Property Type Default Value
date string 24 hours from current date. Format: '3 Jul 2020 08:00:00'
playing bool true
labels object days: 'days',
hours: 'hours'
minutes: 'minutes',
seconds: 'seconds'

Methods

Method Function
play Initializes the countdown
stop Stops the countdown
getRemaining Returns the remaining value (in miliseconds) of a given argument. Available arguments are 'days', 'hours', 'minutes' and 'seconds'.

Events

Events can be accessed through the on() method.

on(eventType, callbackFn)

Events are triggered every time certain value changes (e.g. from 2 hours to 1 hour). Here is the events list:

  • on('days', callbackFn)
  • on('hours', callbackFn)
  • on('minutes', callbackFn)
  • on('seconds', callbackFn)
coundown.on('hours', myCallback)

function myCallback() {
  console.log('an hour less to go')
}

About

Simple, lightweight and very easy to use JS Countdown package.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published