JSFiddle - React, Tailwind, and code Playground

by pierian_design

JavaScript

var percent     = 17;
var end       = 55;
var duration  = 10000; // In milliseconds (divide by 1000 to get seconds).
var step = 1.1;    // In milliseconds (divide by 1000 to get seconds).

var interval = setInterval(function() {
  console.log(percent);
  percent += 1;

  if (percent >= end) {
      clearInterval(interval);
      console.log('PRELOADER');
    return;
  }

  duration = duration * step;
}, duration);