mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
Fix scrolling bug
This commit is contained in:
parent
a2b39ee288
commit
af74657f1a
1 changed files with 13 additions and 1 deletions
|
@ -197,14 +197,22 @@ export function Discover() {
|
|||
}
|
||||
}, [movieWidth]); // Added movieWidth to the dependency array
|
||||
|
||||
let isScrolling = false;
|
||||
|
||||
function handleWheel(e: React.WheelEvent, categorySlug: string) {
|
||||
if (isScrolling) {
|
||||
return;
|
||||
}
|
||||
|
||||
isScrolling = true;
|
||||
|
||||
const carousel = carouselRefs.current[categorySlug];
|
||||
if (carousel) {
|
||||
const movieElements = carousel.getElementsByTagName("a");
|
||||
if (movieElements.length > 0) {
|
||||
const posterWidth = movieElements[0].offsetWidth;
|
||||
const visibleMovies = Math.floor(carousel.offsetWidth / posterWidth);
|
||||
const scrollAmount = posterWidth * visibleMovies * 0.625;
|
||||
const scrollAmount = posterWidth * visibleMovies * 0.6;
|
||||
if (e.deltaY < 5) {
|
||||
carousel.scrollBy({ left: -scrollAmount, behavior: "smooth" });
|
||||
} else {
|
||||
|
@ -212,6 +220,10 @@ export function Discover() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
isScrolling = false;
|
||||
}, 345); // Disable scrolling every 3 milliseconds after interaction (only for mouse wheel doe)
|
||||
}
|
||||
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
|
|
Loading…
Reference in a new issue