Jump to content
Search Community

snapStart triggers after slight scroll has happened

Ritik test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Video with the issue
 

        .timeline({
          scrollTrigger: {
            trigger: containerRef.current.querySelector(".containerDiv"),
            start: "top top",
            end: () => {
              const containerDiv = document.querySelector(".containerDiv");
              return containerDiv ? `+=${containerDiv.offsetWidth}` : 0;
            },
            pin: true,
            scrub: true,
            snap: {
              inertia: false,
              snapTo: "labelsDirectional",
              duration: { min: 0.2, max: 1.6 },
              ease: "power3",
              delay: 0,
              onStart() {
                alert("snap started after a bit of scroll");
              },
            },
            // onSnapComplete() {
            //   alert("snap completed");
            // },
            onUpdate: (trigger) => {
              setProgressBar(trigger.progress);
            },
          },
        })

I want you to focus on the snap property of scrollTrigger, the video shows how onStart() is only triggered after a bit of scroll has happened. I am unable to understand why this delay is occurring.
I'd create a minimal demo if this issue is not due to some common occurrence or my lack of understanding.

Link to comment
Share on other sites

  • Solution

The snap functions runs after the visitor has done scrolling. Check out the quote from Jack him self (on this post)

Quote

ScrollTrigger cannot snap until scrolling has completely stopped. It has to keep watching the scroll position until it has not changed for a little while, otherwise snapping would interfere with normal user scrolling. So even if you set delay: 0, it won't actually have zero delay. That's simply impossible. 

 

Hope it helps and happy tweening! 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...