Fix being unable to hide controls in full screen video in web UI ()

This commit is contained in:
Eugen Rochko 2025-03-31 10:17:57 +02:00 committed by GitHub
parent 19346fd5f8
commit 70e14c1ed0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions
app/javascript
mastodon/features/video
styles/mastodon

View file

@ -57,6 +57,7 @@ const messages = defineMessages({
});
const DOUBLE_CLICK_THRESHOLD = 250;
const HOVER_FADE_DELAY = 4000;
export const formatTime = (secondsNum: number) => {
const hours = Math.floor(secondsNum / 3600);
@ -232,6 +233,7 @@ export const Video: React.FC<{
const seekRef = useRef<HTMLDivElement>(null);
const volumeRef = useRef<HTMLDivElement>(null);
const doubleClickTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>();
const hoverTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>();
const [style, api] = useSpring(() => ({
progress: '0%',
@ -666,6 +668,26 @@ export const Video: React.FC<{
const handleMouseEnter = useCallback(() => {
setHovered(true);
if (hoverTimeoutRef.current) {
clearTimeout(hoverTimeoutRef.current);
}
hoverTimeoutRef.current = setTimeout(() => {
setHovered(false);
}, HOVER_FADE_DELAY);
}, [setHovered]);
const handleMouseMove = useCallback(() => {
setHovered(true);
if (hoverTimeoutRef.current) {
clearTimeout(hoverTimeoutRef.current);
}
hoverTimeoutRef.current = setTimeout(() => {
setHovered(false);
}, HOVER_FADE_DELAY);
}, [setHovered]);
const handleMouseLeave = useCallback(() => {
@ -795,6 +817,7 @@ export const Video: React.FC<{
style={{ aspectRatio }}
ref={playerRef}
onMouseEnter={handleMouseEnter}
onMouseMove={handleMouseMove}
onMouseLeave={handleMouseLeave}
onClick={handleClickRoot}
onKeyDown={handleKeyDown}

View file

@ -7075,6 +7075,8 @@ a.status-card {
height: 100% !important;
margin: 0;
aspect-ratio: auto !important;
outline: none;
border-radius: 0;
video {
width: 100% !important;