01 Get started

Add Package

First you have to add the package (it's not included in the main gsap package) and register it.
Then you have the scrollTrigger property in your gsap object.

                
        gsap.registerPlugin(ScrollTrigger);
                
            

ScrollTrigger Property

Add the scrollTrigger property, which has an object with another properties as a value, to the animation.

                
        gsap.to(bloc, {
            y: 0,
            ease: "linear",
            scrollTrigger: {
                trigger: ".container-scroll",
                start: "top bottom-=60%",
                end: `+=${offsets[index]}`,
                markers: true,
                scrub: 1.3,
            },
        });
                
            

Play with the Properties

02 Example

HAT

top rocket

Keeps a warm head.

BODY

mid rocket

Highly flexible machine.

GLOVES

bot rocket

Essentials for those days.

SNEAKERS

supply rocket

Always prepared for a run.

                    
    function dissectTheBlob() {
        const hat = document.querySelector(".scrollblob-hat");
        const body = document.querySelector(".scrollblob-body");
        const gloves = document.querySelector(".scrollblob-gloves");
        const shoes = document.querySelector(".scrollblob-shoes");
        const allBlocs = document.querySelectorAll(".bloc");
        const offsets = [200, 490, 590];


        // animates the svg elements 
        gsap.utils.toArray([".bloc2", ".bloc3", ".bloc4"]).forEach((bloc, index) => {
            gsap.to(bloc, {
                y: 0,
                ease: "linear",
                scrollTrigger: {
                    trigger: ".container-scroll",
                    start: "top bottom-=60%",
                    // starts when the top of trigger element is 60% up from the viewport bottom
                    end: `+=${offsets[index]}`,
                    // ends xyz px are scrolled
                    scrub: 1.3,
                },
            });
        });

        //animates the headlines
        allBlocs.forEach((bloc, index) => {
            ScrollTrigger.create({
                trigger: bloc,
                start: "top center",
                onEnter: () => {
                    bloc.classList.add("active");
                },
                onLeaveBack: () => {
                    bloc.classList.remove("active");
                },
                // markers: true
            });
        });
    }
                    
                

We mastered the ScrollTrigger!