From 2f2e96b6a2e7bdc9bd4f0b037f238408de7fbf89 Mon Sep 17 00:00:00 2001 From: herbert Date: Fri, 28 Oct 2022 20:29:43 +0800 Subject: [PATCH] fix: calculateBackgroundRendering may return width or height less than 1 --- src/render/background.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/render/background.ts b/src/render/background.ts index 6e0e877..dd92d17 100644 --- a/src/render/background.ts +++ b/src/render/background.ts @@ -58,7 +58,7 @@ export const calculateBackgroundRendering = ( backgroundPositioningArea ); - const [sizeWidth, sizeHeight] = backgroundImageSize; + let [sizeWidth, sizeHeight] = backgroundImageSize; const position = getAbsoluteValueForTuple( getBackgroundValueForIndex(container.styles.backgroundPosition, index), @@ -77,6 +77,9 @@ export const calculateBackgroundRendering = ( const offsetX = Math.round(backgroundPositioningArea.left + position[0]); const offsetY = Math.round(backgroundPositioningArea.top + position[1]); + sizeWidth = Math.max(1,sizeWidth) + sizeHeight = Math.max(1,sizeHeight) + return [path, offsetX, offsetY, sizeWidth, sizeHeight]; };