Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>sample</title>
  <link rel="stylesheet" href="styles.css">
  <link href="https://fonts.googleapis.com/css2?family=Caveat&display=swap" rel="stylesheet">
</head>
<body>
  <div class="loading-container" id="loading-container">
    <img src="src/topleftcl.png" alt="Cloud 1" class="cloud top-left">
    <img src="src/toprightcl.png" alt="Cloud 2" class="cloud top-right">
    <img src="src/btmlftcl.png" alt="Cloud 3" class="cloud bottom-left">
    <img src="src/btmrightcl.png" alt="Cloud 4" class="cloud bottom-right">
  </div>
  <div class="main-container" id="container" style="display: none;">
    <div class="left-container">
      <div class="image-wrapper">
        <picture>
          <source id="animation-frame-webp" type="image/webp">
          <img id="animation-frame" alt="Animation Frame" loading="lazy">
        </picture>
        <div class="watermark">Sea</div>
        <div class="overlay"></div>
      </div>
    </div>
    <div class="right-container">
      <img src="src/title.png" alt="Title Image" class="title-image">
      <img src="src/sub.png" alt="Sub Image" class="sub-image">
      <div class="sub-text">
        <p>“SEA</p>
       
        <p>This creative endeavor sets the stage for a world rich in collectibles, toys, animations, and storytelling.</p>
      </div>
      <img src="src/banner.png" alt="Banner Image" class="banner-image">
    </div>
  </div>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollTrigger.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/ScrollToPlugin.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bodymovin/5.7.4/lottie.min.js"></script>
  <script src="src/animation.js"></script>
  <script src="src/index.js"></script>
</body>
</html>

              
            
!

CSS

              
                body, html {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    font-family: Arial, sans-serif;
    height: 200%;
    background-color: #010cae;
    scroll-behavior: smooth;
  }
  
  .loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #010cae;
    z-index: 10;
  }
  
  .cloud {
    position: absolute;
    width: 110%;
    transition: transform 30s ease-out;
  }
  
  .top-left {
    top: 0;
    left: 0;
  }
  
  .top-right {
    top: 0;
    right: 0;
  }
  
  .bottom-left {
    bottom: 0;
    left: 0;
  }
  
  .bottom-right {
    bottom: 0;
    right: 0;
  }
  
  .main-container {
    display: flex;
    width: 100%;
    height: 100vh;
    padding: 20px;
    position: relative;
  }
  
  .left-container, .right-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
  }
  
  .image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
  }
  
  .image-wrapper img,
  .image-wrapper source {
    display: block;
    max-width: 650px;
    height: auto;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
  }
  
  .image-wrapper .overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    pointer-events: none;
  }
  
  .image-wrapper .watermark {
    display: none;
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
  }
  
  .title-image,
  .sub-image,
  .sub-text,
  .banner-image {
    position: fixed;
    width: 60%;
    margin-left: -20%;
    top: 200%;
  }
  
  .title-image {
    top: 110%;
    margin-bottom: 5px;
    z-index: 10;
  }
  
  .sub-image {
    top: 120%;
    margin-bottom: 5px;
    z-index: 10;
  }
  
  .sub-text {
    top: 130%;
    max-width: 40%;
    color: rgb(222, 234, 255);
    text-align: justify;
    font-size: 24px;
    font-family: 'Caveat', cursive;
    margin-bottom: 10px;
    z-index: 10;
  }
  
  .banner-image {
    top: 140%;
    max-width: 43%;
    margin-bottom: 10px;
    z-index: 10;
  }
  
  @media (max-width: 768px) {
    .main-container {
      flex-direction: column;
    }
    .left-container, .right-container {
      height: 50vh;
    }
    .image-wrapper img,
    .image-wrapper source,
    .title-image,
    .sub-image,
    .sub-text,
    .banner-image {
      width: 90%;
      left: 5%;
    }
  }
  
  @media (max-width: 480px) {
    .main-container {
      flex-direction: column;
    }
    .left-container, .right-container {
      height: 50vh;
    }
    .image-wrapper img,
    .image-wrapper source,
    .title-image,
    .sub-image,
    .sub-text,
    .banner-image {
      width: 100%;
      left: 0;
    }
  }
  
              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", () => {
    // Scroll to the top of the page when it loads or refreshes
    window.scrollTo(0, 0);
  
    const frameCount = 150; // Number of images in the sequence
    const initialFrames = 75; // Number of initial frames to preload
    const images = [];
    const imageElement = document.getElementById("animation-frame");
    const imageElementWebP = document.getElementById("animation-frame-webp");
    const loadingContainer = document.getElementById("loading-container");
    const container = document.getElementById("container");
    const titleImage = document.querySelector(".title-image");
    const subImage = document.querySelector(".sub-image");
    const subText = document.querySelector(".sub-text");
    const bannerImage = document.querySelector(".banner-image");
    let initialFramesLoaded = false;
  
    // Preload images
    const preloadImages = () => {
      let loadedImages = 0;
  
      for (let i = 301; i <= 450; i++) {
        const imgWebP = new Image();
        imgWebP.src = `src/optimized/SBS_Play_Skateboard_${i.toString().padStart(4, '0')}.webp`;
        imgWebP.loading = i <= 301 + initialFrames - 1 ? 'eager' : 'lazy';
        imgWebP.onload = () => {
          loadedImages++;
          if (loadedImages === initialFrames && !initialFramesLoaded) {
            // Initial frames are loaded
            initialFramesLoaded = true;
            gsap.to(clouds, { opacity: 0, duration: 1 });
          }
        };
        imgWebP.onerror = () => {
          console.error(`Failed to load image ${imgWebP.src}`);
          loadedImages++;
          if (loadedImages === initialFrames && !initialFramesLoaded) {
            initialFramesLoaded = true;
            gsap.to(clouds, { opacity: 0, duration: 1 });
          }
        };
        images.push(imgWebP);
      }
    };
  
    // Ensure the loading animation is visible before starting to preload images
    loadingContainer.style.display = 'flex';
    container.style.display = 'none';
    preloadImages();
  
    const initAnimation = () => {
      gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);
  
      const updateAnimation = (progress) => {
        const frameIndex = Math.floor(progress * (frameCount - 1));
        imageElement.src = images[frameIndex].src;
        imageElementWebP.srcset = images[frameIndex].src;
      };
  
      const totalScrollDistance = document.body.scrollHeight - window.innerHeight;
  
      gsap.to({}, {
        scrollTrigger: {
          trigger: ".main-container",
          start: "top top",
          end: `+=${totalScrollDistance}`,
          scrub: 1.5, // Set scrub to a higher value for smoother and more controlled scroll
          pin: true,
          anticipatePin: 1,
          snap: {
            snapTo: 1 / frameCount, // Snap to the closest frame
            duration: { min: 0.2, max: 0.5 }, // Adjust the snapping speed
            ease: "power3.inOut" // Ease for snapping
          },
          onUpdate: self => {
            const progress = self.progress;
            requestAnimationFrame(() => updateAnimation(progress));
          }
        }
      });
  
      gsap.to(titleImage, {
        y: "-250vh", // Move title image up out of the viewport
        ease: "none",
        scrollTrigger: {
          trigger: ".main-container",
          start: "top top+=100", // Start slightly after the user begins scrolling
          end: `+=${totalScrollDistance / 1}`,
          scrub: true
        }
      });
  
      gsap.to(subImage, {
        y: "-250vh", // Move sub image up out of the viewport
        ease: "none",
        scrollTrigger: {
          trigger: ".main-container",
          start: "top top+=100", // Start slightly after the user begins scrolling
          end: `+=${totalScrollDistance / 1}`,
          scrub: true
        }
      });
  
      gsap.to(subText, {
        y: "-250vh", // Move sub text up out of the viewport
        ease: "none",
        scrollTrigger: {
          trigger: ".main-container",
          start: "top top+=100", // Start slightly after the user begins scrolling
          end: `+=${totalScrollDistance / 1}`,
          scrub: true
        }
      });
  
      gsap.to(bannerImage, {
        y: "-250vh", // Move banner image up out of the viewport
        ease: "none",
        scrollTrigger: {
          trigger: ".main-container",
          start: "top top+=100", // Start slightly after the user begins scrolling
          end: `+=${totalScrollDistance / 1}`,
          scrub: true
        }
      });
    };
  
    // Animate clouds on scroll
    gsap.registerPlugin(ScrollTrigger);
  
    const cloudAnimation = gsap.timeline({
      scrollTrigger: {
        trigger: ".loading-container",
        start: "top top",
        end: "bottom top",
        scrub: true,
        onUpdate: self => {
          if (initialFramesLoaded) {
            gsap.to(".cloud", { autoAlpha: 0, ease: "power1.inOut" });
          }
        },
        onEnter: () => {
          loadingContainer.style.display = 'none';
          container.style.display = 'flex';
          initAnimation();
        }
      }
    });
  
    cloudAnimation
      .to(".top-left", { duration: 15, x: "-50%", y: "-50%", scale: 2, ease: "power3.inOut" })
      .to(".top-right", { duration: 15, x: "50%", y: "-50%", scale: 2, ease: "power3.inOut" }, 0)
      .to(".bottom-left", { duration: 15, x: "-50%", y: "50%", scale: 2, ease: "power3.inOut" }, 0)
      .to(".bottom-right", { duration: 15, x: "50%", y: "50%", scale: 2, ease: "power3.inOut" }, 0)
      .to(".top-left", { duration: 15, x: "-100%", y: "-100%", scale: 4, ease: "power3.inOut" })
      .to(".top-right", { duration: 15, x: "100%", y: "-100%", scale: 4, ease: "power3.inOut" }, 15)
      .to(".bottom-left", { duration: 15, x: "-100%", y: "100%", scale: 4, ease: "power3.inOut" }, 15)
      .to(".bottom-right", { duration: 15, x: "100%", y: "100%", scale: 4, ease: "power3.inOut" }, 15)
      .to(".top-left", { duration: 15, x: "-150%", y: "-150%", scale: 6, ease: "power3.inOut" })
      .to(".top-right", { duration: 15, x: "150%", y: "-150%", scale: 6, ease: "power3.inOut" }, 30)
      .to(".bottom-left", { duration: 15, x: "-150%", y: "150%", scale: 6, ease: "power3.inOut" }, 30)
      .to(".bottom-right", { duration: 15, x: "150%", y: "150%", scale: 6, ease: "power3.inOut" }, 30);
  });
  
  // Ensure scroll position is reset to the top before the page unloads (refresh or navigate away)
  window.addEventListener("beforeunload", () => {
    window.scrollTo(0, 0);
  });
  
              
            
!
999px

Console