Hey y'all!
I'm messing around with this horizontal scrolling demo where I'm using ScrollTrigger and setting the body width to an excessive width. The effect works as expected when scrolling (I've not styled things up yet, POC 😅).
But, I want to add "Next/Previous" buttons to the UI and I can't see what obvious thing I'm missing 🤦♂️
"Previous" works as expected. But, "Next" is never able to reach the last item. I'm assuming I'm not doing something quite right in `SC
Yeah, that was kinda what I was looking for and wanted to avoid doing the "Am I clicking the left/right half of the track" part 😅
I came up with this in the end. It seems to scale well when I change the number of boxes, etc.
document.querySelector('.boxes').addEventListener('click', e => {
const BOX = e.target.closest('.box')
if (BOX) {
let TARGET = BOXES.indexOf(BOX)
let CURRENT = gsap.utils.wrap(
0,
BOXES.length,
Math.floor(BOXES.length *