I need some help, I am currently experiencing some issue on a website I am working on. Here is the website URL https://gsap.asdt.com/home-2
The Scroll Snap doesn't work on the page.
Here is the my GSAP code;
<script>
gsap.registerPlugin(ScrollTrigger);
gsap.utils.toArray(".panel").forEach((panel, i) => {
ScrollTrigger.create({
trigger: panel,
start: "top top",
scrub: true,
pin: true,
pinSpacing: f
Sure, I just switched the wrap to clamp, and then check if the index is the same as the currentIndex. If they're the same, that means it's either on the first or last slide, so we should just return out of the function.
let clamp = gsap.utils.clamp(0, sections.length - 1);
function gotoSection(index, direction) {
index = clamp(index); // make sure it's valid
// If they are the same, it's either the first or last slide
if (index === currentIndex) {
return;
}
...
}