fix: calculateBackgroundRendering may return width or height less than 1

This commit is contained in:
herbert 2022-10-28 20:29:43 +08:00
parent 6020386bbe
commit 2f2e96b6a2

View File

@ -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];
};