From a34fe0513382cb6be1a36b65d9b022e5ad1ad7f3 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Tue, 16 Apr 2024 01:01:00 -0700 Subject: [PATCH 1/2] =?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?= 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 5812825761..b1fd9ef6e4 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 } = 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 = right - clientWidth + 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 = bottom - clientHeight + SCROLL_MARGIN } if (typeof option.left === 'number' || typeof option.top === 'number') { From 45f61907ad92a447fb00dce87063b77efda89ff6 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Tue, 16 Apr 2024 19:35:38 -0700 Subject: [PATCH 2/2] =?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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/canvas/src/components/container/container.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/canvas/src/components/container/container.js b/packages/canvas/src/components/container/container.js index b1fd9ef6e4..d1a7898343 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 { left, right, top, bottom } = element.getBoundingClientRect() + const { left, right, top, bottom, width, height } = element.getBoundingClientRect() const option = {} if (right < 0) { option.left = container.scrollLeft + left - SCROLL_MARGIN } else if (left > clientWidth) { - option.left = right - clientWidth + SCROLL_MARGIN + option.left = container.scrollLeft + left - clientWidth + width + SCROLL_MARGIN } if (bottom < 0) { option.top = container.scrollTop + top - SCROLL_MARGIN } else if (top > clientHeight) { - option.top = bottom - clientHeight + SCROLL_MARGIN + option.top = container.scrollTop + top - clientHeight + height + SCROLL_MARGIN } if (typeof option.left === 'number' || typeof option.top === 'number') {