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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 id="one" class="description panel blue">
    <div><h1>Navigation links with smooth scrolling</h1>
      <p>ScrollTrigger works great with navigation links within the page! Try clicking one of the links above and see how ScrollTrigger stays perfectly synced.</p>
      <div class="scroll-down">Scroll down<div class="arrow"></div></div>

  <section id="two" class="panel red">
    <p><span class="line line-1"></span>This line's animation will begin when it enters the viewport and finish when its top edge hits the top of the viewport, staying perfectly in sync with the scrollbar because it has <code>scrub:&nbsp;true</code></p>

  <section id="three" class="panel orange">
    <p><span class="line line-2"></span>This orange panel gets pinned when its top edge hits the top of the viewport, then the line's animation is linked with the scroll position until it has traveled 100% of the viewport's height (<code>end: "+=100%"</code>), then the orange panel is unpinned and normal scrolling resumes. Padding is added automatically to push the rest of the content down so that it catches up with the scroll when it unpins. You can set <code>pinSpacing: false</code> to prevent that if you prefer.</p>

  <section id="four" class="panel purple">
    <p><span class="line line-3"></span>This panel gets pinned in a similar way, and has a more involved animation that's wrapped in a timeline, fading the background color and animating the transforms of the paragraph in addition to the line, all synced with the scroll position perfectly.</p>

<section id="five" class="panel gray">

  <div><a href="#one">Section one</a></div>
  <div><a href="#two">Section two</a></div>
  <div><a href="#three">Section three</a></div>
  <div><a href="#four">Section four</a></div>
  <div><a href="#five">Section five</a></div>

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


                .line {
  width: 100%;
  max-width: 800px;
  height: 8px;
  margin: 0 0 10px 0;
  position: relative;
  display: inline-block;
  background-color: rgba(255,255,255,1);

/* Not great browser support :(
html {
  scroll-behavior: smooth;
nav {
  position: fixed;
  top: 10px;
  right: 10px;
  background: black;
  padding: 0px 10px;
nav a {
  color: white;
  font-size: 1.3em;
  line-height: 1.7;
  text-decoration: none;
nav a:hover {
  text-decoration: underline;



                gsap.registerPlugin(ScrollTrigger, ScrollToPlugin);

// --- RED PANEL ---
gsap.from(".line-1", {
  scrollTrigger: {
    trigger: ".line-1",
    scrub: true,
    start: "top bottom",
    end: "top top"
  scaleX: 0,
  transformOrigin: "left center", 
  ease: "none"

// --- ORANGE PANEL ---
gsap.from(".line-2", {
  scrollTrigger: {
    trigger: ".orange",
    scrub: true,
    pin: true,
    start: "top top",
    end: "+=100%"
  scaleX: 0, 
  transformOrigin: "left center", 
  ease: "none"

var tl = gsap.timeline({
    scrollTrigger: {
      trigger: ".purple",
      scrub: true,
      pin: true,
      start: "top top",
      end: "+=100%"

tl.from(".purple p", {scale: 0.3, rotation:45, autoAlpha: 0, ease: "power2"})
  .from(".line-3", {scaleX: 0, transformOrigin: "left center", ease: "none"}, 0)
  .to(".purple", {backgroundColor: "#28a92b"}, 0);

gsap.utils.toArray("nav a").forEach(function(a) {
  a.addEventListener("click", function(e) {
    e.preventDefault();, {duration: 1, scrollTo:"href")});

// possible solution for old iOS bugs that don't display things inside an iframe correctly. Create a --full-height CSS variable and use it instead of height: 100%
// function readHeight() {
// 		if (ScrollTrigger.isScrolling()) {
// 			console.log("wait until end...");
// 			ScrollTrigger.addEventListener("scrollEnd", readHeight);
// 		} else {
// 			ScrollTrigger.removeEventListener("scrollEnd", readHeight);
// 			window.removeEventListener("resize", readHeight);
// 			let scrollFunc = ScrollTrigger.getScrollFunc(window),
// 				scrollProgress = scrollFunc() / ScrollTrigger.maxScroll(window),
// 				docStyle =,
// 				bodyStyle =;
// 			bodyStyle.overflow = "auto";
// 			docStyle.setProperty("--full-height", "100%");
// 			docStyle.setProperty("--full-height", window.innerHeight + "px");
// 			bodyStyle.overflow = "unset";
// 			setTimeout(function() {
// 				window.addEventListener("resize", readHeight);
// 			}, 500);
// 			ScrollTrigger.refresh(true);
// 			scrollFunc(scrollProgress * ScrollTrigger.maxScroll(window));
// 		}
// 	}