ls-countdown
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

Ls Countdown

Just a simple countdown.

Codacy Badge npm version

Instalation

npm i ls-countdown

How to:

// Import all stuff
const { LsCountdown, LsCountdownOptions, LsCountdownSufixes } = require('ls-countdown')

// Target date to be the reference for the countdown
const targetDate = new Date(/* MUST BE A FOWARD DATE */)

// Event dispatched right after the countdown starts
const onStart = ({ days, hours, minutes, seconds }) => { /* Do whatever you want... */ }

// Event dispatched ever 1 second
const onTick = ({ days, hours, minutes, seconds }) => { /* Do whatever you want... */ }

// Event dispatched right after the countdown stops
const onStop = ({ days, hours, minutes, seconds }) => { /* Do whatever you want... */ }

// You can use the LsCountdownSufixes class to change the sufixes of the tick on return
// This is the defaults: { days: 'd', hours: 'h', minutes: 'm', seconds: 's' }
const sufixes = new LsCountdownSufixes({ days: ' days', hours: ' hours', minutes: ' minutes', seconds: ' seconds' })

// Create a new options class with the parameters
const options = new LsCountdownOptions({ targetDate, onStart, onTick, onStop, sufixes })

// Create a new countdown class
const countdown = new LsCountdown(options)

// starts to countdown
countdown.start();

// changes countdown target date
const newTargetDate = new Date(/* MUST BE A FOWARD DATE */)
countdown.changeTargetDate(newTargetDate)

// stops to countdown
countdown.stop()

Package Sidebar

Install

npm i ls-countdown

Weekly Downloads

13

Version

1.2.2

License

MIT

Unpacked Size

19.9 kB

Total Files

14

Last publish

Collaborators

  • leandrosimoes