Skip to content

Commit

Permalink
fix(mark-label-onclick): add click handler to mark in order to change…
Browse files Browse the repository at this point in the history
… the slider value to mark value when the mark label is clicked
  • Loading branch information
williamswgb committed Dec 7, 2017
1 parent db32618 commit d0cbd7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/common/Marks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Marks = ({
upperBound,
lowerBound,
max, min,
onClickLabel,
}) => {
const marksKeys = Object.keys(marks);
const marksCount = marksKeys.length;
Expand Down Expand Up @@ -51,6 +52,8 @@ const Marks = ({
className={markClassName}
style={markStyle}
key={point}
onMouseDown={(e) => onClickLabel(e, point)}
onTouchStart={(e) => onClickLabel(e, point)}
>
{markLabel}
</span>
Expand Down
6 changes: 6 additions & 0 deletions src/common/createSlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ export default function createSlider(Component) {
this.handlesRefs[index] = handle;
}

onClickMarkLabel = (e, value) => {
e.stopPropagation();
this.onChange({ value });
}

render() {
const {
prefixCls,
Expand Down Expand Up @@ -321,6 +326,7 @@ export default function createSlider(Component) {
{handles}
<Marks
className={`${prefixCls}-mark`}
onClickLabel={disabled ? noop : this.onClickMarkLabel}
vertical={vertical}
marks={marks}
included={included}
Expand Down

0 comments on commit d0cbd7f

Please sign in to comment.