Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. (function() {
  2. /* --------------------------------------------------------- */
  3. // Page Loading progress bar/line
  4. var perfData = window.performance.timing,
  5. EstimatedTime = -(perfData.loadEventEnd - perfData.navigationStart),
  6. time = parseInt((EstimatedTime / 1000) % 60) * 100;
  7.  
  8. // Percentage Increment Animation
  9. var progress_line = document.querySelector('.progress-line'),
  10. start = 0,
  11. end = 100,
  12. duration = time;
  13.  
  14. animateValue(progress_line, start, end, duration);
  15.  
  16. function animateValue(id, start, end, duration) {
  17. var range = end - start,
  18. current = start,
  19. increment = end > start ? 1 : -1,
  20. stepTime = Math.abs(Math.floor(duration / range)),
  21. obj = id;
  22.  
  23. var timer = setInterval(function() {
  24. current += increment;
  25. obj.style.height = current + '%';
  26. if (current == end) {
  27. clearInterval(timer);
  28. }
  29. }, stepTime);
  30. }
  31. // Swith classnames on Finised
  32. setTimeout(function() {
  33. document.documentElement.classList.remove('loading');
  34. document.documentElement.classList.add('loaded');
  35. }, time);
  36.  
  37. /* --------------------------------------------------------- */
  38. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement