mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 05:35:25 +03:00
Fix control hovering
This commit is contained in:
parent
14f268e62f
commit
9f099131ff
@ -81,6 +81,35 @@ export default function HlsVideoPlayer({
|
|||||||
const [controls, setControls] = useState(isMobile);
|
const [controls, setControls] = useState(isMobile);
|
||||||
const [controlsOpen, setControlsOpen] = useState(false);
|
const [controlsOpen, setControlsOpen] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isDesktop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const callback = (e: MouseEvent) => {
|
||||||
|
if (!videoRef.current) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rect = videoRef.current.getBoundingClientRect();
|
||||||
|
|
||||||
|
if (
|
||||||
|
e.clientX > rect.left &&
|
||||||
|
e.clientX < rect.right &&
|
||||||
|
e.clientY > rect.top &&
|
||||||
|
e.clientY < rect.bottom
|
||||||
|
) {
|
||||||
|
setControls(true);
|
||||||
|
} else {
|
||||||
|
setControls(controlsOpen);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener("mousemove", callback);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("mousemove", callback);
|
||||||
|
};
|
||||||
|
}, [videoRef, controlsOpen]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TransformWrapper minScale={1.0}>
|
<TransformWrapper minScale={1.0}>
|
||||||
<VideoControls
|
<VideoControls
|
||||||
@ -126,26 +155,6 @@ export default function HlsVideoPlayer({
|
|||||||
height: "100%",
|
height: "100%",
|
||||||
}}
|
}}
|
||||||
wrapperProps={{
|
wrapperProps={{
|
||||||
onMouseMove: isDesktop
|
|
||||||
? (e) => {
|
|
||||||
if (!videoRef.current) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rect = videoRef.current.getBoundingClientRect();
|
|
||||||
|
|
||||||
if (
|
|
||||||
e.clientX > rect.left &&
|
|
||||||
e.clientX < rect.right &&
|
|
||||||
e.clientY > rect.top &&
|
|
||||||
e.clientY < rect.bottom
|
|
||||||
) {
|
|
||||||
setControls(true);
|
|
||||||
} else {
|
|
||||||
setControls(controlsOpen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
onClick: isDesktop ? undefined : () => setControls(!controls),
|
onClick: isDesktop ? undefined : () => setControls(!controls),
|
||||||
}}
|
}}
|
||||||
contentStyle={{
|
contentStyle={{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user