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

              
                <h1>Scroll down luv</h1>
<div class="marquee" data-reversed="false">
	<span>Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
</div>
<div class="marquee" data-reversed="true">
	<span>Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
</div>
<div class="marquee" data-reversed="false">
	<span>Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
	<span aria-hidden="true">Oi, oi!</span>
</div>

              
            
!

CSS

              
                body {
	padding: 25vh 0 50vh 0;
	background: #222;
    scroll-behavior: smooth;
	font: 600 8vw/1 "Inter", sans-serif;
}

h1 {
	color: #777;
	display: block;
	font-size: 1.5rem;
	padding: 0 0 35vh 0;
	text-align: center;
	text-transform: uppercase;
}

.marquee {
	display: flex;
	padding: 15px 0;
	margin: 20px 0;
	white-space: nowrap;
	color: #DDD;
	justify-content: flex-end;
	background: #111;
	
	&[data-reversed="true"] {
		justify-content: flex-start;
	}
	
	span {
		display: block;
		padding: 0 1ch;
	}
}
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

let direction = 1;

const duration = 8;
const marquees = document.querySelectorAll(".marquee");
const tl = gsap.timeline({
	repeat: -1,
	yoyo: false,
    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)
    }
});

marquees.forEach(marquee => {
	// This works beacause all the elements inside the marquee wrapper are exactly the same
	tl.to(marquee.querySelectorAll("span"), {
		xPercent: marquee.dataset.reversed === "true" ? -100 : 100,
		repeat: 0,
		ease: "linear",
		duration: duration
	}, "<");
});


let scroll = ScrollTrigger.create({
	onUpdate(self) {
		// Update the direction of the animation based on the direction of scroll
		if (self.direction !== direction) {
			direction *= -1;
		}
		
		// Update the animation speed (duration) based on the scroll speed
		tl.timeScale(duration * self.getVelocity() / 500);
		
		// Go back to the default duration
		gsap.to(tl, {timeScale: direction});	
	}
});
              
            
!
999px

Console