JSFiddle - React, Tailwind, and code Playground
by pierian_design
JavaScript
/*var percent = 17;
var end = 55;
var duration = 1000;
var step = 1.1;
var interval = setInterval(function() {
console.log(percent);
console.log(duration);
percent += 1;
if (percent >= end) {
clearInterval(interval);
console.log('PRELOADER');
return;
}
duration = duration * step;
}, duration);*/
var percent = 17;
var end = 55;
let timeout = 1000;
var step = 1.1;
let intervalId = setInterval(callback, timeout);
function callback () {
console.log('Do something here', new Date());
console.log('SET PERCENT', percent);
console.log('----------------------------------------------');
percent += 1;
clearInterval(intervalId);
timeout *= 2;
if (percent >= end) {
//preloader
} else {
intervalId = setInterval(callback, timeout);
}
}