mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ddcf32b094 | ||
|
|
025a9e7ea6 | ||
|
|
e4396ae4bd | ||
|
|
37b7f508da | ||
|
|
ecbb253986 | ||
|
|
f4a82e3fd1 | ||
|
|
0b1a421a71 |
+1
-1
@@ -95,7 +95,7 @@ ReactDOM.render(
|
|||||||
</div>
|
</div>
|
||||||
<div style={style}>
|
<div style={style}>
|
||||||
<p>Basic Range,`step=20` </p>
|
<p>Basic Range,`step=20` </p>
|
||||||
<Slider range step={20} defaultValue={[20, 40]} onBeforeChange={log} />
|
<Slider range step={20} defaultValue={[20, 20]} onBeforeChange={log} />
|
||||||
</div>
|
</div>
|
||||||
<div style={style}>
|
<div style={style}>
|
||||||
<p>Basic Range,`step=20, dots` </p>
|
<p>Basic Range,`step=20, dots` </p>
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-slider",
|
"name": "rc-slider",
|
||||||
"version": "3.6.0",
|
"version": "3.6.2",
|
||||||
"description": "slider ui component for react",
|
"description": "slider ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
@@ -52,6 +52,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"classnames": "^2.2.1",
|
"classnames": "^2.2.1",
|
||||||
"rc-tooltip": "3.x",
|
"rc-tooltip": "3.x",
|
||||||
"rc-util": "3.x"
|
"rc-util": "3.x",
|
||||||
|
"warning": "^2.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-10
@@ -46,12 +46,7 @@ class Slider extends React.Component {
|
|||||||
|
|
||||||
let recent;
|
let recent;
|
||||||
if (props.range && upperBound === lowerBound) {
|
if (props.range && upperBound === lowerBound) {
|
||||||
if (lowerBound === max) {
|
recent = lowerBound === max ? 'lowerBound' : 'upperBound';
|
||||||
recent = 'lowerBound';
|
|
||||||
}
|
|
||||||
if (upperBound === min) {
|
|
||||||
recent = 'upperBound';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
recent = 'upperBound';
|
recent = 'upperBound';
|
||||||
}
|
}
|
||||||
@@ -240,9 +235,8 @@ class Slider extends React.Component {
|
|||||||
return this.props.vertical ? rect.top : rect.left;
|
return this.props.vertical ? rect.top : rect.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
getPrecision() {
|
getPrecision(step) {
|
||||||
const props = this.props;
|
const stepString = step.toString();
|
||||||
const stepString = props.step.toString();
|
|
||||||
let precision = 0;
|
let precision = 0;
|
||||||
if (stepString.indexOf('.') >= 0) {
|
if (stepString.indexOf('.') >= 0) {
|
||||||
precision = stepString.length - stepString.indexOf('.') - 1;
|
precision = stepString.length - stepString.indexOf('.') - 1;
|
||||||
@@ -282,7 +276,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 step !== null ? parseFloat(closestPoint.toFixed(this.getPrecision())) : closestPoint;
|
return step !== null ? parseFloat(closestPoint.toFixed(this.getPrecision(step))) : closestPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
calcOffset(value) {
|
calcOffset(value) {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import warning from 'warning';
|
||||||
|
|
||||||
function calcPoints(vertical, marks, dots, step, min, max) {
|
function calcPoints(vertical, marks, dots, step, min, max) {
|
||||||
|
warning(dots ? step > 0 : true, '`Slider[step]` should be a positive number in order to make Slider[dots] work.');
|
||||||
const points = Object.keys(marks).map(parseFloat);
|
const points = Object.keys(marks).map(parseFloat);
|
||||||
if (dots) {
|
if (dots) {
|
||||||
for (let i = min; i <= max; i = i + step) {
|
for (let i = min; i <= max; i = i + step) {
|
||||||
|
|||||||
Reference in New Issue
Block a user