Travis build: 2032

This commit is contained in:
30secondsofcode
2018-05-06 14:57:19 +00:00
parent 95a121a832
commit dd547e5167
13 changed files with 69 additions and 20 deletions

View File

@ -10,15 +10,15 @@ Omit the fifth parameter, `duration`, to use a default duration of `2000`ms.
```js
const counter = (selector, start, end, step = 1, duration = 2000) => {
let current = start,
_step = (end - start) * step < 0 ? -step : step,
timer = setInterval(() => {
current += _step;
document.querySelector(selector).innerHTML = current;
if (current >= end) document.querySelector(selector).innerHTML = end;
if (current >= end) clearInterval(timer);
}, Math.abs(Math.floor(duration / (end - start))));
return timer;
let current = start,
_step = (end - start) * step < 0 ? -step : step,
timer = setInterval(() => {
current += _step;
document.querySelector(selector).innerHTML = current;
if (current >= end) document.querySelector(selector).innerHTML = end;
if (current >= end) clearInterval(timer);
}, Math.abs(Math.floor(duration / (end - start))));
return timer;
};
```