oli107 / material-range-bar

Android widget for selecting a range of values.
Apache License 2.0
1.68k stars 370 forks source link

Fixed bug in RangeBar #112

Closed MaxHastings closed 6 years ago

MaxHastings commented 7 years ago

You shouldn't be using getLeft() when computing componentLeft. X is event.GetX() which is a relative location to the view itself, in this case RangeBar. You need to detect if x <= 0. Because if x is less than 0 it means that you are outside and to the left of the RangeBar. If X is greater than 0 you are still inside the RangeBar view. This was creating a bug where the selector would jump to index 0 when it shouldn't be.

krazykira commented 6 years ago

@maxwell10206 can you please provide a gif or photo of the problem. I don't completely understand whats the problem here.

MaxHastings commented 6 years ago

@krazykira You can replicate the problem by creating a range bar that has a width that matches the parent view. And set it up so the range bar goes from something like 0 to 100. And then try to slide the slider to 1. What should happen is it won't let you and it will snap to the left most value which is 0 in this case.

krazykira commented 6 years ago

@maxwell10206 ok Got it. I will fix it. and close this PR as there are conflicts between it and current project and the change is just one liner.