Created
May 11, 2020 09:49
-
-
Save elishaukpong/94f35ba84d5f319cabb5358fbee11412 to your computer and use it in GitHub Desktop.
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
// PRELOADER | |
var width = 100, | |
perfData = window.performance.timing, // The PerformanceTiming interface represents timing-related performance information for the given page. | |
EstimatedTime = -(perfData.loadEventEnd - perfData.navigationStart), | |
time = parseInt((EstimatedTime / 1000) % 60, 10) * 100; | |
var PercentageID = $("#percentage"), | |
start = 0, | |
end = 100, | |
durataion = time; | |
animateValue(PercentageID, start, end, durataion); | |
function animateValue(id, start, end, duration) { | |
var range = end - start, | |
current = start, | |
increment = end > start ? 1 : -1, | |
stepTime = Math.abs(Math.floor(duration / range)), | |
obj = $(id); | |
var timer = setInterval(function() { | |
current += increment; | |
$(obj).text(current); | |
//obj.innerHTML = current; | |
if (current == end) { | |
clearInterval(timer); | |
} | |
}, stepTime); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment