countdown-control
v0.3.0
Published
Controlled countdown.
Downloads
3
Readme
Countdown control
Installation
npm install countdown-control
Usage
HTML
<time id="seconds"></time>
<button id="start">Start</button>
<button id="stop">Stop</button>
JavaScript
import { countdownControl } from 'countdown-control'
const seconds = document.querySelector('#seconds')
const start = document.querySelector('#start')
const stop = document.querySelector('#stop')
const handleChange = (time) => {
seconds.textContent = time.secondsTotal
}
const countdown = countdownControl(handleChange)
start.addEventListener('click', () => {
countdownControl.start(60) // Set the countdown to 60 seconds
})
stop.addEventListener('click', () => {
countdownControl.stop()
})