This commit is contained in:
lloydzhou
2024-07-25 19:31:16 +08:00
parent 6a083b24c4
commit 556d563ba0
2 changed files with 13 additions and 5 deletions

View File

@@ -528,11 +528,15 @@ export function FullScreen(props: any) {
}
}, []);
useEffect(() => {
document.addEventListener("fullscreenchange", (e) => {
const handleScreenChange = (e) => {
if (e.target === ref.current) {
setFullScreen(!!document.fullscreenElement);
}
});
};
document.addEventListener("fullscreenchange", handleScreenChange);
return () => {
document.removeEventListener("fullscreenchange", handleScreenChange);
};
}, []);
return (
<div ref={ref} style={{ position: "relative" }} {...rest}>