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

              
                .smooth-scroll
	.text
		p Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci quas laudantium, consequuntur iste ea officia deserunt perferendis repudiandae tempora, odit obcaecati est ullam non officiis exercitationem sed animi. Adipisci, sed.
		p Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci quas laudantium, consequuntur iste ea officia deserunt perferendis repudiandae tempora, odit obcaecati est ullam non officiis exercitationem sed animi. Adipisci, sed.
		p Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci quas laudantium, consequuntur iste ea officia deserunt perferendis repudiandae tempora, odit obcaecati est ullam non officiis exercitationem sed animi. Adipisci, sed.
		p Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci quas laudantium, consequuntur iste ea officia deserunt perferendis repudiandae tempora, odit obcaecati est ullam non officiis exercitationem sed animi. Adipisci, sed.

	.slider
		.slider__list
			- var item = 0;
				while item < 5
					- item++;
					.slider__item
						h1= 'item ' + item

	.text
		p Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci quas laudantium, consequuntur iste ea officia deserunt perferendis repudiandae tempora, odit obcaecati est ullam non officiis exercitationem sed animi. Adipisci, sed.
		p Lorem ipsum dolor sit amet consectetur adipisicing elit. Adipisci quas laudantium, consequuntur iste ea officia deserunt perferendis repudiandae tempora, odit obcaecati est ullam non officiis exercitationem sed animi. Adipisci, sed.

              
            
!

CSS

              
                *
  box-sizing: border-box

body
  width: 100%
  overflow-x: hidden

.smooth-scroll
  width: 100vw  
  overflow: hidden
  
.text
  width: 100%
  padding: 5rem
  overflow: hidden

.slider__list
  width: 100%
  display: flex
  padding: 0
  
.slider__item
  flex: 0 0 100%
  height: 100vh
  display: flex
  align-items: center
  justify-content: center
  border: 1px solid #000
  background: tomato
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

// const locoScroll = new LocomotiveScroll({
// 	el: document.querySelector(".smooth-scroll"),
// 	smooth: true
// });

// locoScroll.on("scroll", ScrollTrigger.update);
// ScrollTrigger.scrollerProxy(".smooth-scroll", {
// 	scrollTop(value) {
// 		return arguments.length
// 			? locoScroll.scrollTo(value, 0, 0)
// 			: locoScroll.scroll.instance.scroll.y;
// 	},
// 	getBoundingClientRect() {
// 		return {
// 			top: 0,
// 			left: 0,
// 			width: window.innerWidth,
// 			height: window.innerHeight
// 		};
// 	},
// 	pinType: document.querySelector(".smooth-scroll").style.transform
// 		? "transform"
// 		: "fixed"
// });

// ScrollTrigger.addEventListener("refresh", () => locoScroll.update());
// ScrollTrigger.refresh();

let slider = document.querySelector(".slider");
let list = document.querySelector(".slider__list");
let items = document.querySelectorAll(".slider__item");

const TL = gsap.timeline({
	defaults: { ease: "none" },
	scrollTrigger: {
		trigger: slider,
		scrub: 1,
		pin: true,
		start: "top top",
		scroller: "body",
		end: `+=${items.length - 1}00%`,
		snap: {
			snapTo: "labels",
			duration: { min: 0.2, max: 1 },
			delay: 0,
			ease: "power1.inOut"
		}
	}
});
TL.addLabel(`l0`);

items.forEach((el, index) => {
	if (index > 0) {
		TL.to(list, { xPercent: -100 * index });
		TL.addLabel(`l${index}`);
	}
});

              
            
!
999px

Console