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

              
                
<body >

    <div class="home">
        <h1 style="color: red;">
            Section One
        </h1>
    </div>
    <div class="home2">
        <h1 style="color: red;">
            Section Two
        </h1>
        <lottie-player id="secondLottie" id="MyContainerId"
            src="https://assets4.lottiefiles.com/packages/lf20_SKMtJC/File.json" style="width:400px; height: 400px;">
        </lottie-player>
    </div>
    <div class="container">
        <nav class="navBar">
            This is Header
        </nav>
        <div class="c_1 scroll_x">
            Horizontal Scroll <br>
            <br>
            Scroll -------------->
        </div>
        <div class="c_2 scroll_x">
            Keep Scrolling
        </div>
        <div class="c_3 scroll_x">
            Keep Scrolling
        </div>
        <div class="c_4 scroll_x">
            Keep Scrolling
        </div>
    </div>

    <div class="footer">
        <div class="pin">

          <h1> pinned section </h1>
          
            Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae, quam! Sunt, unde mollitia accusantium ipsa
            similique dolores nisi rerum eum, tenetur natus nemo. <br> <br>
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Rerum asperiores dolore, at cum id quae esse
            reprehenderit quas pariatur! Iure qui sapiente totam maiores adipisci praesentium quisquam assumenda,
            asperiores quaerat error blanditiis perferendis natus quam! Debitis dolorum ducimus ea laboriosam distinctio
            officia, corrupti expedita ullam, nam, qui asperiores ex sunt?
        </div>
        <div class="pin2">
            Lorem ipsum dolor sit amet consectetur adipisicing elit. Amet aperiam totam saepe fugiat voluptate officiis
            minima nulla, debitis sequi quibusdam id nostrum aliquam labore accusamus minus quod! Dolorum, ex incidunt.
        </div>
    </div>
    <div class="footer2">

        Lorem ipsum, dolor sit amet consectetur adipisicing elit. Unde nam doloremque molestias id maxime tenetur
        exercitationem aperiam officia magnam perspiciatis dolorum, quibusdam excepturi animi at consequatur explicabo
        quia, fugiat distinctio.
    </div>
    <div class="footer3">


        Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusamus amet quae dolor mollitia ea maxime neque
        consectetur, nemo similique, necessitatibus nisi voluptas perspiciatis expedita ad dignissimos natus suscipit,
        quia tempore.
    </div>

    <div class="endFooter">
        This is Footer
    </div>
</body>
              
            
!

CSS

              
                * {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
}

body {
    overscroll-behavior: none;
    height: 100vh;
}
body::-webkit-scrollbar {
    display: none;
}

.home {
    width: 100vw;
    height: 100vh;
    background-color: rgb(0, 0, 0);
    display: flex;
    justify-content: center;
    align-items: center;
}
.home2 {
    width: 100vw;
    height: 100vh;
    background-color: rgb(245, 230, 230);
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    overscroll-behavior: none;
    width: 400%;
    height: 100vh;
    display: flex;
    flex-wrap: nowrap;
}

.navBar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 30px;
    text-align: center;
    line-height: 30px;
    font-weight: 600;
    background-color: rgb(173, 173, 184);
    z-index: 10;
    font-size: 20px;
}

.c_1 {
    width: 100vw;
    height: 100vh;
    background-color: aqua;
    display: flex;
    justify-content: center;
    align-items: center;
}
.c_2 {
    width: 100vw;
    height: 100vh;
    background-color: rgb(4, 93, 134);
    display: flex;
    justify-content: center;
    align-items: center;
}
.c_3 {
    width: 100vw;
    height: 100vh;
    background-color: antiquewhite;
    display: flex;
    justify-content: center;
    align-items: center;
}

.c_4 {
    width: 100vw;
    height: 100vh;
    background-color: orange;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer {
    display: flex;
    width: 100vw;
    height: 100vh;
    background-color: rgb(42, 63, 56);
}
.pin {
    width: 50vw;
    height: 100vh;
    background-color: rgb(92, 10, 10);
    border: 10px solid black;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
}
.pin2 {
    width: 50vw;
    height: 100vh;
    background-color: rgb(92, 10, 10);
    border: 10px solid rgb(233, 213, 213);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
}

.footer2 {
    width: 50vw;
    margin-left: 50%;
    height: 100vh;
    border: 10px solid rgb(233, 213, 213);
    background-color: rgb(17, 189, 132);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
}
.footer3 {
    width: 50vw;
    margin-left: 50%;
    height: 100vh;
    border: 10px solid rgb(233, 213, 213);
    background-color: rgb(18, 129, 8);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 50px;
}
.endFooter {
    width: 100vw;
    height: 30vh;
    background-color: gray;
    text-align: center;
    line-height: 30vh;
    font-size: 30px;
    font-weight: 600;
}

.lottie {
    position: absolute;
    left: 150px;
}

              
            
!

JS

              
                gsap.registerPlugin(ScrollTrigger);

let section = gsap.utils.toArray('.scroll_x');

let pin = document.querySelector('.pin');
let footer = document.querySelector('.footer');
let footer2 = document.querySelector('.footer2');
let home2 = document.querySelector('.home2');
let container = document.querySelector('.container');
console.log(container);

gsap.to(section, {
    xPercent: -100 * (section.length - 1),
    ease: 'none',
    duration: 0.5,
    scrollTrigger: {
        trigger: container,

        pin: true,
        scrub: 1,
        markers: true,
        snap: 1 / (section.length - 1),
        duration: 0.1,
        // base vertical scrolling on how wide the container is so it feels more natural.
        end: '+=3500'
    }
});

gsap.to(pin, {
    scrollTrigger: {
        trigger: '.pin',
        endTrigger: '.footer2',
        pin: true,
        scrub: 1,
        duration: 0.1,
        // markers: true,
        start: 'top '
        // end: '+=200%'
    }
});

ScrollTrigger.create({
    trigger: '.home',
    start: 'top top',
    duration: 0.1,
    snap: {
        ease: 'power1.inOut'
    },
    pin: true,
    pinSpacing: true,
    duration: 1,
    marker: true
});

ScrollTrigger.create({
    trigger: '.footer2',
    start: 'top top',
    ease: true,
    snap: 1,
    duration: 0.1,
    marker: true
});

// LottieInteractivity.create({
//     mode: 'scroll',
//     player: '#firstLottie',
//     actions: [
//         {
//             visibility: [0, 1],
//             type: 'seek',
//             frames: [0, 63]
//         }
//     ]
// });

LottieInteractivity.create({
    player: '#secondLottie',
    mode: 'scroll',
    container: '#MyContainerId',
    actions: [
        {
            visibility: [0, 1.0],
            type: 'seek',
            frames: [90, 123]
        }
    ]
});

              
            
!
999px

Console