ls-countup
v1.2.5
Published
Just a simple count up
Downloads
29
Maintainers
Readme
Ls Countup
Just a simple count up.
Instalation
npm i ls-countup
How to:
// Import all stuff
const { LsCountup, LsCountupOptions, LsCountupSufixes } = require('ls-countup')
// Target date to be the reference for the countup
const targetDate = new Date(/* MUST BE A BACKWARD DATE */)
// Event dispatched right after the countup 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 countup stops
const onStop = ({ days, hours, minutes, seconds }) => { /* Do whatever you want... */ }
// You can use the LsCountupSufixes 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 LsCountupSufixes({ days: ' days', hours: ' hours', minutes: ' minutes', seconds: ' seconds' })
// Create a new options class with the parameters
const options = new LsCountupOptions({ targetDate, onStart, onTick, onStop, sufixes })
// Create a new countup class
const countup = new LsCountup(options)
// starts to countup
countup.start();
// changes countup target date
const newTargetDate = new Date(/* MUST BE A BACKWARD DATE */)
countup.changeTargetDate(newTargetDate)
// stops to countup
countup.stop()