From bfb09725fbb0bb000d6ad8146c22cd17ee8ccaa3 Mon Sep 17 00:00:00 2001 From: hdx Date: Fri, 26 Jan 2024 19:35:14 +0800 Subject: [PATCH] =?UTF-8?q?long-list:=20=E6=92=A4=E5=9B=9E=20Math.floor=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E7=BA=BF=E8=B7=B3=E5=8A=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/long-list/long-list.uvue | 3 ++- pages/template/long-list2/long-list2.uvue | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 18f01110..f76c2afe 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -148,7 +148,7 @@ // 计算当前索引并重置差异 const current_offset_x = offset_x % this.$swiperWidth const current_offset_i = offset_x / this.$swiperWidth - const current_index = this.$animationFinishIndex + Math.floor(current_offset_i) + const current_index = this.$animationFinishIndex + parseInt(current_offset_i + '') // 计算目标索引及边界检查 let move_to_index = current_index @@ -170,6 +170,7 @@ onSwiperAnimationfinish(e : SwiperAnimationFinishEvent) { this.setSwiperIndex(e.detail.current, true) this.$animationFinishIndex = e.detail.current + console.log('this.$animationFinishIndex', e.detail.current); }, cacheTabItemsSize() { this.$swiperTabsRect.length = 0 diff --git a/pages/template/long-list2/long-list2.uvue b/pages/template/long-list2/long-list2.uvue index 006007bf..989648a3 100644 --- a/pages/template/long-list2/long-list2.uvue +++ b/pages/template/long-list2/long-list2.uvue @@ -151,7 +151,7 @@ // 计算当前索引并重置差异 const current_offset_x = offset_x % this.$swiperWidth const current_offset_i = offset_x / this.$swiperWidth - const current_index = this.$animationFinishIndex + Math.floor(current_offset_i) + const current_index = this.$animationFinishIndex + parseInt(current_offset_i + '') // 计算目标索引及边界检查 let move_to_index = current_index -- GitLab