From b0a708d431cab14ec9c4d7a4101d6d2e2ea25f7e Mon Sep 17 00:00:00 2001 From: hdx Date: Mon, 11 Nov 2024 15:19:11 +0800 Subject: [PATCH] =?UTF-8?q?overflow-visible-event:=20=E8=B0=83=E6=95=B4=20?= =?UTF-8?q?getBoundingClientRectAsync?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CSS/overflow/overflow-visible-event.uvue | 23 ++++++++++--------- pages/template/navbar-lite/navbar-lite.uvue | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/pages/CSS/overflow/overflow-visible-event.uvue b/pages/CSS/overflow/overflow-visible-event.uvue index 6b08d69f..d9854339 100644 --- a/pages/CSS/overflow/overflow-visible-event.uvue +++ b/pages/CSS/overflow/overflow-visible-event.uvue @@ -97,8 +97,8 @@ this.jest_result = true; } }, - jest_getRect() { - const rect = uni.getElementById('child')?.getBoundingClientRect() + async jest_getRect() { + const rect = await uni.getElementById('child')!.getBoundingClientRectAsync() if (rect != null) { let ratio = 1 if (uni.getSystemInfoSync().platform == 'android'){ @@ -120,8 +120,8 @@ this.jest_parent_top = Math.round((parseFloat(value) * ratio)) } }, - jest_getAbsoluteViewRect() { - const rect = uni.getElementById('absolute-view')?.getBoundingClientRect() + async jest_getAbsoluteViewRect() { + const rect = await uni.getElementById('absolute-view')!.getBoundingClientRectAsync() if (rect != null) { const systemInfo = uni.getSystemInfoSync() const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight @@ -133,9 +133,9 @@ this.jest_click_y = (rect.top + titleBarHeight) * ratio + 30 } }, - jest_scrollToDeepOverflow() { + async jest_scrollToDeepOverflow() { const scrollView = uni.getElementById('scroll-view') as UniScrollViewElement - const rect = uni.getElementById('deep-overflow')?.getBoundingClientRect() + const rect = await uni.getElementById('deep-overflow')!.getBoundingClientRectAsync() if (rect != null) { scrollView.scrollTo(0, rect.top) setTimeout(() => { @@ -145,11 +145,12 @@ ratio = uni.getSystemInfoSync().devicePixelRatio } const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight - const afterRect = uni.getElementById('deep-overflow')?.getBoundingClientRect() - if (afterRect != null) { - this.jest_click_x = afterRect.x * ratio + 30 - this.jest_click_y = (afterRect.top + titleBarHeight) * ratio + 30 - } + uni.getElementById('deep-overflow')!.getBoundingClientRectAsync().then((afterRect: DOMRect) => { + if (afterRect != null) { + this.jest_click_x = afterRect.x * ratio + 30 + this.jest_click_y = (afterRect.top + titleBarHeight) * ratio + 30 + } + }) }, 200) } } diff --git a/pages/template/navbar-lite/navbar-lite.uvue b/pages/template/navbar-lite/navbar-lite.uvue index 5b2f7860..c71f9b6d 100644 --- a/pages/template/navbar-lite/navbar-lite.uvue +++ b/pages/template/navbar-lite/navbar-lite.uvue @@ -120,7 +120,7 @@ async calcInputRemainHeight() { let windowHeight = uni.getWindowInfo().windowHeight const rect = await uni.getElementById('input')!.getBoundingClientRectAsync() - this.inputRemainHeight = windowHeight - rect.bottom ?? windowHeight + this.inputRemainHeight = windowHeight - rect.bottom } }, onReady() { -- GitLab