mirror of
https://gitee.com/TSpecific/tuniao-ui.git
synced 2026-03-07 16:24:01 +08:00
【fix】修复滑动选择器在嵌套弹出层计算的bug
This commit is contained in:
@@ -157,7 +157,9 @@
|
|||||||
if (this.status === 'start') this.$emit('start')
|
if (this.status === 'start') this.$emit('start')
|
||||||
let movePageX = event.changedTouches[0].pageX
|
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值时修改一次视图
|
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
||||||
this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + this.min
|
this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + this.min
|
||||||
@@ -168,6 +170,7 @@
|
|||||||
},
|
},
|
||||||
// 滑动结束
|
// 滑动结束
|
||||||
touchEnd() {
|
touchEnd() {
|
||||||
|
console.log("结束。。。");
|
||||||
if(this.disabled) return
|
if(this.disabled) return
|
||||||
if (this.status === 'moving') {
|
if (this.status === 'moving') {
|
||||||
this.updateValue(this.newValue, false)
|
this.updateValue(this.newValue, false)
|
||||||
@@ -200,6 +203,7 @@
|
|||||||
},
|
},
|
||||||
// 点击事件
|
// 点击事件
|
||||||
click(event) {
|
click(event) {
|
||||||
|
console.log("开始点击");
|
||||||
if (this.disabled) return
|
if (this.disabled) return
|
||||||
// 直接点击的情况,计算方式和touchMove方法一致
|
// 直接点击的情况,计算方式和touchMove方法一致
|
||||||
const value = (((event.detail.x - this.sliderRect.left) / this.sliderRect.width) * (this.max - this.min)) + this.min
|
const value = (((event.detail.x - this.sliderRect.left) / this.sliderRect.width) * (this.max - this.min)) + this.min
|
||||||
|
|||||||
Reference in New Issue
Block a user