|
...
|
...
|
@@ -92,14 +92,16 @@ Component({ |
|
|
|
//console.log('sliderMove.changing',this.sliderMoving)
|
|
|
|
if(this.sliderMoving) return;//移动中
|
|
|
|
setTimeout(()=>{
|
|
|
|
//console.log('changing',this.sliderEvent);
|
|
|
|
let pagex = this.sliderEvent.changedTouches[0].pageX / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
|
|
|
|
let type=util.attr(this.sliderEvent,'type')
|
|
|
|
let pos=this.sliderEvent.changedTouches[0].pageX
|
|
|
|
let pagex = pos / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
|
|
|
|
//console.log('changing',this.sliderEvent.changedTouches[0].pageX,pos);
|
|
|
|
let myEventDetail={}
|
|
|
|
if(util.attr(this.sliderEvent,'type')=='max'){
|
|
|
|
if (pagex <= this.data.leftValue + this.data.sliderLength) {
|
|
|
|
pagex = this.data.leftValue + this.data.sliderLength
|
|
|
|
} else if (pagex >= this.data.totalLength - this.data.sliderLength) {
|
|
|
|
pagex = this.data.totalLength - this.data.sliderLength
|
|
|
|
if(type=='max'){
|
|
|
|
if (pagex <= (this.data.leftValue + this.data.sliderLength)) {
|
|
|
|
pagex = (this.data.leftValue + this.data.sliderLength)
|
|
|
|
} else if (pagex >= (this.data.totalLength - this.data.sliderLength)) {
|
|
|
|
pagex = (this.data.totalLength - this.data.sliderLength)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
rightValue: pagex
|
|
...
|
...
|
@@ -107,7 +109,7 @@ Component({ |
|
|
|
pagex = pagex - this.data.sliderLength
|
|
|
|
let heighValue = parseInt(pagex / this.data.bigLength * (this.data.max - this.data.min) + this.data.min)
|
|
|
|
|
|
|
|
myEventDetail = { type:'max',value: heighValue }
|
|
|
|
myEventDetail = { type:'max',value: this.setStepValue(heighValue) }
|
|
|
|
}else{
|
|
|
|
if (pagex + this.data.sliderLength >= this.data.rightValue) {
|
|
|
|
pagex = this.data.rightValue - this.data.sliderLength
|
|
...
|
...
|
@@ -118,7 +120,7 @@ Component({ |
|
|
|
leftValue: pagex
|
|
|
|
})
|
|
|
|
let lowValue = parseInt(pagex / this.data.bigLength * parseInt(this.data.max - this.data.min) + this.data.min)
|
|
|
|
myEventDetail = { type:'min',value: lowValue }
|
|
|
|
myEventDetail = { type:'min',value: this.setStepValue(lowValue) }
|
|
|
|
}
|
|
|
|
//console.log('event',myEventDetail);
|
|
|
|
this.triggerEvent('event', myEventDetail)
|
|
...
|
...
|
@@ -126,6 +128,15 @@ Component({ |
|
|
|
},0)
|
|
|
|
this.sliderMoving=true
|
|
|
|
},
|
|
|
|
setStepValue(val) {
|
|
|
|
let step = this.data.step || 1;
|
|
|
|
if (step == 1) return val;
|
|
|
|
let yus=val%step,sha=parseInt(val/step)
|
|
|
|
if(yus>step/2){
|
|
|
|
sha+=1;
|
|
|
|
}
|
|
|
|
return sha*step;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 隐藏组件
|
|
|
|
*/
|
...
|
...
|
|