mirror of
https://gitee.com/wot-design-uni/wot-design-uni.git
synced 2025-12-07 17:48:34 +08:00
parent
4741439277
commit
c33991ee14
@ -35,7 +35,7 @@ function getInfo() {
|
|||||||
getRect(`#${indexAnchorId.value}`, false, proxy).then((res) => {
|
getRect(`#${indexAnchorId.value}`, false, proxy).then((res) => {
|
||||||
if (isDef(indexBar)) {
|
if (isDef(indexBar)) {
|
||||||
const anchor = indexBar.anchorState.anchorList.find((v) => v.index === props.index)!
|
const anchor = indexBar.anchorState.anchorList.find((v) => v.index === props.index)!
|
||||||
anchor.top = res.top!
|
anchor.top = Math.floor(res.top!)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,12 +82,15 @@ onMounted(() => {
|
|||||||
|
|
||||||
function hanleScroll(scrollEvent: any) {
|
function hanleScroll(scrollEvent: any) {
|
||||||
const { detail } = scrollEvent
|
const { detail } = scrollEvent
|
||||||
|
const scrolltop = Math.floor(detail.scrollTop)
|
||||||
const anchor = state.anchorList.find((item, index) => {
|
const anchor = state.anchorList.find((item, index) => {
|
||||||
if (!isDef(state.anchorList[index + 1])) return true
|
if (!isDef(state.anchorList[index + 1])) return true
|
||||||
if (item.top - offsetTop <= detail.scrollTop && state.anchorList[index + 1].top - offsetTop > detail.scrollTop) return true
|
if (item.top - offsetTop <= scrolltop && state.anchorList[index + 1].top - offsetTop > scrolltop) return true
|
||||||
return false
|
return false
|
||||||
})!
|
})!
|
||||||
state.activeIndex = anchor.index
|
if (state.activeIndex !== anchor.index) {
|
||||||
|
state.activeIndex = anchor.index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAnchorByPageY(pageY: number) {
|
function getAnchorByPageY(pageY: number) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user