Jump to content
Search Community

ScrollTrigger interfering with scrollIntoView

TRIIX test
Moderator Tag

Recommended Posts

I got an Issue with the ScrollTrigger Method "onUpdate":

 

I am trying to "snap" the sections on a Scroll Update (I don't want to use snap: because the user has to stop scrolling to trigger the snap and it should happen onUpdate).

 

So If I am in section1 and trigger onUpdate and if direction === 1, then it should scrollIntoView to Section2:

 

ScrollTrigger.create({
      markers: true,
      id: 'section1',
      trigger: '.section1',
      start: 'top 350px',
      end: 'top 350px',
      endTrigger: '.section2',
      onUpdate: ({ direction }) => {
        if (direction === 1) {
         section2.scrollIntoView({ behavior: 'smooth', block: 'center' });
        }
      },
    });

 

The problem I am having, is that the behavior: 'smooth', is interfiering with ScrollTrigger and it's not scrolling to the center.

I tried to change the direction (if direction === -1) and it is scrolling to the block, but wouldn't make sense to use.

 

My Question is, if there is an even simpler solution or if its a bug, how can I fix it?

 

Thanks in advance :D

 

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...