a914-gowtham / compose-ratingbar

ratingbar composable for jetpack compose :rocket::star2:
MIT License
230 stars 20 forks source link

Drag event stops working when touch leaves view #16

Closed jollygreenegiant closed 2 years ago

jollygreenegiant commented 2 years ago

When dragging along the RatingBar, if your finger leaves the bounds of the view, the stars stop updating. For example, if I have the RatingBar in the top left corner of the screen, as a user, I would expect that if I touched inside the stars and dragged to the bottom right of the screen, the rating bar should fill up and not lose my touch event when my finger leaves the stars.

I think the rating bar should track the X position of the users finger regardless of where it is on the screen, as long as the touch started inside the RatingBar. This is the same behavior that sliders have in Android, which is why it feels like it should be the default behavior here as well.

a914-gowtham commented 2 years ago

Hi @jollygreenegiant , Is this the behaviour you expect?

https://user-images.githubusercontent.com/68514286/142217441-7ce1eff2-4e78-40b2-ba49-2f4506ac1795.mp4

jollygreenegiant commented 2 years ago

Yes, that is exactly what I would expect, thanks for the video! That is not what I'm seeing though, is there a way to get that behavior?

a914-gowtham commented 2 years ago

@jollygreenegiant Great, That is how it works by default. in your screen, any root composable might affect the drag event. to verify the behaviour, you could test ratingbar composable on a separate screen.

jollygreenegiant commented 2 years ago

I've done some looking into this and the issue is because I have the rating bar in a LazyColumn, and the vertical component of the drag on the rating bar is being picked up by the LazyColumn instead. I didn't realize this at first because the LazyColumn didn't have enough things in it to be scrollable, but once the list goes off the end of the screen, the vertical component of the drag on the rating bar is used to scroll the LazyColumn.

Any ideas how to fix that?

jollygreenegiant commented 2 years ago

Similarly, if this RatingBar were placed in a LazyRow, I imagine that the horizontal drag on the rating bar would be consumed by the LazyRow instead

a914-gowtham commented 2 years ago

Thanks, @jollygreenegiant I am able to reproduce the issue. will update a workaround or fix asap

jollygreenegiant commented 2 years ago

Thank you!

a914-gowtham commented 2 years ago

Hi @jollygreenegiant , fixed the issue in the latest version 1.2.0 thanks for finding this one

https://user-images.githubusercontent.com/68514286/146672164-eec3fb7d-a8e4-4b18-90c5-06e85acfca72.mp4

.