mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 03:28:22 +00:00
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.
This commit is contained in:
@@ -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<ControlBarProps> = ({
|
||||
@@ -97,6 +100,8 @@ export const VideoControlBar: React.FC<ControlBarProps> = ({
|
||||
currentFrame,
|
||||
seekToFrame,
|
||||
floatOverlayInFullScreen = true,
|
||||
onMouseEnter,
|
||||
onMouseLeave,
|
||||
}) => {
|
||||
const { videoTimeDisplayMode, setVideoTimeDisplayMode } = useUiStore()
|
||||
|
||||
@@ -130,6 +135,8 @@ export const VideoControlBar: React.FC<ControlBarProps> = ({
|
||||
? 'opacity-100 translate-y-0'
|
||||
: 'opacity-0 translate-y-4 pointer-events-none',
|
||||
)}
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
>
|
||||
{/* Progress Bar */}
|
||||
<div className="mb-4 px-1">
|
||||
|
||||
@@ -42,6 +42,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
||||
const containerRef = useRef<HTMLDivElement>(null)
|
||||
const rootRef = useRef<HTMLDivElement>(null)
|
||||
const controlsTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const isOverControlsRef = useRef(false)
|
||||
|
||||
const [videoHtmlEl, setVideoHtmlEl] = useState<HTMLVideoElement | undefined>(undefined)
|
||||
const videoRef = useRef<HTMLVideoElement | null>(null)
|
||||
@@ -340,23 +341,35 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({
|
||||
}
|
||||
}, [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<VideoPlayerProps> = ({
|
||||
totalFrames={totalFrames}
|
||||
currentFrame={currentFrame}
|
||||
seekToFrame={seekToFrame}
|
||||
onMouseEnter={handleControlsMouseEnter}
|
||||
onMouseLeave={handleControlsMouseLeave}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user