Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                
  <div class="scroller">
  <section>
    <h1>section 1</h1>
  </section>
  <section>
    <h1>section 2</h1>
  </section>
  <section id="animation">
    <div id="main">
      <svg class="absPos" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 300 350" width="100%" height="100%" fill="none" stroke="#fff" stroke-linecap="round" stroke-width="0.5">

        <g class="introAnimDevice">
          <path class="adShape1" fill="rgba(255,255,255,0.4)" stroke="none" d="M104,122H74v-7h30V122z" />
          <path class="adShape2" fill="none" stroke="none" d="M125,95H53V77h72V95z" />
          <path class="adShape3" fill="rgba(255,255,255,0.6)" stroke="none" d="M144,137.32h-27.33V114H144V137.32z" />
          <path class="adShape4" fill="none" stroke="none" d="M144,105.67H36V91h108V105.67z" />
          <path class="adShape5" fill="none" stroke="none" d="M160.33,141.67H133V88h27.33V141.67z" />
          <path class="adShape6" fill="none" stroke="none" d="M160.33,75.67H19V61h141.33V75.67z" />
          <path class="adShape7" fill="none" stroke="none" d="M141,182H39V28h102V182z" />
          <path class="adShape8" fill="none" stroke="none" d="M141,26H39V11h102V26z" />

          <path class="phone phone1" d="M75,86h28c2.76,0,5,2.24,5,5v60c0,2.76-2.24,5-5,5H75 c-2.76,0-5-2.24-5-5V91C70,88.24,72.24,86,75,86z" />
          <path class="phone phone2" d="M72.71,94.2h32.57v53.59H72.71V94.2z" />
          <path class="phone phone3" d="M87.2,149.44h3.6c1.1,0,2,0.9,2,2v0.37c0,1.1-0.9,2-2,2h-3.6 c-1.1,0-2-0.9-2-2v-0.37C85.2,150.34,86.1,149.44,87.2,149.44z" />
          <path class="phone phone4" d="M86.2,88.73h5.6c0.55,0,1,0.31,1,0.69l0,0c0,0.38-0.45,0.69-1,0.69 h-5.6c-0.55,0-1-0.31-1-0.69l0,0C85.2,89.04,85.65,88.73,86.2,88.73z" />
          <path class="phone phone5" d="M75.69,87.09L75.69,87.09c0.75,0,1.35,0.61,1.35,1.37l0,0 c0,0.75-0.61,1.36-1.35,1.36l0,0c-0.75,0-1.35-0.61-1.35-1.36l0,0C74.34,87.7,74.95,87.09,75.69,87.09z" />
          <path class="phone phone6" d="M78.96,87.64L78.96,87.64c0.45,0,0.81,0.37,0.81,0.82l0,0 c0,0.45-0.36,0.82-0.81,0.82l0,0c-0.45,0-0.81-0.37-0.81-0.82l0,0C78.14,88.01,78.5,87.64,78.96,87.64z" />

          <path class="tablet tablet1" d="M51,64h75.63c2.76,0,5,2.24,5,5v102.99c0,2.76-2.24,5-5,5H51c-2.76,0-5-2.24-5-5V69C46,66.24,48.24,64,51,64z" />
          <path class="tablet tablet2" d="M50.41,73.71h76.8v93.57h-76.8V73.71z" />
          <path class="tablet tablet3" d="M88.61,169.05h1.3c1.1,0,2,0.9,2,2v1.3c0,1.1-0.9,2-2,2h-1.3c-1.1,0-2-0.9-2-2v-1.3 C86.61,169.95,87.51,169.05,88.61,169.05z" />
          <path class="tablet tablet4" d="M89.37,67.53h0.21c0.55,0,1,0.45,1,1v0.21c0,0.55-0.45,1-1,1h-0.21c-0.55,0-1-0.45-1-1v-0.21 C88.37,67.98,88.82,67.53,89.37,67.53z" />
          <path class="tablet tablet5" d="M53.06,65.32L53.06,65.32L53.06,65.32L53.06,65.32z" />
          <path class="tablet tablet6" d="M59.24,66.21L59.24,66.21L59.24,66.21L59.24,66.21z" />

          <path class="laptop laptop1" d="M20.4,75h138.65c0.55,0,1,0.45,1,1v94h-1H20.4h-1V76C19.4,75.45,19.85,75,20.4,75z" />
          <path class="laptop laptop2" d="M23.21,78.8h133.04v84.89H23.21V78.8z" />
          <path class="laptop laptop3" d="M89.09,170.03L89.09,170.03L89.09,170.03L89.09,170.03z" />
          <path class="laptop laptop4" d="M90,75.7L90,75.7c0.55,0,1,0.45,1,1l0,0c0,0.55-0.45,1-1,1l0,0c-0.55,0-1-0.45-1-1l0,0C89,76.15,89.45,75.7,90,75.7z" />
          <path class="laptop laptop5" d="M165.12,178.11c-5.53,0-148.92,0-152.96,0 S8,172.56,8,172.56h64.62l2.53,2.53h27.88l2.53-2.53h64.62C170.19,172.56,170.64,178.11,165.12,178.11z" />
          <path class="laptop laptop6" d="" />

          <path class="desktop desktop1" d="M2,50h173.62c1.1,0,2,0.9,2,2v101.46c0,1.1-0.9,2-2,2H2c-1.1,0-2-0.9-2-2V52C0,50.9,0.9,50,2,50z" />
          <path class="desktop desktop2" d="M4.16,54.16h169.29v92.97H4.16V54.16z" />
          <path class="desktop desktop3" d="M90.2,50.69L90.2,50.69c0.77,0,1.39,0.62,1.39,1.39l0,0c0,0.77-0.62,1.39-1.39,1.39l0,0c-0.77,0-1.39-0.62-1.39-1.39l0,0 C88.81,51.31,89.43,50.69,90.2,50.69z" />
          <path class="desktop desktop4" d="M109.12,178.11c-5.53,0-39.08,0-43.12,0s0.92-3.26,3.67-9.78 C72.33,162,72.62,155,72.62,155h2.53h25.88h2.53c0,0,1.1,10.04,3.31,14.12C110.42,175.67,114.64,178.11,109.12,178.11z" />

          <path class="ooh ooh1" d="M152.9,193.77H27V0h125.9V193.77z" />
          <path class="ooh ooh2" d="M143.43,184.47H36.47V7.75h106.96V184.47z" />
          <path class="ooh ooh3" d="M129,229H53l-0.23-2.97L50.15,194h2.53h76.88h2.53l-2.84,33.18 L129,229z" />

        </g>

      </svg>
    </div>

    <div id="scrollDist"></div>
  </section>
  <section>
    <h1>section 3</h1>
  </section>
  <section>
    <h1>section 4</h1>
  </section>

</div>

              
            
!

CSS

              
                html,
body, #main {
  width: 100%;
  height: 100%;
}

section {
  height: 400px;
}

#main {
  background: radial-gradient(#222 10%, #000 90%);
  position: relative;
}

#scrollDist {
  position: absolute;
  height: 400%;
  top: 0;
}

.scroller, .wrapper {
  height: auto;
}

              
            
!

JS

              
                gsap.set(".introAnim", {
  position: "absolute",
  left: 0,
  top: 0,
  width: "100%",
  height: "100%",
  opacity: 1
});
gsap.set(".introAnimDevice", { x: 65, y: 65 });
gsap.set(".tablet, .laptop, .desktop, .ooh", { opacity: 0 });

let tl = gsap
  .timeline({
    defaults: { duration: 0.67, ease: "expo.inOut" },
    scrollTrigger: {
      trigger: "#animation",
      start: "top top",
      end: "+=1000",
      scrub: 0.5,
      pin: ".scroller",
    }
  })

  .add("tablet", 0.1)
  .to(".phone", { morphSVG: (i) => ".tablet" + (i + 1) }, "tablet")
  .to(".phone5, .phone6", { opacity: 0, morphSVG: ".tablet5" }, "tablet")
  .to(".adShape1", { morphSVG: ".adShape2" }, "tablet")

  .add("laptop", 1.5)
  .to(".phone", { morphSVG: (i) => ".laptop" + (i + 1) }, "laptop")
  .to(".phone3", { opacity: 0, y: -4 }, "laptop")
  .fromTo(
    ".laptop5",
    { scale: 0, transformOrigin: "50% 50%" },
    { scale: 1, opacity: 1 },
    "laptop"
  )
  .to(".adShape1", { morphSVG: ".adShape4" }, "laptop")
  .from(".adShape3", { scale: 0, opacity: 0 }, "laptop")

  .add("desktop", 3)
  .to(".phone1", { morphSVG: ".desktop1" }, "desktop")
  .to(".phone2", { morphSVG: ".desktop2" }, "desktop")
  .to(".phone4", { morphSVG: ".desktop3" }, "desktop")
  .to(
    ".laptop5",
    { morphSVG: { shape: ".desktop4", shapeIndex: 0 }, y: 0.5 },
    "desktop"
  )
  .to(".adShape1", { morphSVG: ".adShape6" }, "desktop")
  .to(".adShape3", { morphSVG: ".adShape5" }, "desktop")

  .add("ooh", 4.5)
  .to(".phone1", { morphSVG: ".ooh1" }, "ooh")
  .to(".phone2", { morphSVG: ".ooh2" }, "ooh")
  .to(".phone4", { scale: 0, y: -48 }, "ooh")
  .to(".laptop5", { morphSVG: ".ooh3", y: 0 }, "ooh")
  .to(".adShape1", { morphSVG: ".adShape8" }, "ooh")
  .to(".adShape3", { morphSVG: ".adShape7", ease: "back.inOut(0.6)" }, "ooh")
  .add("end");

              
            
!
999px

Console