From 16903150dd66585999393ae37196c2318ef710ad Mon Sep 17 00:00:00 2001 From: hdx Date: Tue, 29 Aug 2023 18:38:58 +0800 Subject: [PATCH] =?UTF-8?q?swiper:=20=E4=BD=BF=E7=94=A8=E6=B5=AE=E7=82=B9?= =?UTF-8?q?=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/template/long-list/long-list.uvue | 6 +++--- pages/template/swiper-list/swiper-list.uvue | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 76874d58..855cd76d 100644 --- a/pages/template/long-list/long-list.uvue +++ b/pages/template/long-list/long-list.uvue @@ -80,7 +80,7 @@ }, onReady() { this.$headerHeight = (this.$refs["header"] as INode).offsetHeight - this.$swiperWidth = (this.$refs["swiper"] as INode).offsetWidth + this.$swiperWidth = (this.$refs["swiper"] as INode).getBoundingClientRect().width this.queryTabItemsSize() this.setSwiperIndex(0, true) }, @@ -91,8 +91,8 @@ onSwiperTransition(e : SwiperTransitionEvent) { const offsetX = e.detail.dx // 兼容微信 skyline 和 webview - const offsetIndex = Math.abs(offsetX.toInt()) == this.$swiperWidth ? 0 : offsetX / this.$swiperWidth - const currentIndex = this.$animationFinishIndex + Math.abs(offsetIndex.toInt()) + const offsetIndex = offsetX.toInt() / this.$swiperWidth + const currentIndex = this.$animationFinishIndex + offsetIndex.toInt() let moveToIndex = offsetX > 0 ? currentIndex + 1 : currentIndex - 1 if (moveToIndex < 0) { moveToIndex = 0 } diff --git a/pages/template/swiper-list/swiper-list.uvue b/pages/template/swiper-list/swiper-list.uvue index eb8e51ef..02819a4e 100644 --- a/pages/template/swiper-list/swiper-list.uvue +++ b/pages/template/swiper-list/swiper-list.uvue @@ -55,7 +55,7 @@ } }, onReady() { - this.$swiperWidth = (this.$refs["swiper"] as INode).offsetWidth + this.$swiperWidth = (this.$refs["swiper"] as INode).getBoundingClientRect().width this.queryTabItemsSize() this.setSwiperIndex(0, true) }, @@ -66,8 +66,8 @@ onSwiperTransition(e : SwiperTransitionEvent) { const offsetX = e.detail.dx // 兼容微信 skyline 和 webview - const offsetIndex = Math.abs(offsetX.toInt()) == this.$swiperWidth ? 0 : offsetX / this.$swiperWidth - const currentIndex = this.$animationFinishIndex + Math.abs(offsetIndex.toInt()) + const offsetIndex = offsetX.toInt() / this.$swiperWidth + const currentIndex = this.$animationFinishIndex + offsetIndex.toInt() let moveToIndex = offsetX > 0 ? currentIndex + 1 : currentIndex - 1 if (moveToIndex < 0) { moveToIndex = 0 } -- GitLab