Pen Settings



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


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.


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.


                <div class='scrollContainer'>
    <div class='section'>ScrollTrigger with Draggable</div>
    <div class='section'></div>
    <div class='section'></div>
    <div class='section'></div>
<div class="proxy"></div>


                body {
  margin: 0;
  padding: 0;
  overflow: hidden;

.scrollContainer {
  width: 600%;
  display: flex;
  flex-wrap: nowrap;

.section {
  height: 100vh;
  width: 100vw;
  text-align: center;
  font-size: 36px;
  line-height: 90vh;

.section:nth-child(1) {
  background-color: #deb887;

.section:nth-child(2) {
  background-color: limegreen;

.section:nth-child(3) {
  background-color: #b8860b;

.section:nth-child(4) {
  background-color: #2f4f4f;

.proxy {
  position: absolute;
  visibility: hidden;


                let sections = document.querySelectorAll(".section");
let scrollContainer = document.querySelector(".scrollContainer");

let scrollTween =, {
  xPercent: -100 * (sections.length - 1),
  ease: "none"

let horizontalScroll = ScrollTrigger.create({
  animation: scrollTween,
  trigger: scrollContainer,
  pin: true,
  scrub: 1,
  end: () => "+=" + scrollContainer.offsetWidth,

// total scroll amount divided by the total distance that the sections move gives us the ratio we can apply to the pointer movement so that it fits. 
var dragRatio = scrollContainer.offsetWidth / (window.innerWidth * (sections.length - 1));
var drag = Draggable.create(".proxy", {
  trigger: scrollContainer,
  type: "x",
  onPress() {
    this.startScroll = horizontalScroll.scroll();
  onDrag() {
    horizontalScroll.scroll(this.startScroll - (this.x - this.startX) * dragRatio);
    // if you don't want it to lag at all while dragging (due to the 1-second scrub), uncomment the next line: