From fc3f623e82ad01da86fc61a618fb60ad1b763a67 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Mon, 9 Dec 2024 18:41:01 +0800 Subject: [PATCH] =?UTF-8?q?refactor(swiper):=20=E5=B1=8F=E8=94=BD=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E4=B8=8D=E6=94=AF=E6=8C=81=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/swiper/swiper.uvue | 38 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/pages/component/swiper/swiper.uvue b/pages/component/swiper/swiper.uvue index dca475de..c36e4465 100644 --- a/pages/component/swiper/swiper.uvue +++ b/pages/component/swiper/swiper.uvue @@ -122,26 +122,28 @@ animationfinishDetailTest: null as UniSwiperAnimationFinishEventDetail | null, isChangeTest: '', isTransitionTest: '', - isAnimationfinishTest: '', - swipeX: 0, + isAnimationfinishTest: '', + swipeX: 0, swipeY: 0 } - }, - onReady() { - // 获取模拟滑动手势的起始点 - let ele = uni.getElementById("swiper-view") + }, + onReady() { + // #ifndef MP + // 获取模拟滑动手势的起始点 + let ele = uni.getElementById("swiper-view") let eleRect = ele?.getBoundingClientRect() if(eleRect != null) { this.swipeX = eleRect.width - 10 this.swipeY += eleRect.y + uni.getSystemInfoSync().safeArea.top + 44 + 35 - } + } + // #endif }, - methods: { - swipertouchStart(e: UniTouchEvent) { - console.log("swiper touchstart") - }, - viewtouchStart(e: UniTouchEvent) { - console.log("view touchstart:") + methods: { + swipertouchStart(e: UniTouchEvent) { + console.log("swiper touchstart") + }, + viewtouchStart(e: UniTouchEvent) { + console.log("view touchstart:") }, swiperChange: function (e : UniSwiperChangeEvent) { this.changeDetailTest = e.detail @@ -182,12 +184,12 @@ } }, // 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取) - checkEventTest(e : SwiperEventTest, eventName : String) { + checkEventTest(e : SwiperEventTest, eventName : String) { // #ifndef MP - const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement; - // #endif + const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement; + // #endif // #ifdef MP - const isPass = true; + const isPass = true; // #endif const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`; switch (eventName) { @@ -284,4 +286,4 @@ text-align: center; line-height: 150px; } - + -- GitLab