Skip to content

Fix range slider initial position, allow thumb positions to be equal #2182

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

Closed
wants to merge 2 commits into from

Conversation

ajp8164
Copy link

@ajp8164 ajp8164 commented Aug 10, 2022

The range slider thumbs exhibited an arbitrary gap when they are moved next to each other. This gap should be zero so that the selected range is n..n (e.g. 10..10) when the thumbs are coincident. The arbitrary gap calculation imposed by the prior implementation results in different behavior based on step and range values.

This solution allows the range endpoints to be equal (no gap). The solution also ensures that the thumbs can always be accessed when thumb positions are the same (100% overlap). Fix initial position of minimum range thumb. The prior implementation was using the user defined range value as a "pixel", "x" value which resulted in the min track having the incorrect stop (filled in to the wrong x position).

There could be a new feature added to maintain a "gap" feature. This is out of scope for this PR.

Can ignore the import re-ordering - done by my lint rules.

Changelog
Eliminate the minimum gap between range slider thumbs (minimum gap is now 0).
Fix the initial position of the minimum range thumb.

ajp8164 added 2 commits August 9, 2022 23:56
…e accessed when thumb positions are the same, fix initial position of min thumb
@ethanshar ethanshar requested a review from Inbal-Tish August 10, 2022 05:56
@Inbal-Tish Inbal-Tish self-assigned this Aug 15, 2022
@@ -678,7 +678,9 @@ export default class Slider extends PureComponent<SliderProps, State> {
>
{this.renderTrack()}
<View style={styles.touchArea} onTouchEnd={this.handleTrackPress}/>
{useRange && this.renderMinThumb()}
<View style={[!this.isDefaultThumbActive() ? {zIndex: 1} : {zIndex: 0}, {top: '-50%'}]}>
Copy link
Collaborator

@Inbal-Tish Inbal-Tish Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<View style={[!this.isDefaultThumbActive() ? {zIndex: 1} : {zIndex: 0}, {top: '-50%'}]}>
<View style={{zIndex: this.isDefaultThumbActive() ? 0 : 1, top: '-50%'}}>

@Inbal-Tish
Copy link
Collaborator

@ajp8164 Hi. Thank you for your contribution, PR looks excellent! I saw you wrote that adding support for a gap is not in the scope of this PR, but without it, we're looking at UI-breaking change. We need to support it and pass 4 (MIN_RANGE_GAP) as the default, allowing users to choose the gap distance or pass 0 as no gap (or just choose no gap as boolean prop). Do you think you can add this to this PR?

@Inbal-Tish
Copy link
Collaborator

@ajp8164 Hi. Please see added features in PR #2248.

@Inbal-Tish Inbal-Tish closed this Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants