Compare commits

..
5 Commits
Author SHA1 Message Date
Benjy Cui 926d5aeb91 bump 3.8.0 2016-07-20 09:40:04 +08:00
miskreant b2ae1bc0fc feat: identify upper/lower range handles (#118)
Extend the handle classNames, and provide props so that
upper/lower handles are easily distinguishable in CSS & React.

* Use classNames() instead of string concatenation
2016-07-20 09:34:49 +08:00
Benjy Cui 80d4ee4794 bump 3.7.4 2016-07-11 09:55:12 +08:00
Benjy Cui e2504d99fe fix: should calc cloest point correctly, close: #116 2016-07-11 09:53:38 +08:00
Benjy Cui d4ae5a5298 deps: update 2016-07-11 09:48:44 +08:00
2 changed files with 22 additions and 11 deletions
+8 -8
View File
@@ -1,6 +1,6 @@
{ {
"name": "rc-slider", "name": "rc-slider",
"version": "3.7.3", "version": "3.8.0",
"description": "slider ui component for react", "description": "slider ui component for react",
"keywords": [ "keywords": [
"react", "react",
@@ -42,17 +42,17 @@
"pre-commit": "1.x", "pre-commit": "1.x",
"rc-server": "3.x", "rc-server": "3.x",
"rc-tools": "4.x", "rc-tools": "4.x",
"react": "~0.14.0", "react": "^15.2.1",
"react-addons-test-utils": "^0.14.0", "react-addons-test-utils": "^15.2.1",
"react-dom": "~0.14.0" "react-dom": "^15.2.1"
}, },
"pre-commit": [ "pre-commit": [
"lint" "lint"
], ],
"dependencies": { "dependencies": {
"classnames": "^2.2.1", "classnames": "^2.2.5",
"rc-tooltip": "3.x", "rc-tooltip": "^3.4.2",
"rc-util": "3.x", "rc-util": "^3.2.1",
"warning": "^2.1.0" "warning": "^3.0.0"
} }
} }
+14 -3
View File
@@ -270,7 +270,7 @@ class Slider extends React.Component {
const points = Object.keys(marks).map(parseFloat); const points = Object.keys(marks).map(parseFloat);
if (step !== null) { if (step !== null) {
const closestStep = Math.round(val / step) * step; const closestStep = (Math.round((val - min) / step) * step) + min;
points.push(closestStep); points.push(closestStep);
} }
@@ -337,15 +337,26 @@ class Slider extends React.Component {
const lowerOffset = this.calcOffset(lowerBound); const lowerOffset = this.calcOffset(lowerBound);
const handleClassName = prefixCls + '-handle'; const handleClassName = prefixCls + '-handle';
const upperClassName = classNames({
[handleClassName]: true,
[handleClassName + '-upper']: true,
});
const lowerClassName = classNames({
[handleClassName]: true,
[handleClassName + '-lower']: true,
});
const isNoTip = (step === null) || (tipFormatter === null); const isNoTip = (step === null) || (tipFormatter === null);
const upper = cloneElement(customHandle, { className: handleClassName, const upper = cloneElement(customHandle, { className: upperClassName,
noTip: isNoTip, tipTransitionName: tipTransitionName, tipFormatter: tipFormatter, noTip: isNoTip, tipTransitionName: tipTransitionName, tipFormatter: tipFormatter,
vertical: vertical, offset: upperOffset, value: upperBound, dragging: handle === 'upperBound' }); vertical: vertical, offset: upperOffset, value: upperBound, dragging: handle === 'upperBound' });
let lower = null; let lower = null;
if (range) { if (range) {
lower = cloneElement(customHandle, { className: handleClassName, lower = cloneElement(customHandle, { className: lowerClassName,
noTip: isNoTip, tipTransitionName: tipTransitionName, tipFormatter: tipFormatter, noTip: isNoTip, tipTransitionName: tipTransitionName, tipFormatter: tipFormatter,
vertical: vertical, offset: lowerOffset, value: lowerBound, dragging: handle === 'lowerBound' }); vertical: vertical, offset: lowerOffset, value: lowerBound, dragging: handle === 'lowerBound' });
} }