From 9b8c534f3556c0ef9ed8a27c3d5dccebbb91abfd Mon Sep 17 00:00:00 2001 From: ruilongzhang Date: Wed, 29 Oct 2025 10:16:04 +0800 Subject: [PATCH] fix: The width and height of the source node can be greater than the actual values, but they cannot be less than the actual values. Otherwise, when aligning right and aligning down, it will cause the scrolling behavior when the parent box property overflow is set to auto; --- src/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils.js b/src/utils.js index b2c96f9..2742a7b 100644 --- a/src/utils.js +++ b/src/utils.js @@ -458,8 +458,8 @@ function getWH(elem, name, ex) { const which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom']; let borderBoxValue = name === 'width' - ? Math.floor(elem.getBoundingClientRect().width) - : Math.floor(elem.getBoundingClientRect().height); + ? Math.ceil(elem.getBoundingClientRect().width) + : Math.ceil(elem.getBoundingClientRect().height); const isBorderBox = isBorderBoxFn(elem); let cssBoxValue = 0; if ( @@ -478,7 +478,7 @@ function getWH(elem, name, ex) { cssBoxValue = elem.style[name] || 0; } // Normalize '', auto, and prepare for extra - cssBoxValue = Math.floor(parseFloat(cssBoxValue)) || 0; + cssBoxValue = Math.ceil(parseFloat(cssBoxValue)) || 0; } if (extra === undefined) { extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;