fix ;bug
This commit is contained in:
@@ -251,6 +251,8 @@
|
||||
})
|
||||
},
|
||||
setScrollLeft() {
|
||||
setTimeout(()=> {
|
||||
|
||||
// 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息
|
||||
const tabRect = this.list[this.innerCurrent]
|
||||
// 累加得到当前item到左边的距离
|
||||
@@ -261,12 +263,14 @@
|
||||
}, 0)
|
||||
// 此处为屏幕宽度
|
||||
const windowWidth = this.$uv.sys().windowWidth
|
||||
let _rect = tabRect?.rect?.width||0
|
||||
// 将活动的tabs-item移动到屏幕正中间,实际上是对scroll-view的移动
|
||||
let scrollLeft = offsetLeft - (this.tabsRect.width - tabRect.rect.width) / 2 - (windowWidth - this.tabsRect
|
||||
let scrollLeft = offsetLeft - (this.tabsRect.width - _rect) / 2 - (windowWidth - this.tabsRect
|
||||
.right) / 2 + this.tabsRect.left / 2
|
||||
// 这里做一个限制,限制scrollLeft的最大值为整个scroll-view宽度减去tabs组件的宽度
|
||||
scrollLeft = Math.min(scrollLeft, this.scrollViewWidth - this.tabsRect.width)
|
||||
this.scrollLeft = Math.max(0, scrollLeft)
|
||||
},200)
|
||||
},
|
||||
// 获取所有标签的尺寸
|
||||
resize() {
|
||||
|
||||
Reference in New Issue
Block a user