HamzaGhazouani/HGCircularSlider

Setting MinimumValue Causes Thumb to Jump when Touched

Etep15 opened this issue ยท 6 comments

First of all, great little library you have here. Works great! :)

I'm using the RangeSlider and have set the minimumValue to 5 and the maximumValue to 30.

When I touch on one of the thumbs it jumps forward by 5 (the minimumValue). A quick fix I did was to change the delta function in CircularSliderHelper.swift. Instead of...

return scaleValue(deltaAngle, fromInterval: angleIntreval, toInterval: interval);

I changed it to...

let scaledValue = scaleValue(deltaAngle, fromInterval: angleIntreval, toInterval: interval) - interval.min;
		
return scaledValue;

This seems to have solved the problem. I'm not sure if this is the best place to put this or if it should've been in the ScaleValue function?

I take it back. My fix works for the immediate problem. But then when I try to set a thumb to somewhere in the middle it is offset. For instance if use some odd numbers such as min 5 and max 37 and then set one of the thumbs to 16 (the midpoint) my thumb is offset by 4. Will keep digging into it.

Ok finally found the fix that appears to be working. Again it's in CircularSwilderHelper.swift in the function scaleValue

let newValue = (((scaledValue - source.min) * destinationRange) / sourceRange) + destination.min

Should be...

let newValue = (((scaledValue - source.min) * destinationRange) / sourceRange)

Adding destination.min is what was offsetting the thumb. I've done a bunch of testing and this does all appear to work. But would like confirmation from others.

Hi @Etep15, thanks for using the library, can you please check if we have the issue with the version 2.2.0, also, I will be happy to see your PR with the fix :)
thanks a lot for your feedback

I reproduced the issue with the latest version

Still buggy @HamzaGhazouani
However, the way @Etep15 proposed did work. [Version 2.2.0

Fixed ๐ŸŽ‰ thank you guys for reporting that