diff --git a/src/pages/watch/Watch.jsx b/src/pages/watch/Watch.jsx index 92ffc59..3af6777 100644 --- a/src/pages/watch/Watch.jsx +++ b/src/pages/watch/Watch.jsx @@ -83,7 +83,7 @@ export default function Watch() { } = useWatchControl(); const videoContainerRef = useRef(null); - const controlsRef = useRef(null); + const playerRef = useRef(null); const episodesRef = useRef(null); // Sync URL with episodeId @@ -116,20 +116,20 @@ export default function Watch() { // Height adjustment logic const adjustHeight = useCallback(() => { if (window.innerWidth > 1200) { - if (videoContainerRef.current && controlsRef.current && episodesRef.current) { - const totalHeight = videoContainerRef.current.offsetHeight + controlsRef.current.offsetHeight; - episodesRef.current.style.height = `${totalHeight}px`; + if (playerRef.current && episodesRef.current) { + episodesRef.current.style.height = 'auto'; + episodesRef.current.style.maxHeight = `${playerRef.current.offsetHeight}px`; } } else if (episodesRef.current) { episodesRef.current.style.height = 'auto'; + episodesRef.current.style.maxHeight = 'none'; } }, []); useEffect(() => { const resizeObserver = new ResizeObserver(adjustHeight); - if (videoContainerRef.current) resizeObserver.observe(videoContainerRef.current); - if (controlsRef.current) resizeObserver.observe(controlsRef.current); + if (playerRef.current) resizeObserver.observe(playerRef.current); window.addEventListener('resize', adjustHeight); adjustHeight(); @@ -193,11 +193,11 @@ export default function Watch() {