Good day!
I have a pretty simple ScrollTrigger setup; where a bar with sticky titles animates up or down, based on the scroll direction. But there's a small bug / unwanted behaviour in it: when the content changes (certain elements can be removed), even if it's less than a pixel, the ScrollTrigger fires and the header bar moves up. Is there any way to add a threshold of some sort?
This is what i currently have:
const headingScrollTrigger = ScrollTrigger.create({
start: '400',
end: 'max',
scrub: 1,
fastScrollEnd: true,
onEnter: () => gsap.to('.compare__heading-container', {
duration: 0.5,
ease: 'sine.out(1.7)',
y: 60,
opacity: 1,
}),
onLeaveBack: () => gsap.to('.compare__heading-container', {
duration: 1,
ease: 'expo.out',
y: -210,
opacity: 0,
}),
onUpdate: (self) => {
if (breakpoint >= 4) {
self.direction === -1
? (document.querySelector('.compare__heading-container').style.transform = 'translateY(120px)')
: (document.querySelector('.compare__heading-container').style.transform = 'translateY(60px)');
}
},
});