ThunderStruct / MSCircularSlider

A fully-featured, powerful circular slider for iOS applications
MIT License
119 stars 30 forks source link

Don't go from 100% to 0% if the swipe continues #13

Open ghost opened 5 years ago

ghost commented 5 years ago

I have a 270 degree slider. If I swipe beyond 100%, (or reach too close to the starting point), the slider resets to 0%! Can you add a setting where the slider will stay at 100% (and symetrically at 0%) if we over (or under) swipe?

Thanks!

ThunderStruct commented 5 years ago

That was requested already and (good news!) I already implemented it. I'm currently implementing a few more features and fixes I have on my list before I commit the changes and update the pod. Should be out by tomorrow hopefully!

ThunderStruct commented 5 years ago

Released 1.3.0 and updated the pod!

ghost commented 5 years ago

I've upgraded to 1.3.0 and set maximumRevolutions to 0. But since my slider is 300 degrees (not a full circle), this doesn't work. Is there any reason why there is a limitation of this feature to work with only full circles?

ThunderStruct commented 5 years ago

I see... I may have misunderstood what you meant at first!

The reason why this works on full circles only is because semi-circular sliders stop at 100% by default. However, when you slide further, it would snap back at 0%, which (as I understand) is your issue here.

Even if the slider is a full circle and you set maximumRevolutions to 0, it would still snap to other values after 180 degrees beyond 100% (you could try it to get a better grasp on what I mean).

The problem with what you're asking for is that the slider computes the handle's angle and value based solely on the current touch location, neglecting any previous sliding. I.e: given a certain touch location, the handle would get drawn at its corresponding angle. I thought of a couple of workarounds off the top of my head now that could essentially solve this issue, but unfortunately it'll probably take a few days (possibly a couple of weeks) to implement it because I'm really busy these few days! Regardless, I'm reopening the issue in case anyone wants to implement it and PR in the time being. Have a good day!

ghost commented 5 years ago

Thank you! That's exactly what I mean.