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

              
                <div style="height: 50vh; background-color:gray"></div>
<div id="section">
  
  <div id="text1" class="myText">
    Text 1
  </div>
  
  <div id="text2" class="myText">
     Text 2
  </div>
  <div id="text3" class="myText">
     Text 3
  </div>

</div>

 <div style="height: 50vh; background-color:gray"></div>

              
            
!

CSS

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

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

.myText{
  position:absolute;
  top:50%;
  transform: translate(0, -50%);
  color:white;
  font-size:50px;
  opacity:0
}

#section{
  position:relative;
  height:50vh;
  widht:100vw;
  background-color:black;
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger, Observer);
console.clear();

let tl1 = gsap.timeline();
tl1.to("#text1", {left:"50%", opacity:1, duration:4});

let tl2 = gsap.timeline();
tl2.to("#text2", {left:"60%", opacity:1, duration:4});

let tl3= gsap.timeline();
tl3.to("#text3",  {left:"70%", opacity:1, duration:4});

// drop each timeline into a master so that we can add a pause inbetween
let masterTL = gsap.timeline({
  onReverseComplete: () => {
    scrollObserver.disable();
    sectionST.scroll(sectionST.start);
  },
  onComplete: () => {
    scrollObserver.disable();
    sectionST.scroll(sectionST.end);
  },
  paused: true
});
masterTL.add(tl1, "label1")
  .addPause()
  .add(tl2, "label2")
  .addPause()
  .add(tl3, "label3");

// create an observer that freezes the scroll and plays/reverses the master timeline based on scroll direction
let scrollObserver = Observer.create({
  type: "wheel,touch",
  wheelSpeed: -1,
  debounce: false,
  dragMinimum: 2,
  preventDefault: true,
  onUp: () => masterTL.play(),
  onDown: () => masterTL.reverse(),
  onEnable(self) {
    // when enabling, we should save the scroll position and freeze it. This fixes momentum-scroll on Macs, for example.
    let savedScroll = self.scrollY();
    self._restoreScroll = (e) => self.scrollY(savedScroll)
    document.addEventListener("scroll", self._restoreScroll, {passive: false});
  },
  onDisable(self) {
    document.removeEventListener("scroll", self._restoreScroll);
  }
});
scrollObserver.disable();

let sectionST = ScrollTrigger.create({
  trigger: "#section",
  start: "bottom center",
  end: "+=300",
  onEnter: self => {
    self.scroll(self.start + 1);
    masterTL.progress() < 1 && scrollObserver.enable();
  },
  onEnterBack: self => {
    self.scroll(self.end - 1);
    masterTL.progress() > 0 && scrollObserver.enable();
  },
  onLeave: () => scrollObserver.disable(),
  onLeaveBack: () => scrollObserver.disable(),
  markers: true,
  pin: true
});

              
            
!
999px

Console