From ca5e8c9429e216e1ba5e677cc45761f2c4ebe9ea Mon Sep 17 00:00:00 2001 From: zhengliming Date: Wed, 21 Feb 2024 01:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=E3=80=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E9=80=89=E6=8B=A9=E5=99=A8=E5=9C=A8=E5=B5=8C?= =?UTF-8?q?=E5=A5=97=E5=BC=B9=E5=87=BA=E5=B1=82=E8=AE=A1=E7=AE=97=E7=9A=84?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tuniao-ui/components/tn-slider/tn-slider.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tuniao-ui/components/tn-slider/tn-slider.vue b/tuniao-ui/components/tn-slider/tn-slider.vue index d29d848..db9d080 100644 --- a/tuniao-ui/components/tn-slider/tn-slider.vue +++ b/tuniao-ui/components/tn-slider/tn-slider.vue @@ -157,7 +157,9 @@ if (this.status === 'start') this.$emit('start') let movePageX = event.changedTouches[0].pageX // 滑块的左边不一定跟屏幕左边接壤,所以需要减去最外层父元素的左边值 - this.distanceX = movePageX - this.sliderRect.left + let marginLeft = this.sliderRect.left; + marginLeft = marginLeft < 0 ? 0 : marginLeft; + this.distanceX = movePageX - marginLeft; // 获得移动距离对整个滑块的百分比值,此为带有多位小数的值,不能用此更新视图 // 否则造成通信阻塞,需要每改变一个step值时修改一次视图 this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + this.min @@ -168,6 +170,7 @@ }, // 滑动结束 touchEnd() { + console.log("结束。。。"); if(this.disabled) return if (this.status === 'moving') { this.updateValue(this.newValue, false) @@ -200,6 +203,7 @@ }, // 点击事件 click(event) { + console.log("开始点击"); if (this.disabled) return // 直接点击的情况,计算方式和touchMove方法一致 const value = (((event.detail.x - this.sliderRect.left) / this.sliderRect.width) * (this.max - this.min)) + this.min