mirror of
https://github.com/wassname/slider.git
synced 2026-09-11 12:42:49 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
daaea139b9 | ||
|
|
2641880783 | ||
|
|
d6e81a692c | ||
|
|
0512ee6ee0 | ||
|
|
613a2ae213 |
@@ -90,9 +90,9 @@ ReactDOM.render(<Rcslider />, container);
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>marks</td>
|
<td>marks</td>
|
||||||
<td>object {number: string}</td>
|
<td>object{number: string} or object{number: object{ style, label }}</td>
|
||||||
<td>{}</td>
|
<td>{}</td>
|
||||||
<td>Mark on the slider. The key determines the position, and the value determines what will show.</td>
|
<td>Mark on the slider. The key determines the position, and the value determines what will show. If you want to set the style of a specific mark point, the value should be an object which contains `style` and `label` properties.</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>step</td>
|
<td>step</td>
|
||||||
|
|||||||
+6
-1
@@ -11,7 +11,12 @@ const marks = {
|
|||||||
26: '26°C',
|
26: '26°C',
|
||||||
37: '37°C',
|
37: '37°C',
|
||||||
50: '50°C',
|
50: '50°C',
|
||||||
100: '100°C',
|
100: {
|
||||||
|
style: {
|
||||||
|
color: 'red',
|
||||||
|
},
|
||||||
|
label: '100°C',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function log(value) {
|
function log(value) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "rc-slider",
|
"name": "rc-slider",
|
||||||
"version": "3.3.2",
|
"version": "3.4.0",
|
||||||
"description": "slider ui component for react",
|
"description": "slider ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
|||||||
+8
-3
@@ -8,7 +8,7 @@ const Marks = ({className, marks, included, upperBound, lowerBound, max, min}) =
|
|||||||
const markWidth = unit * 0.9;
|
const markWidth = unit * 0.9;
|
||||||
|
|
||||||
const range = max - min;
|
const range = max - min;
|
||||||
const elements = marksKeys.map(parseFloat).map((point) => {
|
const elements = marksKeys.map(parseFloat).sort((a, b) => a - b).map((point) => {
|
||||||
const isActived = (!included && point === upperBound) ||
|
const isActived = (!included && point === upperBound) ||
|
||||||
(included && point <= upperBound && point >= lowerBound);
|
(included && point <= upperBound && point >= lowerBound);
|
||||||
const markClassName = classNames({
|
const markClassName = classNames({
|
||||||
@@ -19,8 +19,13 @@ const Marks = ({className, marks, included, upperBound, lowerBound, max, min}) =
|
|||||||
const style = { width: markWidth + '%' };
|
const style = { width: markWidth + '%' };
|
||||||
style.left = (point - min) / range * 100 - markWidth / 2 + '%';
|
style.left = (point - min) / range * 100 - markWidth / 2 + '%';
|
||||||
|
|
||||||
return (<span className={markClassName} style={style} key={point}>
|
const markPoint = marks[point];
|
||||||
{marks[point]}
|
const markPointIsObject = typeof markPoint === 'object';
|
||||||
|
const markLabel = markPointIsObject ? markPoint.label : markPoint;
|
||||||
|
const markStyle = markPointIsObject ?
|
||||||
|
{ ...style, ...markPoint.style } : style;
|
||||||
|
return (<span className={markClassName} style={markStyle} key={point}>
|
||||||
|
{markLabel}
|
||||||
</span>);
|
</span>);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user