Pen Settings



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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


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


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.


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.


                <div class="description panel blue">
  <div><h1>Layered pinning with infinite looping</h1>
    <p>Use pinning to layer panels on top of each other as you scroll.</p>
    <div class="scroll-down">Scroll down<div class="arrow"></div></div>

<section class="panel red">
<section class="panel orange">
<section class="panel purple">
<section class="panel green">

   <a href="">
     <img class="greensock-icon" src="" width="200" height="64" />





let panels = gsap.utils.toArray(".panel"),
    copy = panels[0].cloneNode(true);
panels[0].parentNode.appendChild(copy); // copy the first panel to the end (for seamless looping)

panels.forEach((panel, i) => {
    trigger: panel,
    start: "top top", 
    pin: true, 
    pinSpacing: false 

let maxScroll;
let pageScrollTrigger = ScrollTrigger.create({ // snap whole page to the closest section!
  // normally we'd just do snap: 1 / panels.length but we'll use a function-based value so that we can handle the very start and end values in a special way to prevent looping on the snap
  snap(value) {
    let snappedValue = gsap.utils.snap(1 / panels.length, value);
    if (snappedValue <= 0) { // don't let it go all the way back to exactly 0 or it'll wrap. Keep it a bit more than 1px from the top.
      return 1.05 / maxScroll;
    } else if (snappedValue >= 1) { // don't let it go all the way to the end or it'll wrap. Keep it a bit more than 1px from the bottom. 
      return maxScroll / (maxScroll + 1.05);
    return snappedValue;
function onResize() {
  maxScroll = ScrollTrigger.maxScroll(window) - 1;
window.addEventListener("resize", onResize);
// make sure we use a non-passive event listener so that we can preventDefault() on the scroll if it's at the very top or bottom
window.addEventListener("scroll", e => {
  let scroll = pageScrollTrigger.scroll()
  if (scroll > maxScroll) {
  } else if (scroll < 1) {
    pageScrollTrigger.scroll(maxScroll - 1);
}, {passive: false});