splash.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. $(() => {
  2. const skip = localStorage.getItem('skip-splash');
  3. if (skip && skip == 'true') {
  4. setTimeout(() => {
  5. $('#splash').addClass('none');
  6. }, 200);
  7. } else {
  8. $('#splash-logo').removeClass('hide');
  9. const loaderInterval = loader();
  10. setTimeout(() => {
  11. $('#splash-loader').removeClass('hide');
  12. }, 200);
  13. $('#splash-line-1').removeClass('hide').addClass('anim-typewriter');
  14. $('#splash-line-1').one('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', function() {
  15. $('#splash-line-2').removeClass('hide').addClass('anim-typewriter');
  16. });
  17. $('#splash-line-2').one('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', function() {
  18. $('#splash-line-3').removeClass('hide').addClass('anim-typewriter');
  19. });
  20. $('#splash-line-3').one('animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd', function() {
  21. clearInterval(loaderInterval);
  22. $('#splash').addClass('none');
  23. });
  24. }
  25. });
  26. const spinner = {
  27. interval:80,
  28. frames:[
  29. "[        ]",
  30. "[=       ]",
  31. "[==      ]",
  32. "[===     ]",
  33. "[====    ]",
  34. "[=====   ]",
  35. "[ =====  ]",
  36. "[  ===== ]",
  37. "[   =====]",
  38. "[    ====]",
  39. "[     ===]",
  40. "[      ==]",
  41. "[       =]",
  42. "[        ]",
  43. "[       =]",
  44. "[      ==]",
  45. "[     ===]",
  46. "[    ====]",
  47. "[   =====]",
  48. "[  ===== ]",
  49. "[ =====  ]",
  50. "[=====   ]",
  51. "[====    ]",
  52. "[===     ]",
  53. "[==      ]",
  54. "[=       ]"]
  55. }
  56. function loader() {
  57. const grid = document.getElementById('splash-loader')
  58. const spin = document.createElement('div');
  59. spin.innerText = spinner.frames[0];
  60. grid.appendChild(spin);
  61. let i = 0;
  62. return setInterval(() => {
  63. requestAnimationFrame(() => {
  64. spin.innerHTML = spinner.frames[++i % spinner.frames.length];
  65. });
  66. }, spinner.interval);
  67. }