fix #414: when multiple thumbs are being touched at the same time, set the current thumb to the closest of the touch event #417
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#404
First ever PR in public repo, please be kind.
Run into this issue recently and since it's a must have in my project, I decided to dig a little bit into it. The problem in general was the way the lib detects when a thumb is being touched or not. If more than 1 thumb are being touched, it will only set the current one to the first being touched, being the earliest in the values array.
So the first fix is to make an array hitThumbs to get which ones are being touched. For each thumb, we get either the distance to the touch or false. Then if at least one of the thumbs is being touched, we make an array of the distance to touch and for the false value, we assign a dummy value (props.maximumValue) and we use indexOfLowest to get the closest thumb from the touch. This thumb is the one that should be dragged
I updated the trackDistanceToPoint to get the absolute distance from the center of the thumb.
Let me know if you have any questions!
Simulator.Screen.Recording.-.14.pro.demo.uti.-.2023-10-04.at.21.40.07.mp4