Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for a third track style and optional enable for enabling markers to overlap #251

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions MultiSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,11 @@ export default class MultiSlider extends React.Component {
const {
selectedStyle,
unselectedStyle,
thirdStyle,
sliderLength,
markerOffsetX,
markerOffsetY,
overlap
} = this.props;
const twoMarkers = this.props.values.length == 2; // when allowOverlap, positionTwo could be 0, identified as string '0' and throwing 'RawText 0 needs to be wrapped in <Text>' error

Expand All @@ -502,7 +504,7 @@ export default class MultiSlider extends React.Component {
? unselectedStyle
: selectedStyle || styles.selectedTrack;
const trackThreeLength = twoMarkers ? sliderLength - positionTwo : 0;
const trackThreeStyle = unselectedStyle;
const trackThreeStyle = thirdStyle!=undefined?thirdStyle:unselectedStyle;
const trackTwoLength = sliderLength - trackOneLength - trackThreeLength;
const trackTwoStyle = twoMarkers
? selectedStyle || styles.selectedTrack
Expand Down Expand Up @@ -614,7 +616,7 @@ export default class MultiSlider extends React.Component {
)}
</View>
</View>
{twoMarkers && positionOne !== this.props.sliderLength && (
{twoMarkers && (overlap==true || positionOne !== this.props.sliderLength) && (
<View
style={[
styles.markerContainer,
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Feel free to contribute to this part of the documentation.
| step | 1 | number | Step value of the slider. |
| optionsArray | | array of numbers | Possible values of the slider. Ignores min and max. |
| {container/track/selected/unselected/ markerContainer/marker/pressedMarker/step/stepLabel/StepMarker} Style | | style object | Styles for the slider |
| selectedStyle | | style object | Style for the track right of the marker in the 1 marker case. Style of the track between the 2 markers in the 2 marker case. |
| unselectedStyle | | style object | Style for the track left of the marker in the 1 marker case. Style of the track on either side of the 2 markers in the 2 marker case. |
| thirdStyle | | style object | Style for the track right of the right marker in the 2 marker case. |
| overlap | | boolean | Enables 2 markers to exist at the same slider position. default behaviour right marker disappears. |
| valuePrefix | | string | Prefix added to the value. |
| valueSuffix | | string | Suffix added to the value. |
| enabledOne | true | boolean | Enables the first cursor |
Expand Down