Last active
January 31, 2019 13:10
-
-
Save laroi/ac0408df6274e755355b7322317d6a49 to your computer and use it in GitHub Desktop.
Gets random fake progress bar values for JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getRandomProgress = () => { | |
let secs = 0; // How many seconds to wait | |
let perc = 0; // How much percentage to update | |
let func = () => { | |
if (perc < 100 ) { // Exit the loop if we reached 100 | |
perc = Math.min((perc + Math.floor(Math.random() * 40)), 100); //Get the random percentage, make sure it is less than 100 | |
secs += Math.ceil(Math.random()*2); // Get random Time | |
(function(_perc, _secs) { | |
return setTimeout(function(){/*update dom here*/console.log(_perc, _secs)}, _secs*1000); | |
})(perc, secs) | |
func(); | |
} | |
} | |
return func() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment