simplyCountdown.js
Why another countdown ?
I developed this little library in a boring day. I regularly use this kind of Javascript's libraries to display countdowns on websites and this one exactly meets the needs that I have. It is perfect to make 'under construction' pages, etc.
This is a very (very) basic Javascript CountDown.
Getting Started
install via npm or bower
$ yarn add simplycountdown.js
// or
$ npm install simplycountdown.js
Insert simplyCountdown to your HTML
<link rel="stylesheet" href="css/simplyCountdown.theme.default.css"/>
<script src="dist/simplyCountdown.min.js"></script>
simplyCountdown('[CSS-SELECTOR]', {
year: 2019,
month: 6,
day: 28,
hours: 0,
minutes: 0,
seconds: 0,
words: {
days: { singular: 'day', plural: 'days' },
hours: { singular: 'hour', plural: 'hours' },
minutes: { singular: 'minute', plural: 'minutes' },
seconds: { singular: 'second', plural: 'seconds' }
},
plural: true,
inline: false,
inlineClass: 'simply-countdown-inline',
enableUtc: false,
onEnd: function() { return; },
refresh: 1000,
sectionClass: 'simply-section',
amountClass: 'simply-amount',
wordClass: 'simply-word',
zeroPad: false,
countUp: false
});
let myElement = document.querySelector('.my-countdown');
simplyCountdown(myElement, { });
let multipleElements = document.querySelectorAll('.my-countdown');
simplyCountdown(multipleElements, { });
You can use it with jQuery too (not required)
$('[CSS-SELECTOR]').simplyCountdown({
year: 2019,
month: 6,
day: 28,
...
});
Easy to customize
You can easly customize the countdown using the css theme starter file or create your own like so :
/!\ The following theme template works with default class in parameters.
.simply-countdown {
}
.simply-countdown > .simply-section {
}
.simply-countdown > .simply-section > div {
}
.simply-countdown > .simply-section .simply-amount,
.simply-countdown > .simply-section .simply-word {
}
.simply-countdown > .simply-section .simply-amount {
}
.simply-countdown > .simply-section .simply-word {
}
Contributing
Pull Requests
- Solve a problem
- For code enhancement, use ESLint as a code quality tool.
- Small is better than Big.
Changelog
1.7.0
- Countdowns can be initialized directly with HTML elements with variables like
- document.getElementById
- document.querySelector
- document.querySelectorAll
- etc...
1.6.0
- Compatibility with languages like german for plurals (PR #15), thanks to q30t
1.5.0
- Resolve #10 - Add countup support
- Upgrade yarn dev dependencies
- Some minor code reformatting
1.4.0
- Remove bower support
- migrate from LESS to SASS (scss) / for demo and themes
- migrate lib from ES5 to a really basic ES6
- Remove JSLint support
- Add ESLint support based on customized airbnb rules
1.3.2
zeroPad: false
- fixed Flash of Unstyled Content
1.3.1
- clean some code
- add refresh parameter
refresh: 1000
1.3.0
onEnd: function () {
}
1.2.0
- Resolve #4 - Add UTC support adding enableUtc parameter
enableUtc: true
1.1.1
- Resolve #3 - Remove ID Only compatibility
1.1.0
- Add hours, minutes, seconds in available settings to set the target Date
1.0.1
- Fix console error when not using jQuery
1.0.0