Compare commits

..
5 Commits
Author SHA1 Message Date
Benjy Cui 806cb06d76 bump 3.5.1 2016-03-22 17:22:43 +08:00
Benjy Cui 73b9953084 refactor: update Marks style algorithm 2016-03-22 17:21:50 +08:00
Benjy Cui 6347b6d0c6 bump 3.5.0 2016-03-22 16:55:02 +08:00
Benjy Cui 6a5573b6ca feat: support React.Component in marks 2016-03-22 16:53:38 +08:00
Benjy Cui e030ba9f9d refactor: rename Dots to Steps 2016-03-22 16:27:50 +08:00
5 changed files with 15 additions and 10 deletions
+2 -2
View File
@@ -7,7 +7,7 @@ const Slider = require('rc-slider');
const style = {width: 400, margin: 50};
const marks = {
'-10': '-10°C',
0: '0°C',
0: <strong>0°C</strong>,
26: '26°C',
37: '37°C',
50: '50°C',
@@ -15,7 +15,7 @@ const marks = {
style: {
color: 'red',
},
label: '100°C',
label: <strong>100°C</strong>,
},
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-slider",
"version": "3.4.0",
"version": "3.5.1",
"description": "slider ui component for react",
"keywords": [
"react",
+7 -3
View File
@@ -16,11 +16,15 @@ const Marks = ({className, marks, included, upperBound, lowerBound, max, min}) =
[className + '-text-active']: isActived,
});
const style = { width: markWidth + '%' };
style.left = (point - min) / range * 100 - markWidth / 2 + '%';
const style = {
width: markWidth + '%',
marginLeft: -markWidth / 2 + '%',
};
style.left = (point - min) / range * 100 + '%';
const markPoint = marks[point];
const markPointIsObject = typeof markPoint === 'object';
const markPointIsObject = typeof markPoint === 'object' &&
!React.isValidElement(markPoint);
const markLabel = markPointIsObject ? markPoint.label : markPoint;
const markStyle = markPointIsObject ?
{ ...style, ...markPoint.style } : style;
+2 -2
View File
@@ -4,7 +4,7 @@ import classNames from 'classnames';
import objectAssign from 'object-assign';
import Track from './Track';
import Handle from './Handle';
import Dots from './Dots';
import Steps from './Steps';
import Marks from './Marks';
function noop() {
@@ -366,7 +366,7 @@ class Slider extends React.Component {
{lower}
<Track className={prefixCls + '-track'} included={isIncluded}
offset={lowerOffset} length={upperOffset - lowerOffset}/>
<Dots prefixCls={prefixCls} marks={marks} dots={dots} step={step}
<Steps prefixCls={prefixCls} marks={marks} dots={dots} step={step}
included={isIncluded} lowerBound={lowerBound}
upperBound={upperBound} max={max} min={min}/>
<Marks className={prefixCls + '-mark'} marks={marks}
+3 -2
View File
@@ -12,7 +12,8 @@ function calcPoints(marks, dots, step, min, max) {
return points;
}
const Dots = ({prefixCls, marks, dots, step, included, lowerBound, upperBound, max, min}) => {
const Steps = ({prefixCls, marks, dots, step, included,
lowerBound, upperBound, max, min}) => {
const range = max - min;
const elements = calcPoints(marks, dots, step, min, max).map((point) => {
const offset = (point - min) / range * 100 + '%';
@@ -31,4 +32,4 @@ const Dots = ({prefixCls, marks, dots, step, included, lowerBound, upperBound, m
return <div className={prefixCls + '-step'}>{elements}</div>;
};
export default Dots;
export default Steps;