mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-11 13:45: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 { useEffect, useRef, useState } from "react";
|
||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import ActivityIndicator from "../indicators/activity-indicator";
|
import ActivityIndicator from "../indicators/activity-indicator";
|
||||||
|
import { useResizeObserver } from "@/hooks/resize-observer";
|
||||||
|
|
||||||
type CameraImageProps = {
|
type CameraImageProps = {
|
||||||
className?: string;
|
className?: string;
|
||||||
@ -36,6 +37,9 @@ export default function CameraImage({
|
|||||||
}`;
|
}`;
|
||||||
}, [apiHost, name, imgRef, searchParams, config]);
|
}, [apiHost, name, imgRef, searchParams, config]);
|
||||||
|
|
||||||
|
const [{ width: containerWidth, height: containerHeight }] =
|
||||||
|
useResizeObserver(containerRef);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={className} ref={containerRef}>
|
<div className={className} ref={containerRef}>
|
||||||
{enabled ? (
|
{enabled ? (
|
||||||
@ -47,7 +51,9 @@ export default function CameraImage({
|
|||||||
|
|
||||||
if (imgRef.current) {
|
if (imgRef.current) {
|
||||||
const { naturalHeight, naturalWidth } = imgRef.current;
|
const { naturalHeight, naturalWidth } = imgRef.current;
|
||||||
setIsPortraitImage(naturalHeight > naturalWidth);
|
setIsPortraitImage(
|
||||||
|
naturalWidth / naturalHeight < containerWidth / containerHeight,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onload) {
|
if (onload) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user