mirror of
https://github.com/Qortal/qapp-core.git
synced 2025-07-12 12:21:24 +00:00
fix max height and width for global player
This commit is contained in:
parent
b01232b39f
commit
378ec78c25
@ -144,6 +144,8 @@ export const GlobalPipPlayer = () => {
|
||||
|
||||
const [height, setHeight] = useState(300);
|
||||
const [width, setWidth] = useState(400);
|
||||
const savedHeightRef = useRef<null | number>(null)
|
||||
const savedWidthRef = useRef<null | number>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!videoSrc) return;
|
||||
@ -155,12 +157,12 @@ useEffect(() => {
|
||||
const maxWidthByScreen = screenWidth * 0.75;
|
||||
const maxWidthByHeight = (screenHeight * 0.2) / aspectRatio;
|
||||
|
||||
const maxWidth = Math.min(maxWidthByScreen, maxWidthByHeight);
|
||||
const maxHeight = maxWidth * aspectRatio;
|
||||
const maxWidth = savedWidthRef.current || Math.min(maxWidthByScreen, maxWidthByHeight);
|
||||
const maxHeight = savedHeightRef.current || maxWidth * aspectRatio;
|
||||
|
||||
setWidth(maxWidth);
|
||||
setHeight(maxHeight);
|
||||
|
||||
|
||||
rndRef.current.updatePosition({
|
||||
x: screenWidth - maxWidth - margin,
|
||||
y: screenHeight - maxHeight - margin,
|
||||
@ -271,6 +273,8 @@ useEffect(() => {
|
||||
onResize={(e, direction, ref, delta, position) => {
|
||||
setWidth(ref.offsetWidth);
|
||||
setHeight(ref.offsetHeight);
|
||||
savedHeightRef.current = ref.offsetHeight
|
||||
savedWidthRef.current = ref.offsetWidth
|
||||
}}
|
||||
// default={{
|
||||
// x: 500,
|
||||
|
Loading…
x
Reference in New Issue
Block a user