mirror of https://github.com/ElemeFE/element
Slider: fix step not updating precision
parent
67d8eae691
commit
75e5b0ecea
|
@ -119,6 +119,10 @@
|
||||||
this.setValues();
|
this.setValues();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
step() {
|
||||||
|
this.setPrecision();
|
||||||
|
},
|
||||||
|
|
||||||
dragging(val) {
|
dragging(val) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
this.setValues();
|
this.setValues();
|
||||||
|
@ -210,6 +214,14 @@
|
||||||
if (this.disabled || this.dragging) return;
|
if (this.disabled || this.dragging) return;
|
||||||
const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
|
const sliderOffsetLeft = this.$refs.slider.getBoundingClientRect().left;
|
||||||
this.setPosition((event.clientX - sliderOffsetLeft) / this.$sliderWidth * 100);
|
this.setPosition((event.clientX - sliderOffsetLeft) / this.$sliderWidth * 100);
|
||||||
|
},
|
||||||
|
|
||||||
|
setPrecision() {
|
||||||
|
let precisions = [this.min, this.max, this.step].map(item => {
|
||||||
|
let decimal = ('' + item).split('.')[1];
|
||||||
|
return decimal ? decimal.length : 0;
|
||||||
|
});
|
||||||
|
this.precision = Math.max.apply(null, precisions);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -274,11 +286,7 @@
|
||||||
}
|
}
|
||||||
this.oldValue = this.firstValue;
|
this.oldValue = this.firstValue;
|
||||||
}
|
}
|
||||||
let precisions = [this.min, this.max, this.step].map(item => {
|
this.setPrecision();
|
||||||
let decimal = ('' + item).split('.')[1];
|
|
||||||
return decimal ? decimal.length : 0;
|
|
||||||
});
|
|
||||||
this.precision = Math.max.apply(null, precisions);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue