mirror of https://github.com/sussy-code/smov.git
fixed side-effect for chromium based browsers
This commit is contained in:
parent
b2e5af356e
commit
e59529a02c
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue