mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-20 04:40:27 +01:00
Auto hide control after 5 seconds
This commit is contained in:
@@ -280,8 +280,38 @@ export const Controls: React.FC<Props> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
prefetchAllTrickplayImages();
|
prefetchAllTrickplayImages();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const CONTROLS_TIMEOUT = 5000;
|
||||||
|
const controlsTimeoutRef = useRef<NodeJS.Timeout>();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const resetControlsTimeout = () => {
|
||||||
|
if (controlsTimeoutRef.current) {
|
||||||
|
clearTimeout(controlsTimeoutRef.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showControls && !isSliding && !EpisodeView) {
|
||||||
|
controlsTimeoutRef.current = setTimeout(() => {
|
||||||
|
setShowControls(false);
|
||||||
|
setShowAudioSlider(false);
|
||||||
|
}, CONTROLS_TIMEOUT);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
resetControlsTimeout();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (controlsTimeoutRef.current) {
|
||||||
|
clearTimeout(controlsTimeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [showControls, isSliding, EpisodeView]);
|
||||||
|
|
||||||
const toggleControls = () => {
|
const toggleControls = () => {
|
||||||
if (showControls) {
|
if (showControls) {
|
||||||
|
if (controlsTimeoutRef.current) {
|
||||||
|
clearTimeout(controlsTimeoutRef.current);
|
||||||
|
}
|
||||||
setShowAudioSlider(false);
|
setShowAudioSlider(false);
|
||||||
setShowControls(false);
|
setShowControls(false);
|
||||||
} else {
|
} else {
|
||||||
@@ -289,6 +319,18 @@ export const Controls: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleControlsInteraction = () => {
|
||||||
|
if (showControls) {
|
||||||
|
if (controlsTimeoutRef.current) {
|
||||||
|
clearTimeout(controlsTimeoutRef.current);
|
||||||
|
}
|
||||||
|
controlsTimeoutRef.current = setTimeout(() => {
|
||||||
|
setShowControls(false);
|
||||||
|
setShowAudioSlider(false);
|
||||||
|
}, CONTROLS_TIMEOUT);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSliderStart = useCallback(() => {
|
const handleSliderStart = useCallback(() => {
|
||||||
if (showControls === false) return;
|
if (showControls === false) return;
|
||||||
|
|
||||||
@@ -731,6 +773,7 @@ export const Controls: React.FC<Props> = ({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
className={`flex flex-col p-4`}
|
className={`flex flex-col p-4`}
|
||||||
|
onTouchStart={handleControlsInteraction}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
className="shrink flex flex-col justify-center h-full mb-2"
|
className="shrink flex flex-col justify-center h-full mb-2"
|
||||||
|
|||||||
Reference in New Issue
Block a user