Responsive Carousel V2

Goal: Create a responsive carousel for all screensizes

Here is my attempted solution - https://codepen.io/Matt-CopOffMatt/pen/eYopOWj

Using (multiple) media queries, I reduced the amount of visible cards. Then, using JS, I used a formula productRow.scrollWidth / productRow.offsetWidth) + productRow.offsetWidth to determine how much many cards to move per click (previous vs next)

This works flawlessly, except there's no logic for detecting the first and last card (if you keep clicking, there winds up being white space)

Any ideas or suggestions on how to handle this? The goal would be to ensure there is no white space

Thanks in advance 👍
Was this page helpful?