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

Range of one value #7

Open
rupadas opened this issue Feb 25, 2016 · 4 comments
Open

Range of one value #7

rupadas opened this issue Feb 25, 2016 · 4 comments

Comments

@rupadas
Copy link

rupadas commented Feb 25, 2016

I am unable to select a range of gap one like 33-34. How can i achieve that?

@Sundin
Copy link

Sundin commented May 18, 2016

Hello @rupadas

I solved this by halving the gapBetweenThumbs variable in the RangeSlider class like this:

var gapBetweenThumbs: Double {
    return Double(thumbWidth)*(maximumValue - minimumValue) / (Double(bounds.width)*2)
}

@khaptonstall
Copy link

khaptonstall commented May 21, 2016

@Sundin @rupadas This still didn't work for me. I was able to produce a range of 1 by using this:

var gapBetweenThumbs: Double {   
    var gap = (upperValue - lowerValue) / (Double(bounds.width)*2)
    return max(1.0, gap)
}

@warchimede
Copy link
Owner

Hi @rupadas @Sundin & @khaptonstall ,
First of all thanks for giving this project a try 👍
If @khaptonstall 's change really does the trick, can you please create a PR
so that I can merge easily ?

Thanks ! 💯

@khaptonstall
Copy link

@warchimede While it does allow for a single Int gap and solves this specific problem, it would break other things. Such as:

  • You would no longer be able to return a Double x, where lowerValue < x < upperValue
  • Also causes a problem when you drag both sliders all the way to the left, as the bottom slider (leftmost) reacts to the user touch when actually the top (rightmost) slider should react instead.

So I think further user customization would need to be added instead of my hacky change.

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

No branches or pull requests

4 participants