https://github.com/tiagocastro070/countdown
Simple, lightweight and very easy to use JS Countdown package.
https://github.com/tiagocastro070/countdown
countdown countdown-clock countdown-timer js timer
Last synced: 12 months ago
JSON representation
Simple, lightweight and very easy to use JS Countdown package.
- Host: GitHub
- URL: https://github.com/tiagocastro070/countdown
- Owner: tiagocastro070
- License: mit
- Created: 2020-05-31T21:34:02.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T22:25:47.000Z (almost 6 years ago)
- Last Synced: 2024-05-30T17:44:19.708Z (almost 2 years ago)
- Topics: countdown, countdown-clock, countdown-timer, js, timer
- Language: JavaScript
- Size: 21.5 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Countdown
Simple, lightweight and very easy to use Countdown package.

## Installation
```
npm install countdown-tmr
import Countdown from 'countdown-tmr';
```
```javascript
const elm = document.querySelector('#my-countdown')
const options = {
date: '3 Jul 2020 08:00:00',
labels: {
days: 'd',
hours: 'h',
minutes: 'm',
seconds: 's'
}
}
const countdown = new Countdown(elm, settings).play()
```
## Properties
Property | Type | Default Value
-|-|-
date | string | 24 hours from current date. Format: '3 Jul 2020 08:00:00'
playing | bool | true
labels | object | days: 'days',
hours: 'hours'
minutes: 'minutes',
seconds: 'seconds'
## Methods
Method | Function
-| -
play | Initializes the countdown
stop | Stops the countdown
getRemaining | Returns the remaining value (in miliseconds) of a given argument. Available arguments are 'days', 'hours', 'minutes' and 'seconds'.
## Events
Events can be accessed through the ```on()``` method.
```javascript
on(eventType, callbackFn)
```
Events are triggered every time certain value changes (e.g. from 2 hours to 1 hour). Here is the events list:
- `on('days', callbackFn)`
- `on('hours', callbackFn)`
- `on('minutes', callbackFn)`
- `on('seconds', callbackFn)`
```javascript
coundown.on('hours', myCallback)
function myCallback() {
console.log('an hour less to go')
}
```