Advertisement
GochiSiyan

index.html

Jul 6th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <link rel="stylesheet" href="index.css">
  8. <link rel="stylesheet" href="https://unpkg.com/aos@next/dist/aos.css" />
  9. <title>Document</title>
  10. </head>
  11. <body>
  12. <div class="w-screen h-screen">
  13. <div id="custom-loading" class="w-full h-full relative overflow-hidden">
  14. <div class="h-1/2 absolute top-0 left-0 right-0 transition-all duration-1000 top-cover bg-gradient-to-r from-black to-[#0e101f] flex items-end justify-center">
  15. <div class="h-px w-0 transition-all duration-1000 bg-gradient-to-r from-[#1DCFFC] to-[#AD00FF]"></div>
  16. </div>
  17. <div class="h-1/2 bg-black absolute bottom-0 left-0 right-0 transition-all duration-1000 bottom-cover bg-gradient-to-b from-[#0e101f] to-black flex items-start justify-center">
  18. <div class="h-px w-0 transition-all duration-1000 bg-gradient-to-r from-[#1DCFFC] to-[#AD00FF]"></div>
  19. </div>
  20. </div>
  21. </div>
  22.  
  23. <div class="p-5 text-center" data-aos="fade-up" data-aos-duration="1000">
  24. <span class="font bold text-[24px]">Heading</span>
  25. </div>
  26.  
  27. <div class="p-5 text-center" data-aos="fade-up" data-aos-duration="1000">
  28. <span class="text-[16px] w-[200px] block m-auto">this is paragraph text for test animation. this is paragraph text for test animation. this is paragraph text for test animation.</span>
  29. </div>
  30.  
  31. <div class="p-5 text-center">
  32. <span class="font bold text-[24px] ml12">Heading Tester</span>
  33. </div>
  34.  
  35. <script>
  36. (() => {
  37. const sleep = (time = 1000) => {
  38. return new Promise((resolve) => {
  39. setTimeout(() => {
  40. resolve();
  41. }, time);
  42. });
  43. }
  44. window.addEventListener('load', async () => {
  45. const loadingAnimation = document.getElementById('custom-loading');
  46. const topCover = loadingAnimation?.getElementsByClassName('top-cover')[0];
  47. const bottomCover = loadingAnimation?.getElementsByClassName('bottom-cover')[0];
  48. const topLine = topCover?.firstElementChild;
  49. const bottomLine = bottomCover?.firstElementChild;
  50.  
  51. if (loadingAnimation && topCover && bottomCover && topLine && bottomLine) {
  52. await sleep(1000);
  53.  
  54. topLine.classList.remove('w-0');
  55. topLine.classList.add('w-full');
  56. bottomLine.classList.remove('w-0');
  57. bottomLine.classList.add('w-full');
  58.  
  59. await sleep(1300);
  60.  
  61. topCover.classList.add('-translate-y-full');
  62. bottomCover.classList.add('translate-y-full');
  63.  
  64. await sleep(1000);
  65.  
  66. loadingAnimation.remove();
  67. }
  68. });
  69. })();
  70. </script>
  71. <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/2.0.2/anime.min.js"></script>
  72. <script src="https://unpkg.com/aos@next/dist/aos.js"></script>
  73. <script>
  74. AOS.init();
  75. </script>
  76. <script>
  77. (() => {
  78. document.querySelectorAll('.ml12').forEach((el) => {
  79. el.innerHTML = el.textContent.replace(/\S/g, "<span class='letter'>$&</span>");
  80.  
  81. let animation = anime.timeline({loop: false})
  82. .add({
  83. targets: el.querySelectorAll('.letter'),
  84. translateX: [40,0],
  85. translateZ: 0,
  86. opacity: [0,1],
  87. easing: "easeOutExpo",
  88. duration: 1200,
  89. delay: (el, i) => 500 + 30 * i
  90. });
  91.  
  92. let observer = new IntersectionObserver((e) => {
  93. if (e[0].isIntersecting) {
  94. animation.play();
  95. } else {
  96. animation.seek(0);
  97. }
  98. });
  99.  
  100. observer.observe(el);
  101. });
  102. })();
  103. // Wrap every letter in a span
  104. // var observer = new IntersectionObserver((e) => {
  105. // console.log(e);
  106. // });
  107. // console.log(observer);
  108. // var textWrapper = document.querySelector('.ml12');
  109. // textWrapper.innerHTML = textWrapper.textContent.replace(/\S/g, "<span class='letter'>$&</span>");
  110.  
  111. // var animation = anime.timeline({loop: false})
  112. // .add({
  113. // targets: '.ml12 .letter',
  114. // translateX: [40,0],
  115. // translateZ: 0,
  116. // opacity: [0,1],
  117. // easing: "easeOutExpo",
  118. // duration: 1200,
  119. // delay: (el, i) => 500 + 30 * i
  120. // });
  121. </script>
  122. </body>
  123. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement