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. 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

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="limits"></div>
<div class="half"></div>

<div class="wrapperRollingText">
  <div class="rollingText text">
    <span>• GreenSock •</span> Ultra high-performance, professional-grade animation for the modern web
  </div>
</div>

<div class="wrapperRollingText02"l>
  <div class="rollingText02 text">
    <span>• GreenSock •</span> Ultra high-performance, professional-grade animation for the modern web
  </div>
</div>

<h2>Just scroll ...</h2>
              
            
!

CSS

              
                
body{
  background:grey;
  height:300vh;
  margin:0;
  overflow-x:hidden;
}
h2{
  position:fixed;
  top:0;
  width:100%;
  background:grey;
  font-size: 20px;
  font-family:sans-serif;
  color: #b5b5b5;
  margin: 0;
  line-height: 2;
  text-align: center;
}
.wrapperRollingText {
  white-space: nowrap;
  font-family: 'Playfair Display', serif;
  margin-top: 100vh;
  border-top: 1px solid #6f6f6f;
  
}
.rollingText {
  font-size: 6vw;
  display: inline-block;
  padding-left: 10px;
}
.wrapperRollingText02 {
  white-space: nowrap;
  font-family: 'Playfair Display', serif;
  margin-top: 10px;
}
.rollingText02 {
  font-size: 6vw;
  display: inline-block;
  padding-left: 13px;
}
span{
  font-family:sans-serif;
  font-weight:600;
  color:green;
}

.limits{
  position: fixed;
  top: 20vh;
  height: 50vh;
  width: 100px;
  border-top: 1px solid #6f6f6f;
  border-bottom: 1px solid #6f6f6f;
}
.half{
  position: fixed;
  top: 50vh;
  width: 100px;
  border-top: 1px solid green;
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

let direction = 1; // 1 = forward, -1 = backward scroll

const roll1 = roll(".rollingText", {duration: 10}),
      roll2 = roll(".rollingText02", {duration: 10}, true),
      scroll = ScrollTrigger.create({
        onUpdate(self) {
          if (self.direction !== direction) {
            direction *= -1;
            gsap.to([roll1, roll2], {timeScale: direction, overwrite: true});
          }
        }
      });

// helper function that clones the targets, places them next to the original, then animates the xPercent in a loop to make it appear to roll across the screen in a seamless loop.
function roll(targets, vars, reverse) {
  const tl = gsap.timeline({
    repeat: -1,
    onReverseComplete() { 
      this.totalTime(this.rawTime() + this.duration() * 10); // otherwise when the playhead gets back to the beginning, it'd stop. So push the playhead forward 10 iterations (it could be any number)
    }
  });
  vars = vars || {};
  vars.ease || (vars.ease = "none");
  gsap.utils.toArray(targets).forEach(el => {
    let clone = el.cloneNode(true);
    el.parentNode.appendChild(clone);
    gsap.set(clone, {position: "absolute", top: el.offsetTop, left: el.offsetLeft + (reverse ? -el.offsetWidth : el.offsetWidth)});
    tl.to([el, clone], {xPercent: reverse ? 100 : -100, ...vars}, 0);
  });
  return tl;
}
              
            
!
999px

Console