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

              
                <section id="section1">
	<div class="content blue"><h2>Section 1</h2></div>
	<div class="content"></div>
	<div class="content"></div>
	<div class="content"></div>
</section>

<section id="section2">
	<div class="content red"><h2>Section 2</h2></div>
	<div class="content"></div>
	<div class="content"></div>
	<div class="content"></div>
</section>

<section id="section3">
	<div class="content blue"><h2>Section 3</h2></div>
	<div class="content">test content</div>
	<div class="content"></div>
	<div class="content"></div>
</section>

<section id="section4">
	<div class="content red"><h2>Section 4</h2></div>
	<div class="content"></div>
	<div class="content"></div>
	<div class="content"></div>
</section>

    
<div class="anchors">
  <span data-link="#section1">Anchor 1</span>
  <span data-link="#section2">Anchor 2</span>
  <span data-link="#section3">Anchor 3</span>
  <span data-link="#section4">Anchor 4</span> 
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap');

html {
  margin: 0;
}

body { 
  font-family: "Signika Negative", sans-serif; 
  font-weight: 300;
  margin: 0;
  padding: 0 20px;
}

section {
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.content {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

h2 {
  font-size: 60px;
  color: #fff;
}

.blue {
  background-color: blue;
}

.red {
  background-color: red;
}

.square {
  width: 100px;
  height: 100px;
  background-color: black;
}

.anchors {
  position: fixed;
  top: 50%;
  right: 40px;
  display: flex;
  flex-direction: column;
  transform: translateY(-50%);
  
  span {
    display: block;
    color: #fff;
    padding: 20px;
    cursor: pointer;
  }
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);

let sections = gsap.utils.toArray("section");
sections.forEach(section => {
  gsap.to(section.querySelector("h2"), {
    rotation: 360,
    ease: "none",
    scrollTrigger: {
      trigger: section,
      pin: true,
      scrub: 1,
      onUpdate: killWhenFast,
      end: () => "+=" + window.innerHeight * sections.length
    }
  });
});

// when the scroll velocity is more than 2500px/second, skip the smooth scrubbing
function killWhenFast(self) {
  let tween = self.getTween();
  tween && Math.abs(self.getVelocity()) > 2500 && tween.progress(1);
}


gsap.utils.toArray(".anchors [data-link]").forEach(el => {
  el.addEventListener("click", event => {
    gsap.to(window, {scrollTo: event.target.getAttribute("data-link")});
  });
});







// if disabled is true, don't allow the ScrollTrigger's animation to render at any progress other than 0 or 1.
// function checkDisabled(self) {
//   if (disabled) {
//     let tween = self.getTween();
//     tween && tween.progress(1); // in case there's a scrub attached
//     self.animation.progress(self.progress === 1 ? 1 : 0);
//   }
// }
              
            
!
999px

Console