From c33991ee14b8108bcd084b5d7b59f35cb79b2b35 Mon Sep 17 00:00:00 2001 From: weisheng <1780903673@qq.com> Date: Sun, 7 Jul 2024 23:24:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8DIndexBa?= =?UTF-8?q?r=E7=82=B9=E5=87=BB=E7=B4=A2=E5=BC=95=E5=BA=8F=E5=8F=B7?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E6=98=BE=E7=A4=BA=E9=A2=84=E6=9C=9F=E7=B4=A2?= =?UTF-8?q?=E5=BC=95=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #408 --- .../components/wd-index-anchor/wd-index-anchor.vue | 2 +- .../components/wd-index-bar/wd-index-bar.vue | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/uni_modules/wot-design-uni/components/wd-index-anchor/wd-index-anchor.vue b/src/uni_modules/wot-design-uni/components/wd-index-anchor/wd-index-anchor.vue index 402a0765..67a808a3 100644 --- a/src/uni_modules/wot-design-uni/components/wd-index-anchor/wd-index-anchor.vue +++ b/src/uni_modules/wot-design-uni/components/wd-index-anchor/wd-index-anchor.vue @@ -35,7 +35,7 @@ function getInfo() { getRect(`#${indexAnchorId.value}`, false, proxy).then((res) => { if (isDef(indexBar)) { const anchor = indexBar.anchorState.anchorList.find((v) => v.index === props.index)! - anchor.top = res.top! + anchor.top = Math.floor(res.top!) } }) } diff --git a/src/uni_modules/wot-design-uni/components/wd-index-bar/wd-index-bar.vue b/src/uni_modules/wot-design-uni/components/wd-index-bar/wd-index-bar.vue index 75de549e..3dd4412e 100644 --- a/src/uni_modules/wot-design-uni/components/wd-index-bar/wd-index-bar.vue +++ b/src/uni_modules/wot-design-uni/components/wd-index-bar/wd-index-bar.vue @@ -82,12 +82,15 @@ onMounted(() => { function hanleScroll(scrollEvent: any) { const { detail } = scrollEvent + const scrolltop = Math.floor(detail.scrollTop) const anchor = state.anchorList.find((item, index) => { 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 })! - state.activeIndex = anchor.index + if (state.activeIndex !== anchor.index) { + state.activeIndex = anchor.index + } } function getAnchorByPageY(pageY: number) {