From b69c1828cbd6129700e47cdcaf287f75a7aefe2e Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Thu, 2 May 2024 15:05:20 -0500 Subject: [PATCH] Fix overflowing portrait images in debug and motion tuner views (#11209) * fix overflowing camera image and remove mse console debug * move calc into onLoad * check container aspect --- web/src/components/camera/CameraImage.tsx | 14 +++++++++++++- web/src/components/player/MsePlayer.tsx | 6 ++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/web/src/components/camera/CameraImage.tsx b/web/src/components/camera/CameraImage.tsx index ab0bfdf08..b4fb707bc 100644 --- a/web/src/components/camera/CameraImage.tsx +++ b/web/src/components/camera/CameraImage.tsx @@ -2,6 +2,7 @@ import { useApiHost } from "@/api"; import { useEffect, useRef, useState } from "react"; import useSWR from "swr"; import ActivityIndicator from "../indicators/activity-indicator"; +import { useResizeObserver } from "@/hooks/resize-observer"; type CameraImageProps = { className?: string; @@ -24,6 +25,7 @@ export default function CameraImage({ const { name } = config ? config.cameras[camera] : ""; const enabled = config ? config.cameras[camera].enabled : "True"; + const [isPortraitImage, setIsPortraitImage] = useState(false); useEffect(() => { if (!config || !imgRef.current) { @@ -35,15 +37,25 @@ export default function CameraImage({ }`; }, [apiHost, name, imgRef, searchParams, config]); + const [{ width: containerWidth, height: containerHeight }] = + useResizeObserver(containerRef); + return (