Pen Settings



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


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.


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.


                <div class="wrapper d-flex flex-nowrap">
	<section class="section section--large flex-shrink-0 d-flex line-right">text</section>
	<section class="section section--small flex-shrink-0 d-flex line-right">text</section>
	<section class="section section--small flex-shrink-0 d-flex line-right">text</section>
	<section class="section section--large flex-shrink-0 d-flex">text</section>

<div class="drag-proxy"></div>


                * {

body {
	overflow-x: hidden;
.section--large {
  width: 100vw;
  background-color: #ffd103;

.section--small {
  background-color: #ffd103;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 400px;
  width: 40vw;
  max-width: 600px;
  margin: 0 auto;
  position: relative;

.line-right {
	border-right:1px solid #000000;

.drag-proxy {
	  visibility: hidden;
	  position: absolute;

html, body {
  scroll-behavior: auto !important;


                gsap.registerPlugin(ScrollTrigger, Draggable);

const sections = gsap.utils.toArray("section");
let maxWidth = 0;

const getMaxWidth = () => {
  maxWidth = 0;
  sections.forEach((section) => {
	maxWidth += section.offsetWidth;
ScrollTrigger.addEventListener("refreshInit", getMaxWidth);

let scrollTween =, {
  x: () => `-${maxWidth - window.innerWidth}`,
  ease: "none",

let horizontalScroll = ScrollTrigger.create({
  animation: scrollTween,
  trigger: ".wrapper",
	pin: true,
	scrub: true,
	end: () => `+=${maxWidth}`,
	invalidateOnRefresh: true

//sections.forEach((sct, i) => {
//  ScrollTrigger.create({
//	trigger: sct,
//	start: () => 'top top-=' + (sct.offsetLeft - window.innerWidth/2) * (maxWidth / (maxWidth - window.innerWidth)),
//	end: () => '+=' + sct.offsetWidth * (maxWidth / (maxWidth - window.innerWidth)),
//	toggleClass: {targets: sct, className: "active"}
//  });

// dragRatio changed to the part in the horizontal sroll that's there to calculate the offset between the duration of the scroll and the amount of x-translation of the content (that needs to be included there when triggering things when certain sections reach a certain point in the viewport - as seen in commented out part above)

var dragRatio = (maxWidth / (maxWidth - window.innerWidth))

var drag = Draggable.create(".drag-proxy", {
  trigger: '.wrapper',
  type: "x",
  inertia: true,
  allowContextMenu: true,
  onPress() {
    this.startScroll = horizontalScroll.scroll();
  onDrag() {
    horizontalScroll.scroll(this.startScroll - (this.x - this.startX) * dragRatio);
  onThrowUpdate() {
    horizontalScroll.scroll(this.startScroll - (this.x - this.startX) * dragRatio);