mirror of
https://github.com/wassname/slider.git
synced 2026-09-10 12:38:09 +08:00
fix: the key of dots should be unique #64
This commit is contained in:
+2
-1
@@ -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}>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user