提交 b0a708d4 编写于 作者: H hdx

overflow-visible-event: 调整 getBoundingClientRectAsync

上级 af378c99
...@@ -97,8 +97,8 @@ ...@@ -97,8 +97,8 @@
this.jest_result = true; this.jest_result = true;
} }
}, },
jest_getRect() { async jest_getRect() {
const rect = uni.getElementById('child')?.getBoundingClientRect() const rect = await uni.getElementById('child')!.getBoundingClientRectAsync()
if (rect != null) { if (rect != null) {
let ratio = 1 let ratio = 1
if (uni.getSystemInfoSync().platform == 'android'){ if (uni.getSystemInfoSync().platform == 'android'){
...@@ -120,8 +120,8 @@ ...@@ -120,8 +120,8 @@
this.jest_parent_top = Math.round((parseFloat(value) * ratio)) this.jest_parent_top = Math.round((parseFloat(value) * ratio))
} }
}, },
jest_getAbsoluteViewRect() { async jest_getAbsoluteViewRect() {
const rect = uni.getElementById('absolute-view')?.getBoundingClientRect() const rect = await uni.getElementById('absolute-view')!.getBoundingClientRectAsync()
if (rect != null) { if (rect != null) {
const systemInfo = uni.getSystemInfoSync() const systemInfo = uni.getSystemInfoSync()
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
...@@ -133,9 +133,9 @@ ...@@ -133,9 +133,9 @@
this.jest_click_y = (rect.top + titleBarHeight) * ratio + 30 this.jest_click_y = (rect.top + titleBarHeight) * ratio + 30
} }
}, },
jest_scrollToDeepOverflow() { async jest_scrollToDeepOverflow() {
const scrollView = uni.getElementById('scroll-view') as UniScrollViewElement 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) { if (rect != null) {
scrollView.scrollTo(0, rect.top) scrollView.scrollTo(0, rect.top)
setTimeout(() => { setTimeout(() => {
...@@ -145,11 +145,12 @@ ...@@ -145,11 +145,12 @@
ratio = uni.getSystemInfoSync().devicePixelRatio ratio = uni.getSystemInfoSync().devicePixelRatio
} }
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
const afterRect = uni.getElementById('deep-overflow')?.getBoundingClientRect() uni.getElementById('deep-overflow')!.getBoundingClientRectAsync().then((afterRect: DOMRect) => {
if (afterRect != null) { if (afterRect != null) {
this.jest_click_x = afterRect.x * ratio + 30 this.jest_click_x = afterRect.x * ratio + 30
this.jest_click_y = (afterRect.top + titleBarHeight) * ratio + 30 this.jest_click_y = (afterRect.top + titleBarHeight) * ratio + 30
} }
})
}, 200) }, 200)
} }
} }
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
async calcInputRemainHeight() { async calcInputRemainHeight() {
let windowHeight = uni.getWindowInfo().windowHeight let windowHeight = uni.getWindowInfo().windowHeight
const rect = await uni.getElementById('input')!.getBoundingClientRectAsync() const rect = await uni.getElementById('input')!.getBoundingClientRectAsync()
this.inputRemainHeight = windowHeight - rect.bottom ?? windowHeight this.inputRemainHeight = windowHeight - rect.bottom
} }
}, },
onReady() { onReady() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册