update Slider
This commit is contained in:
parent
bb1a3c38b4
commit
2f8104a321
1 changed files with 28 additions and 22 deletions
|
@ -360,18 +360,21 @@
|
|||
}
|
||||
},
|
||||
changeFirstPosition (newPos) {
|
||||
if (newPos >= 0 && (newPos <= this.secondPosition)) {
|
||||
const lengthPerStep = 100 / ((this.max - this.min) / this.step);
|
||||
const steps = Math.round(newPos / lengthPerStep);
|
||||
if (newPos < 0) {
|
||||
newPos = 0;
|
||||
} else if (newPos > this.secondPosition) {
|
||||
newPos = this.secondPosition;
|
||||
}
|
||||
const lengthPerStep = 100 / ((this.max - this.min) / this.step);
|
||||
const steps = Math.round(newPos / lengthPerStep);
|
||||
|
||||
this.currentValue = [Math.round(steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min), this.currentValue[1]];
|
||||
this.setFirstPosition(this.currentValue[0]);
|
||||
if (!this.firstDragging) {
|
||||
if (this.currentValue[0] !== this.oldFirstValue) {
|
||||
this.$emit('on-change', this.currentValue);
|
||||
this.dispatch('FormItem', 'on-form-change', this.currentValue);
|
||||
this.oldFirstValue = this.currentValue[0];
|
||||
}
|
||||
this.currentValue = [Math.round(steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min), this.currentValue[1]];
|
||||
this.setFirstPosition(this.currentValue[0]);
|
||||
if (!this.firstDragging) {
|
||||
if (this.currentValue[0] !== this.oldFirstValue) {
|
||||
this.$emit('on-change', this.currentValue);
|
||||
this.dispatch('FormItem', 'on-form-change', this.currentValue);
|
||||
this.oldFirstValue = this.currentValue[0];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -410,18 +413,21 @@
|
|||
}
|
||||
},
|
||||
changeSecondPosition (newPos) {
|
||||
if (newPos >= this.firstPosition && (newPos <= 100)) {
|
||||
const lengthPerStep = 100 / ((this.max - this.min) / this.step);
|
||||
const steps = Math.round(newPos / lengthPerStep);
|
||||
if (newPos > 100) {
|
||||
newPos = 100;
|
||||
} else if (newPos < this.firstPosition) {
|
||||
newPos = this.firstPosition;
|
||||
}
|
||||
const lengthPerStep = 100 / ((this.max - this.min) / this.step);
|
||||
const steps = Math.round(newPos / lengthPerStep);
|
||||
|
||||
this.currentValue = [this.currentValue[0], Math.round(steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min)];
|
||||
this.setSecondPosition(this.currentValue[1]);
|
||||
if (!this.secondDragging) {
|
||||
if (this.currentValue[1] !== this.oldSecondValue) {
|
||||
this.$emit('on-change', this.currentValue);
|
||||
this.dispatch('FormItem', 'on-form-change', this.currentValue);
|
||||
this.oldSecondValue = this.currentValue[1];
|
||||
}
|
||||
this.currentValue = [this.currentValue[0], Math.round(steps * lengthPerStep * (this.max - this.min) * 0.01 + this.min)];
|
||||
this.setSecondPosition(this.currentValue[1]);
|
||||
if (!this.secondDragging) {
|
||||
if (this.currentValue[1] !== this.oldSecondValue) {
|
||||
this.$emit('on-change', this.currentValue);
|
||||
this.dispatch('FormItem', 'on-form-change', this.currentValue);
|
||||
this.oldSecondValue = this.currentValue[1];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue