Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- /* --------------------------------------------------------- */
- // Page Loading progress bar/line
- var perfData = window.performance.timing,
- EstimatedTime = -(perfData.loadEventEnd - perfData.navigationStart),
- time = parseInt((EstimatedTime / 1000) % 60) * 100;
- // Percentage Increment Animation
- var progress_line = document.querySelector('.progress-line'),
- start = 0,
- end = 100,
- duration = time;
- animateValue(progress_line, start, end, duration);
- 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.style.height = current + '%';
- if (current == end) {
- clearInterval(timer);
- }
- }, stepTime);
- }
- // Swith classnames on Finised
- setTimeout(function() {
- document.documentElement.classList.remove('loading');
- document.documentElement.classList.add('loaded');
- }, time);
- /* --------------------------------------------------------- */
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement