mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 05:35:25 +03:00
check container aspect
This commit is contained in:
parent
d55d862d3e
commit
23335e4678
@ -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;
|
||||
@ -36,6 +37,9 @@ export default function CameraImage({
|
||||
}`;
|
||||
}, [apiHost, name, imgRef, searchParams, config]);
|
||||
|
||||
const [{ width: containerWidth, height: containerHeight }] =
|
||||
useResizeObserver(containerRef);
|
||||
|
||||
return (
|
||||
<div className={className} ref={containerRef}>
|
||||
{enabled ? (
|
||||
@ -47,7 +51,9 @@ export default function CameraImage({
|
||||
|
||||
if (imgRef.current) {
|
||||
const { naturalHeight, naturalWidth } = imgRef.current;
|
||||
setIsPortraitImage(naturalHeight > naturalWidth);
|
||||
setIsPortraitImage(
|
||||
naturalWidth / naturalHeight < containerWidth / containerHeight,
|
||||
);
|
||||
}
|
||||
|
||||
if (onload) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user