fix: the key of dots should be unique #64

This commit is contained in:
Benjy Cui
2015-12-21 09:57:30 +08:00
parent 4d795b01cc
commit f3c1d4bd3d
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -10,6 +10,7 @@ const marks = {
0: '0°C',
26: '26°C',
37: '37°C',
50: '50°C',
100: '100°C',
};
@@ -25,7 +26,7 @@ ReactDOM.render(
</div>
<div style={style}>
<p>Slider with marks and steps</p>
<Slider min={-10} marks={marks} step={10} onChange={log} defaultValue={20} />
<Slider dots min={-10} marks={marks} step={10} onChange={log} defaultValue={20} />
</div>
<div style={style}>
+1
View File
@@ -5,6 +5,7 @@ function calcPoints(marks, dots, step, min, max) {
const points = Object.keys(marks).map(parseFloat);
if (dots) {
for (let i = min; i <= max; i = i + step) {
if (points.indexOf(i) >= 0) continue;
points.push(i);
}
}