mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
Add overflow exception to buttons
This commit is contained in:
parent
249a527a9a
commit
2655154ce9
1 changed files with 16 additions and 1 deletions
|
@ -165,7 +165,22 @@ export function Discover() {
|
|||
const visibleMovies = Math.floor(carousel.offsetWidth / movieWidth);
|
||||
const scrollAmount = movieWidth * visibleMovies;
|
||||
if (direction === "left") {
|
||||
carousel.scrollBy({ left: -scrollAmount, behavior: "smooth" });
|
||||
if (carousel.scrollLeft <= 5) {
|
||||
carousel.scrollBy({
|
||||
left: carousel.scrollWidth,
|
||||
behavior: "smooth",
|
||||
}); // Scroll to the end
|
||||
} else {
|
||||
carousel.scrollBy({ left: -scrollAmount, behavior: "smooth" });
|
||||
}
|
||||
} else if (
|
||||
carousel.scrollLeft + carousel.offsetWidth + 5 >=
|
||||
carousel.scrollWidth
|
||||
) {
|
||||
carousel.scrollBy({
|
||||
left: -carousel.scrollWidth,
|
||||
behavior: "smooth",
|
||||
}); // Scroll to the beginning
|
||||
} else {
|
||||
carousel.scrollBy({ left: scrollAmount, behavior: "smooth" });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue