diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue index 76874d5830d538b09ceee84c6cfd20cd42d35321..855cd76da5dca15d6068a2d0df75016198820c8e 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 eb8e51ef3c9edeff8ea972bae44cef82053de8f1..02819a4e8f145d40aad9ea832558b859a99757be 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 }