fix max height and width for global player

This commit is contained in:
PhilReact 2025-06-22 18:02:34 +03:00
parent b01232b39f
commit 378ec78c25

View File

@ -144,6 +144,8 @@ export const GlobalPipPlayer = () => {
const [height, setHeight] = useState(300); const [height, setHeight] = useState(300);
const [width, setWidth] = useState(400); const [width, setWidth] = useState(400);
const savedHeightRef = useRef<null | number>(null)
const savedWidthRef = useRef<null | number>(null)
useEffect(() => { useEffect(() => {
if (!videoSrc) return; if (!videoSrc) return;
@ -155,8 +157,8 @@ useEffect(() => {
const maxWidthByScreen = screenWidth * 0.75; const maxWidthByScreen = screenWidth * 0.75;
const maxWidthByHeight = (screenHeight * 0.2) / aspectRatio; const maxWidthByHeight = (screenHeight * 0.2) / aspectRatio;
const maxWidth = Math.min(maxWidthByScreen, maxWidthByHeight); const maxWidth = savedWidthRef.current || Math.min(maxWidthByScreen, maxWidthByHeight);
const maxHeight = maxWidth * aspectRatio; const maxHeight = savedHeightRef.current || maxWidth * aspectRatio;
setWidth(maxWidth); setWidth(maxWidth);
setHeight(maxHeight); setHeight(maxHeight);
@ -271,6 +273,8 @@ useEffect(() => {
onResize={(e, direction, ref, delta, position) => { onResize={(e, direction, ref, delta, position) => {
setWidth(ref.offsetWidth); setWidth(ref.offsetWidth);
setHeight(ref.offsetHeight); setHeight(ref.offsetHeight);
savedHeightRef.current = ref.offsetHeight
savedWidthRef.current = ref.offsetWidth
}} }}
// default={{ // default={{
// x: 500, // x: 500,