Good afternoon, i have a very long page that utilizes scrolltriggers in several modules. one of the modules on my pages has a horizontal scroll with a few slides and within each slide is an animation. everything works pretty well except we have found during beta testing that the user can scroll and very quickly through and past the horizontal "slider" into the regular vertical page. overall the horizontal portion doesnt "feel" great and breaks the user experience. we've tried doing "snap" points- but they snapped in odd ways that didnt feel natural.
i've googled this, searched the forums, tried on my own but nothing is working or is overly complex to the point of getting overwhelmed at the complexity of some of these other "snap" solutions.
what im wondering is is there a way to add a bit of a "click" feel as each slide finishes. or some sort of anticipation and "pause" after each slide so the user doesnt whip trough the horizontal scroll?
i''d be very thankful for any assistance i can get on this, as it's become quite frustrating.
const tl2 = gsap.timeline({
scrollTrigger: {
trigger: '.module_3_wrapper',
start: "center center",
end: "center center",
pin: '.module_3_wrapper',
scrub: 1,
pinSpacing: true,
}
});
let container = document.querySelector('.module_3');
let sections = gsap.utils.toArray(".module_3 .slides");
let scrollTween = gsap.to(sections, {
x: () => -(container.scrollWidth - document.querySelector('.module_3_wrapper').clientWidth) + "px",
ease: "none",
duration: .1,
scrollTrigger: {
trigger: ".module_3_wrapper",
pin: true,
start: "center center",
scrub: true,
invalidateOnRefresh: true,
end: `+=${container.offsetWidth}`,
}
});
I found someone did something like this with a nest scrolltrigger, but i can't figure out how to merge what i have and what this does. but it has the exact effect im looking for. where it nicely locks between slides.
let slides = gsap.utils.toArray(".slide");
slides.forEach((slide, i) => {
if (i) { // skip the first one.
ScrollTrigger.create({
start: () => ScrollTrigger.maxScroll(window) / (slides.length - 0) * i,
end: "+=1",
onEnter: self => gsap.to(".slide", {x: (-100 * i) + "vw", ease: "none", overwrite: true}),
onLeaveBack: self => gsap.to(".slide", {x: (-100 * (i - 1)) + "vw", ease: "none", overwrite: true})
})
}
});