提交 0b951390 编写于 作者: H hdx

fix(getBoundingClientRectAsync): Android 编译失败问题

上级 b16de6dd
......@@ -98,7 +98,7 @@
}
},
async jest_getRect() {
const rect = await uni.getElementById('child')!.getBoundingClientRectAsync()
const rect = await uni.getElementById('child')!.getBoundingClientRectAsync()!
let ratio = 1
if (uni.getSystemInfoSync().platform == 'android'){
ratio = uni.getSystemInfoSync().devicePixelRatio
......@@ -119,7 +119,7 @@
}
},
async jest_getAbsoluteViewRect() {
const rect = await uni.getElementById('absolute-view')!.getBoundingClientRectAsync()
const rect = await uni.getElementById('absolute-view')!.getBoundingClientRectAsync()!
const systemInfo = uni.getSystemInfoSync()
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
let ratio = 1
......@@ -131,7 +131,7 @@
},
async jest_scrollToDeepOverflow() {
const scrollView = uni.getElementById('scroll-view') as UniScrollViewElement
const rect = await uni.getElementById('deep-overflow')!.getBoundingClientRectAsync()
const rect = await uni.getElementById('deep-overflow')!.getBoundingClientRectAsync()!
scrollView.scrollTo(0, rect.top)
setTimeout(() => {
const systemInfo = uni.getSystemInfoSync()
......@@ -140,7 +140,7 @@
ratio = uni.getSystemInfoSync().devicePixelRatio
}
const titleBarHeight = systemInfo.screenHeight - systemInfo.windowHeight
uni.getElementById('deep-overflow')!.getBoundingClientRectAsync().then((afterRect: DOMRect) => {
uni.getElementById('deep-overflow')!.getBoundingClientRectAsync()!.then((afterRect: DOMRect) => {
this.jest_click_x = afterRect.x * ratio + 30
this.jest_click_y = (afterRect.top + titleBarHeight) * ratio + 30
})
......
......@@ -68,7 +68,7 @@
},
updateRichTextHeight() {
if (this.richTextElement != null) {
this.richTextElement!.getBoundingClientRectAsync().then((elRect: DOMRect) => {
this.richTextElement!.getBoundingClientRectAsync()!.then((elRect: DOMRect) => {
this.richTextHeight = elRect.height
console.log('richTextHeight:', this.richTextHeight)
})
......
......@@ -75,7 +75,7 @@
},
onReady() {
// this.setSelectedIndex(0)
(this.$refs["tabview"] as UniElement).getBoundingClientRectAsync().then((res: DOMRect) => {
(this.$refs["tabview"] as UniElement).getBoundingClientRectAsync()!.then((res: DOMRect) => {
this.tabViewHeight = res.height
});
},
......
......@@ -165,16 +165,16 @@
onReady() {
this.halfNode = this.$refs['halfScreen'] as UniElement;//uni.getElementById('halfScreen');
this.scrollNode = this.$refs['halfScroll'] as UniElement;//uni.getElementById('halfScroll');
this.halfNode!.getBoundingClientRectAsync().then((rect: DOMRect) => {
this.halfNode!.getBoundingClientRectAsync()!.then((rect: DOMRect) => {
this.halfHeight = rect.height
});
(this.$refs['page'] as UniElement).getBoundingClientRectAsync().then((rect: DOMRect) => {
(this.$refs['page'] as UniElement).getBoundingClientRectAsync()!.then((rect: DOMRect) => {
this.totalHeight = rect.height
this.halfNode?.style?.setProperty('top', this.totalHeight.toFixed(2)+'px');
});
},
onResize() {
this.halfNode?.getBoundingClientRectAsync().then((rect: DOMRect) => {
this.halfNode?.getBoundingClientRectAsync()!.then((rect: DOMRect) => {
this.halfHeight = rect.height
});
this.totalHeight = uni.getWindowInfo().windowHeight;
......
......@@ -93,7 +93,7 @@
this.headerHeight = (this.$refs['header'] as UniElement).offsetHeight
this.tabScrollView = this.$refs['tabScroll'] as UniElement
this.indicatorNode = this.$refs['indicator'] as UniElement
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync().then((res : DOMRect) : Promise<void> => {
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync()!.then((res : DOMRect) : Promise<void> => {
this.swiperWidth = res.width
return this.cacheTabItemsSize()
}).then(() => {
......@@ -179,7 +179,7 @@
const tabs = this.$refs["swipertab"] as UniElement[]
for (let i = 0; i < tabs.length; i++) {
const element = tabs[i];
const rect = await element.getBoundingClientRectAsync()
const rect = await element.getBoundingClientRectAsync()!
this.swiperTabsRect.push({
x: rect.left,
w: rect.width
......
......@@ -121,7 +121,7 @@
},
async calcInputRemainHeight() {
let windowHeight = uni.getWindowInfo().windowHeight
const rect = await uni.getElementById('input')!.getBoundingClientRectAsync()
const rect = await uni.getElementById('input')!.getBoundingClientRectAsync()!
this.inputRemainHeight = windowHeight - rect.bottom
}
},
......
......@@ -68,8 +68,8 @@
// let rect = this.stickyNode?.getBoundingClientRect();
// this.stickyTop = rect?.top;
//this.stickyTop = this.stickyNode?.getBoundingClientRect()?.top;
const stickyRect = await (this.$refs['sticky'] as UniElement).getBoundingClientRectAsync();
const scrollRect = await (this.$refs['scroll'] as UniElement).getBoundingClientRectAsync();
const stickyRect = await (this.$refs['sticky'] as UniElement).getBoundingClientRectAsync()!;
const scrollRect = await (this.$refs['scroll'] as UniElement).getBoundingClientRectAsync()!;
this.stickyTop = stickyRect.top - scrollRect.top;
console.log(stickyRect, scrollRect);
}
......
......@@ -66,7 +66,7 @@
onReady() {
this.tabScrollView = this.$refs['tabScroll'] as UniElement;
this.indicatorNode = this.$refs['indicator'] as UniElement;
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync().then((res : DOMRect) : Promise<void> => {
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync()!.then((res : DOMRect) : Promise<void> => {
this.swiperWidth = res.width
return this.cacheTabItemsSize()
}).then(() => {
......@@ -128,7 +128,7 @@
const tabs = this.$refs["swipertab"] as UniElement[]
for (let i = 0; i < tabs.length; i++) {
const element = tabs[i];
const rect = await element.getBoundingClientRectAsync()
const rect = await element.getBoundingClientRectAsync()!
this.swiperTabsRect.push({
x: rect.left,
w: rect.width
......
......@@ -54,7 +54,7 @@
},
onReady() {
this.tabScrollView = this.$refs['tabScroll'] as UniElement;
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync().then((res : DOMRect) => {
(this.$refs["swiper"] as UniElement).getBoundingClientRectAsync()!.then((res : DOMRect) => {
this.swiperWidth = res.width
this.updateTabIndicator(this.swiperIndex, this.swiperIndex, 1)
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册