warchimede / RangeSlider

A simple range slider made in Swift
MIT License
356 stars 77 forks source link

Range of one value #7

Open rupadas opened 8 years ago

rupadas commented 8 years ago

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

Sundin commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

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

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