From d4b9bd2b3560c219702c916c7414b841d5cb8019 Mon Sep 17 00:00:00 2001 From: Scenery <1507337624@qq.com> Date: Sun, 18 Feb 2024 18:36:51 +0800 Subject: [PATCH] fix: image widget contain style --- .../src/widgetLibrary/ImageWidget/image.tsx | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/apps/builder/src/widgetLibrary/ImageWidget/image.tsx b/apps/builder/src/widgetLibrary/ImageWidget/image.tsx index 57a4b78d50..10e3b8a536 100644 --- a/apps/builder/src/widgetLibrary/ImageWidget/image.tsx +++ b/apps/builder/src/widgetLibrary/ImageWidget/image.tsx @@ -16,18 +16,12 @@ import { } from "@/widgetLibrary/ImageWidget/style" import { AutoHeightContainer } from "@/widgetLibrary/PublicSector/AutoHeightContainer" import { TooltipWrapper } from "@/widgetLibrary/PublicSector/TooltipWrapper" -import { - DynamicHeight, - ImageWidgetProps, - ObjectFit, - WrappedImageProps, -} from "./interface" +import { DynamicHeight, ImageWidgetProps, WrappedImageProps } from "./interface" const getHeight = ( dynamicHeight: DynamicHeight, aspectRatio: number, width: number, - objectFit?: ObjectFit, ) => { if (dynamicHeight === "auto") { if (aspectRatio && aspectRatio > 0) { @@ -36,9 +30,7 @@ const getHeight = ( return `${width}px` } } else { - return dynamicHeight === "fixed" || objectFit === "contain" - ? "100%" - : "auto" + return dynamicHeight === "fixed" ? "100%" : "auto" } } @@ -62,19 +54,10 @@ export const WrappedImage: FC = (props) => { ? "100%" : "auto" - const height = getHeight( - dynamicHeight, - aspectRatio, - imageBouds.width, - objectFit, - ) + const height = getHeight(dynamicHeight, aspectRatio, imageBouds.width) - const finalObjectFit = - dynamicHeight === "auto" - ? "cover" - : dynamicHeight === "fixed" && objectFit === "contain" - ? undefined - : "cover" + const finalObjectFit = dynamicHeight === "auto" ? "cover" : objectFit + console.log("finalObjectFit", finalObjectFit) return (