From c793e0dd788d46fc9a2c7f0e408bdfc7d1fed665 Mon Sep 17 00:00:00 2001 From: yiling Date: Sat, 4 Jul 2026 13:15:52 +0800 Subject: [PATCH] fix(webui): keep fullscreen controls visible while cursor is over them Track when the cursor is over the control bar (VideoControlBar now forwards mouse enter/leave) and skip the idle-hide timer while it is, so the bar no longer disappears when the cursor rests on it. Also reduce the fullscreen auto-hide delay from 2s to 1.2s. --- .../components/viewers/video-control-bar.tsx | 7 ++++ .../webui/components/viewers/video-player.tsx | 33 ++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/packages/webui/components/viewers/video-control-bar.tsx b/packages/webui/components/viewers/video-control-bar.tsx index f1838b1e..28436447 100644 --- a/packages/webui/components/viewers/video-control-bar.tsx +++ b/packages/webui/components/viewers/video-control-bar.tsx @@ -73,6 +73,9 @@ export interface ControlBarProps { * stays in-flow. Colors are always theme-aware regardless of this flag. */ floatOverlayInFullScreen?: boolean + /** Fired when the cursor enters/leaves the bar (used to pin it visible). */ + onMouseEnter?: () => void + onMouseLeave?: () => void } export const VideoControlBar: React.FC = ({ @@ -97,6 +100,8 @@ export const VideoControlBar: React.FC = ({ currentFrame, seekToFrame, floatOverlayInFullScreen = true, + onMouseEnter, + onMouseLeave, }) => { const { videoTimeDisplayMode, setVideoTimeDisplayMode } = useUiStore() @@ -130,6 +135,8 @@ export const VideoControlBar: React.FC = ({ ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-4 pointer-events-none', )} + onMouseEnter={onMouseEnter} + onMouseLeave={onMouseLeave} > {/* Progress Bar */}
diff --git a/packages/webui/components/viewers/video-player.tsx b/packages/webui/components/viewers/video-player.tsx index 54b16fe8..3d7d69f5 100644 --- a/packages/webui/components/viewers/video-player.tsx +++ b/packages/webui/components/viewers/video-player.tsx @@ -42,6 +42,7 @@ const VideoPlayer: React.FC = ({ const containerRef = useRef(null) const rootRef = useRef(null) const controlsTimeoutRef = useRef | null>(null) + const isOverControlsRef = useRef(false) const [videoHtmlEl, setVideoHtmlEl] = useState(undefined) const videoRef = useRef(null) @@ -340,23 +341,35 @@ const VideoPlayer: React.FC = ({ } }, [startTime, frameRate, seekToFrame, isPlayerReady]) - const handleMouseMove = useCallback(() => { - // Always show controls on movement - setIsControlsVisible(true) - + const scheduleHide = useCallback(() => { if (controlsTimeoutRef.current) { clearTimeout(controlsTimeoutRef.current) } - - // In fullscreen, hide the controls after the cursor stays idle, regardless - // of play/pause (YouTube-style). In windowed mode controls stay visible. - if (state.isFullScreen) { + // Never hide while the cursor rests over the control bar itself. + if (state.isFullScreen && !isOverControlsRef.current) { controlsTimeoutRef.current = setTimeout(() => { setIsControlsVisible(false) - }, 2000) + }, 1200) } }, [state.isFullScreen]) + const handleMouseMove = useCallback(() => { + // Always show controls on movement, then (re)start the idle hide timer. + setIsControlsVisible(true) + scheduleHide() + }, [scheduleHide]) + + const handleControlsMouseEnter = useCallback(() => { + isOverControlsRef.current = true + if (controlsTimeoutRef.current) clearTimeout(controlsTimeoutRef.current) + setIsControlsVisible(true) + }, []) + + const handleControlsMouseLeave = useCallback(() => { + isOverControlsRef.current = false + scheduleHide() + }, [scheduleHide]) + const handleMouseLeave = useCallback(() => { // If the cursor leaves the player while fullscreen, hide the controls. if (state.isFullScreen) { @@ -625,6 +638,8 @@ const VideoPlayer: React.FC = ({ totalFrames={totalFrames} currentFrame={currentFrame} seekToFrame={seekToFrame} + onMouseEnter={handleControlsMouseEnter} + onMouseLeave={handleControlsMouseLeave} />
)