mirror of https://github.com/ElemeFE/element
Slider: precision is now a computed prop
parent
75e5b0ecea
commit
4af6c854d0
|
@ -103,7 +103,6 @@
|
||||||
firstValue: null,
|
firstValue: null,
|
||||||
secondValue: null,
|
secondValue: null,
|
||||||
oldValue: null,
|
oldValue: null,
|
||||||
precision: 0,
|
|
||||||
dragging: false
|
dragging: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -119,10 +118,6 @@
|
||||||
this.setValues();
|
this.setValues();
|
||||||
},
|
},
|
||||||
|
|
||||||
step() {
|
|
||||||
this.setPrecision();
|
|
||||||
},
|
|
||||||
|
|
||||||
dragging(val) {
|
dragging(val) {
|
||||||
if (!val) {
|
if (!val) {
|
||||||
this.setValues();
|
this.setValues();
|
||||||
|
@ -214,14 +209,6 @@
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -265,6 +252,14 @@
|
||||||
return this.range
|
return this.range
|
||||||
? `${ 100 * (this.minValue - this.min) / (this.max - this.min) }%`
|
? `${ 100 * (this.minValue - this.min) / (this.max - this.min) }%`
|
||||||
: '0%';
|
: '0%';
|
||||||
|
},
|
||||||
|
|
||||||
|
precision() {
|
||||||
|
let precisions = [this.min, this.max, this.step].map(item => {
|
||||||
|
let decimal = ('' + item).split('.')[1];
|
||||||
|
return decimal ? decimal.length : 0;
|
||||||
|
});
|
||||||
|
return Math.max.apply(null, precisions);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -286,7 +281,6 @@
|
||||||
}
|
}
|
||||||
this.oldValue = this.firstValue;
|
this.oldValue = this.firstValue;
|
||||||
}
|
}
|
||||||
this.setPrecision();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue