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