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

              
                
        <div id="scrollbar">
            <div class="wrapper d-flex flex-column-reverse wrapper-sections">
                <section id="sectionOne" class="section section--large flex-shrink-0 vw-100 vh-100 d-flex justify-content-center align-items-center">
                    <h2>Section One</h2>
                </section>
                <section id="sectionTwo" class="section section--dark section--small vh-100 flex-shrink-0 d-flex justify-content-center align-items-center">
                    <h2>Section Two</h2>
                </section>
                <section id="sectionThree" class="section section--small vh-100 flex-shrink-0 d-flex justify-content-center align-items-center">
                    <h2>Section Three</h2>
                </section>
            </div>
            <div class="image-bg d-flex justify-content-center align-items-end">
                <img src="https://heiko-poke.com/2tours-bg.png" class="imgbg">
            </div>

        </div>

              
            
!

CSS

              
                        body, html {
            overflow-x: hidden;
            max-width: 100vw;
        }
        #scrollbar {
            width: 100vw;
            height: 100vh;
            overflow: hidden;
        }
        .wrapper-sections {
            position: relative;
            z-index: 10;
        }
        .section--large {
            width: 100vw;
            background-color: #e4002b;
            color: white;
        }
        .section--small {
            width: 100vw;
        }
        .section--dark {
            color: white;
            background-color: black;
        }

        button {
            background-color: red;
        }
        button.enable {
            background-color: green;
        }

        h2.active {
            color: blue;
        }
        .image-bg {
            position: fixed;
            height:300vh;
            /*max-height:1639px;*/
            max-height:2500px;
            width:250vh;
            max-width:100vw;
            bottom:0;
            left:0;
            z-index: 9;
            overflow: hidden;
            background: blue;
            border:10px solid green;
            overflow:hidden;
        }
        .image-bg img {
            height:100%;
            width: auto;
            /*max-height:1639px;*/
            border:1px solid red;
        }
        .section {
            opacity: 0.5;
        }
              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

			const scrollbar = document.querySelector("#scrollbar");

			class invertDeltaPlugin extends Scrollbar.ScrollbarPlugin {
				static pluginName = "invertDelta";

				transformDelta(delta) {
					return {
						x: delta.x,
						y: -delta.y
					};
				}
			}

			Scrollbar.use(invertDeltaPlugin);

			const myInvertScrollbar = Scrollbar.init(scrollbar);
			myInvertScrollbar.setPosition(0, myInvertScrollbar.limit.y);

			ScrollTrigger.scrollerProxy(scrollbar, {
				scrollTop(value) {
					if (arguments.length) {
						myInvertScrollbar.scrollTop = value;
					}
					return myInvertScrollbar.scrollTop;
				},
				getBoundingClientRect() {
					return {
						top: 0,
						left: 0,
						width: window.innerWidth,
						height: window.innerHeight
					};
				}
			});

			myInvertScrollbar.addListener(ScrollTrigger.update);

			const buttons = document.querySelectorAll("h2");
			buttons.forEach((btn, index) => {
				gsap.to(btn, {
					scrollTrigger: {
						id: `title--${index}`,
						trigger: btn,
						start: "top center",
						end: "bottom center",
						toggleClass: "active",
						//markers: true,
						scroller: scrollbar
					}
				});
			});
			gsap.to(".image-bg", {
				scrollTrigger: {
					trigger: "#sectionOne",
					start: "top 90%",
					end: "top 0",
					markers: true,
					//toggleActions: "reverse reverse restart play",
					scroller: scrollbar,
					scrub:1
				},
				width: '100%',
				height: '100vh',
			});

// Only necessary to correct marker position - not needed in production
if (document.querySelector('.gsap-marker-scroller-start')) {    
  const markers = gsap.utils.toArray('[class *= "gsap-marker"]'); 

  myInvertScrollbar.addListener(({ offset }) => {  
    gsap.set(markers, { marginTop: -offset.y })
  });
}
              
            
!
999px

Console