techhjork

Barbajs

Jul 15th, 2020
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  
  5. </head>
  6.  
  7. <body data-barba="wrapper">
  8. <div class="load-container">
  9. <div class="loading-screen"></div>
  10. </div>
  11. <main data-barba="container" data-barba-namespace="about-section">
  12. <div class="header">
  13. <h1 class="title animate-this">
  14. about page
  15. </h1>
  16. <div class="animate-this button">
  17. <a href="index.html">go back to home</a>
  18. </div>
  19. </div>
  20. </main>
  21. </body>
  22.  
  23. <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
  24. <!-- <script src="https://unpkg.com/@barba/core"></script> -->
  25. <script src="https://cdnjs.cloudflare.com/ajax/libs/barba.js/1.0.0/barba.min.js" integrity="sha512-7b1FfB2MGnB65aK6jrbS8k3REB+8bEE8UfP/TEwacejD0g02nLLI1VL4IPcKyiLk2lf7HJWaUYEUWc65aqaXQg==" crossorigin="anonymous"></script>
  26. <script
  27. type="text/javascript"
  28. src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.4/gsap.min.js"
  29. ></script>
  30. <script src="main.js"></script>
  31. </html>
  32.  
  33.  
  34.  
  35. function delay(n) {
  36. n = n || 2000;
  37. return new Promise((done) => {
  38. setTimeout(() => {
  39. done();
  40. }, n);
  41. });
  42. }
  43.  
  44. function pageTransition() {
  45. var tl = gsap.timeline();
  46. tl.to(".loading-screen", {
  47. duration: 1.2,
  48. width: "100%",
  49. left: "0%",
  50. ease: "Expo.easeInOut",
  51. });
  52.  
  53. tl.to(".loading-screen", {
  54. duration: 1,
  55. width: "100%",
  56. left: "100%",
  57. ease: "Expo.easeInOut",
  58. delay: 0.3,
  59. });
  60. tl.set(".loading-screen", { left: "-100%" });
  61. }
  62.  
  63. function contentAnimation() {
  64. var tl = gsap.timeline();
  65. tl.from(".animate-this", { duration: 1, y: 30, opacity: 0, stagger: 0.4, delay: 0.2 });
  66. }
  67.  
  68.  
  69. $(function () {
  70. barba.init({
  71. debug:true,
  72. sync: true,
  73. transitions: [
  74. {
  75. async leave(data) {
  76. const done = this.async();
  77.  
  78. pageTransition();
  79. await delay(1000);
  80. done();
  81. },
  82.  
  83. async enter(data) {
  84. contentAnimation();
  85. },
  86.  
  87. async once(data) {
  88. contentAnimation();
  89. },
  90. },
  91. ],
  92. });
  93. });
Add Comment
Please, Sign In to add comment