xmove01

animateBrilliant

Oct 6th, 2022 (edited)
650
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function animateBrilliant() {
  2.   if (window.screen.width >= 1024) {
  3.     gsap.registerPlugin(ScrollTrigger);
  4.     var tl = gsap.timeline({
  5.       scrollTrigger: {
  6.         trigger: ".banner__video",
  7.         scrub: true,
  8.         pin: true,
  9.         invalidateOnRefresh: true
  10.       },});
  11.     tl.to(".banner__video", {
  12.         x: () => {
  13.           let cStart = document.querySelector(".banner__video").getBoundingClientRect();
  14.           let cEnd = document.querySelector(".services__video").getBoundingClientRect();
  15.           return (cStart.x - cEnd.x) * -1;
  16.         },
  17.         y: () => {
  18.           let cStart = document.querySelector(".banner__video").getBoundingClientRect();
  19.           let cEnd = document.querySelector(".services__video").getBoundingClientRect();
  20.           return cEnd.y - cStart.y - cEnd.height;
  21.         },
  22.         ease: "none",
  23.         duration: 5
  24.       });
  25.     tl.to(".services__video", {
  26.       duration: 0,
  27.       opacity: 1,
  28.     });
  29.     tl.to(".services__station_glow", {
  30.       duration: 0,
  31.       opacity: 1,
  32.     });
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment