fixed side-effect for chromium based browsers

This commit is contained in:
kirbo 2024-06-04 01:03:35 -07:00 committed by Weblate
parent b2e5af356e
commit e59529a02c
1 changed files with 17 additions and 0 deletions

View File

@ -268,7 +268,15 @@ export function Discover() {
} }
}, [movieWidth]); }, [movieWidth]);
const browser = !!window.chrome; // detect chromium browser
let isScrolling = false;
function handleWheel(e: React.WheelEvent, categorySlug: string) { function handleWheel(e: React.WheelEvent, categorySlug: string) {
if (isScrolling) {
return;
}
isScrolling = true;
const carousel = carouselRefs.current[categorySlug]; const carousel = carouselRefs.current[categorySlug];
if (carousel) { if (carousel) {
const movieElements = carousel.getElementsByTagName("a"); const movieElements = carousel.getElementsByTagName("a");
@ -280,6 +288,15 @@ export function Discover() {
} }
} }
} }
if (browser) {
setTimeout(() => {
isScrolling = false;
}, 345); // disable scrolling after 345 milliseconds for chromium-based browsers
} else {
// immediately reset isScrolling for non-chromium browsers
isScrolling = false;
}
} }
const [isHovered, setIsHovered] = useState(false); const [isHovered, setIsHovered] = useState(false);