Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/filipchalupa/countdown-control
Countdown control JavaScript package.
https://github.com/filipchalupa/countdown-control
Last synced: about 14 hours ago
JSON representation
Countdown control JavaScript package.
- Host: GitHub
- URL: https://github.com/filipchalupa/countdown-control
- Owner: FilipChalupa
- Created: 2023-02-15T21:27:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-02-16T00:16:13.000Z (over 1 year ago)
- Last Synced: 2024-10-30T06:32:49.165Z (8 days ago)
- Language: TypeScript
- Homepage: https://filipchalupa.cz/countdown-control/
- Size: 206 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Countdown control [![npm](https://img.shields.io/npm/v/countdown-control.svg)](https://www.npmjs.com/package/countdown-control) ![npm type definitions](https://img.shields.io/npm/types/countdown-control.svg)
## Installation
```bash
npm install countdown-control
```## Usage
### HTML
```html
Start
Stop
```### JavaScript
```js
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()
})
```## Demo
For more complex example check [code here](demo/index.html#L52) or live [demo here](https://filipchalupa.cz/countdown-control/).