1.0.2 • Published 3 years ago
@unipro/dms-countdown v1.0.2
DMS Countdown
Example Usage
function updateCountdown(days, hours, minutes, seconds) {
// This is called every second
}
function removeCountdown() {
// This is called on Christmas day 2050
}
const countdown = new Countdown({
to: new Date(2050, 11, 25),
precedingZero: true,
unitsToShow: ['days', 'hours', 'minutes', 'seconds'],
updateCb: updateCountdown,
endCb: removeCountdown
})
countdown.start()
Settings
Param | Type | Description |
---|---|---|
endCb | function | The Callback to execute once the date has passed. |
precedingZero | boolean | Whether to zero-pad the time units. |
pulse | number | The number of milliseconds for each tick. |
to | Date | The date to countdown to. |
unitsToShow | Array.<string> | The day and time units that will be passed to updateCb. |
updateCb | function | The callback to execute updates on each tick. |
The available units are weeks, days, hours, minutes, and seconds
Defaults
Param | Default |
---|---|
precedingZero | false |
pulse | 1000 |
unitsToShow | 'days', 'hours', 'minutes', 'seconds' |