mirror of
https://github.com/Qortal/qapp-core.git
synced 2025-07-13 04:41:27 +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 [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,12 +157,12 @@ 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);
|
||||||
|
|
||||||
rndRef.current.updatePosition({
|
rndRef.current.updatePosition({
|
||||||
x: screenWidth - maxWidth - margin,
|
x: screenWidth - maxWidth - margin,
|
||||||
y: screenHeight - maxHeight - margin,
|
y: screenHeight - maxHeight - margin,
|
||||||
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user