|
@@ -92,14 +92,16 @@ Component({ |
|
@@ -92,14 +92,16 @@ Component({ |
|
92
|
//console.log('sliderMove.changing',this.sliderMoving)
|
92
|
//console.log('sliderMove.changing',this.sliderMoving)
|
|
93
|
if(this.sliderMoving) return;//移动中
|
93
|
if(this.sliderMoving) return;//移动中
|
|
94
|
setTimeout(()=>{
|
94
|
setTimeout(()=>{
|
|
95
|
- //console.log('changing',this.sliderEvent);
|
|
|
|
96
|
- let pagex = this.sliderEvent.changedTouches[0].pageX / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
|
95
|
+ let type=util.attr(this.sliderEvent,'type')
|
|
|
|
96
|
+ let pos=this.sliderEvent.changedTouches[0].pageX
|
|
|
|
97
|
+ let pagex = pos / this.data.ratio - this.data.containerLeft - this.data.sliderLength / 2
|
|
|
|
98
|
+ //console.log('changing',this.sliderEvent.changedTouches[0].pageX,pos);
|
|
97
|
let myEventDetail={}
|
99
|
let myEventDetail={}
|
|
98
|
- if(util.attr(this.sliderEvent,'type')=='max'){
|
|
|
|
99
|
- if (pagex <= this.data.leftValue + this.data.sliderLength) {
|
|
|
|
100
|
- pagex = this.data.leftValue + this.data.sliderLength
|
|
|
|
101
|
- } else if (pagex >= this.data.totalLength - this.data.sliderLength) {
|
|
|
|
102
|
- pagex = this.data.totalLength - this.data.sliderLength
|
100
|
+ if(type=='max'){
|
|
|
|
101
|
+ if (pagex <= (this.data.leftValue + this.data.sliderLength)) {
|
|
|
|
102
|
+ pagex = (this.data.leftValue + this.data.sliderLength)
|
|
|
|
103
|
+ } else if (pagex >= (this.data.totalLength - this.data.sliderLength)) {
|
|
|
|
104
|
+ pagex = (this.data.totalLength - this.data.sliderLength)
|
|
103
|
}
|
105
|
}
|
|
104
|
this.setData({
|
106
|
this.setData({
|
|
105
|
rightValue: pagex
|
107
|
rightValue: pagex
|
|
@@ -107,7 +109,7 @@ Component({ |
|
@@ -107,7 +109,7 @@ Component({ |
|
107
|
pagex = pagex - this.data.sliderLength
|
109
|
pagex = pagex - this.data.sliderLength
|
|
108
|
let heighValue = parseInt(pagex / this.data.bigLength * (this.data.max - this.data.min) + this.data.min)
|
110
|
let heighValue = parseInt(pagex / this.data.bigLength * (this.data.max - this.data.min) + this.data.min)
|
|
109
|
|
111
|
|
|
110
|
- myEventDetail = { type:'max',value: heighValue }
|
112
|
+ myEventDetail = { type:'max',value: this.setStepValue(heighValue) }
|
|
111
|
}else{
|
113
|
}else{
|
|
112
|
if (pagex + this.data.sliderLength >= this.data.rightValue) {
|
114
|
if (pagex + this.data.sliderLength >= this.data.rightValue) {
|
|
113
|
pagex = this.data.rightValue - this.data.sliderLength
|
115
|
pagex = this.data.rightValue - this.data.sliderLength
|
|
@@ -118,7 +120,7 @@ Component({ |
|
@@ -118,7 +120,7 @@ Component({ |
|
118
|
leftValue: pagex
|
120
|
leftValue: pagex
|
|
119
|
})
|
121
|
})
|
|
120
|
let lowValue = parseInt(pagex / this.data.bigLength * parseInt(this.data.max - this.data.min) + this.data.min)
|
122
|
let lowValue = parseInt(pagex / this.data.bigLength * parseInt(this.data.max - this.data.min) + this.data.min)
|
|
121
|
- myEventDetail = { type:'min',value: lowValue }
|
123
|
+ myEventDetail = { type:'min',value: this.setStepValue(lowValue) }
|
|
122
|
}
|
124
|
}
|
|
123
|
//console.log('event',myEventDetail);
|
125
|
//console.log('event',myEventDetail);
|
|
124
|
this.triggerEvent('event', myEventDetail)
|
126
|
this.triggerEvent('event', myEventDetail)
|
|
@@ -126,6 +128,15 @@ Component({ |
|
@@ -126,6 +128,15 @@ Component({ |
|
126
|
},0)
|
128
|
},0)
|
|
127
|
this.sliderMoving=true
|
129
|
this.sliderMoving=true
|
|
128
|
},
|
130
|
},
|
|
|
|
131
|
+ setStepValue(val) {
|
|
|
|
132
|
+ let step = this.data.step || 1;
|
|
|
|
133
|
+ if (step == 1) return val;
|
|
|
|
134
|
+ let yus=val%step,sha=parseInt(val/step)
|
|
|
|
135
|
+ if(yus>step/2){
|
|
|
|
136
|
+ sha+=1;
|
|
|
|
137
|
+ }
|
|
|
|
138
|
+ return sha*step;
|
|
|
|
139
|
+ },
|
|
129
|
/**
|
140
|
/**
|
|
130
|
* 隐藏组件
|
141
|
* 隐藏组件
|
|
131
|
*/
|
142
|
*/
|