mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee0dd09a4f |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-slider",
|
"name": "rc-slider",
|
||||||
"version": "3.1.1",
|
"version": "3.1.2",
|
||||||
"description": "slider ui component for react",
|
"description": "slider ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
|||||||
+11
-1
@@ -203,6 +203,16 @@ class Slider extends React.Component {
|
|||||||
return rect.left;
|
return rect.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPrecision() {
|
||||||
|
const props = this.props;
|
||||||
|
const stepString = props.step.toString();
|
||||||
|
let precision = 0;
|
||||||
|
if (stepString.indexOf('.') >= 0) {
|
||||||
|
precision = stepString.length - stepString.indexOf('.') - 1;
|
||||||
|
}
|
||||||
|
return precision;
|
||||||
|
}
|
||||||
|
|
||||||
trimAlignValue(v) {
|
trimAlignValue(v) {
|
||||||
const state = this.state || {};
|
const state = this.state || {};
|
||||||
const {handle, lowerBound, upperBound} = state;
|
const {handle, lowerBound, upperBound} = state;
|
||||||
@@ -231,7 +241,7 @@ class Slider extends React.Component {
|
|||||||
const diffs = points.map((point) => Math.abs(val - point));
|
const diffs = points.map((point) => Math.abs(val - point));
|
||||||
const closestPoint = points[diffs.indexOf(Math.min.apply(Math, diffs))];
|
const closestPoint = points[diffs.indexOf(Math.min.apply(Math, diffs))];
|
||||||
|
|
||||||
return closestPoint;
|
return step !== null ? parseFloat(closestPoint.toFixed(this.getPrecision())) : closestPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
calcOffset(value) {
|
calcOffset(value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user