From ade2d93331f1429deaa245abf1aab2cce91f3f38 Mon Sep 17 00:00:00 2001 From: Gene Date: Mon, 22 Apr 2024 17:56:48 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E5=88=B0=E8=8A=82=E7=82=B9=E7=9A=84=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E9=80=82=E9=85=8D=E8=B6=85=E5=AE=BD=E8=B6=85=E9=AB=98=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=20(#428)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/container/container.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/canvas/src/components/container/container.js b/packages/canvas/src/components/container/container.js index ec547a8..0d438fd 100644 --- a/packages/canvas/src/components/container/container.js +++ b/packages/canvas/src/components/container/container.js @@ -320,19 +320,19 @@ export const scrollToNode = (element) => { if (element) { const container = getDocument().documentElement const { clientWidth, clientHeight } = container - const { x, y, width, height } = element.getBoundingClientRect() + const { left, right, top, bottom, width, height } = element.getBoundingClientRect() const option = {} - if (x < 0) { - option.left = container.scrollLeft + x - SCROLL_MARGIN - } else if (x > clientWidth) { - option.left = x + width - clientWidth + SCROLL_MARGIN + if (right < 0) { + option.left = container.scrollLeft + left - SCROLL_MARGIN + } else if (left > clientWidth) { + option.left = container.scrollLeft + left - clientWidth + width + SCROLL_MARGIN } - if (y < 0) { - option.top = container.scrollTop + y - SCROLL_MARGIN - } else if (y > clientHeight) { - option.top = y + height - clientHeight + SCROLL_MARGIN + if (bottom < 0) { + option.top = container.scrollTop + top - SCROLL_MARGIN + } else if (top > clientHeight) { + option.top = container.scrollTop + top - clientHeight + height + SCROLL_MARGIN } if (typeof option.left === 'number' || typeof option.top === 'number') {