directly display countdown

by extracting the countdown update to a dedicated function we can call it before setting the interval. thus the countdown is updated the instant it is possible instead of needing to wait for the timer interval.
master
lub 5 years ago
parent 5a04be896a
commit 5a1a5261fa

@ -5,7 +5,7 @@ const minute = second*60;
const hour = minute*60;
const day = hour*24;
setInterval(() => {
const update_countdown = () => {
const now = new Date();
const diff = target - now;
@ -23,4 +23,7 @@ setInterval(() => {
document.getElementById(unit).innerHTML = value;
});
}, 500);
};
update_countdown();
setInterval(update_countdown, 500);
Loading…
Cancel
Save