iOS-Components icon indicating copy to clipboard operation
iOS-Components copied to clipboard

Wrong calculation of handler positions and restoration of value from handler position

Open Moes81 opened this issue 11 years ago • 2 comments

Thanks for this control! I'm using it in two Enterprise apps extensively! Also loved the vertical possibility! :-)

But, I recognized a calculation issue, when the minValue of the scale is not set to 0. The handler positions are not relative to the represented sector but absolut to the span.

Try: minValue = 10, maxValue = 30 and move Slider to positions 15 and 28. You should instantly see, what I mean.

However, I'm not just complaining, but I have also the solution :-)

In moveSliderToPosition calculate the handler center like so: CGPointMake(sliderBarWidth * ([leftSlider floatValue] - minValue) / (maxValue - minValue), sliderBarHeight * 0.5);

And in the updateValues do the following: self.minSelectedValue = _minValue + (self.minHandle.center.x * (_maxValue - _minValue) / sliderBarWidth);

Regards, Moes

Moes81 avatar Apr 19 '13 07:04 Moes81

Thanks for the appreciation - great to hear people find this useful - and for the solution! Not sure when I'll be able to add these changes back into the project so you can show your appreciation further with a pull request ;)

Kindest regards, Dimitris

doukasd avatar Apr 23 '13 15:04 doukasd

@Moes81 facing same problem with right slider ,Please help me to resolve ....Thanks

akainth avatar May 27 '15 13:05 akainth