What is the use case for `detectDragGestures` ? Gi...
# compose
d
What is the use case for
detectDragGestures
? Given that
onDragStart
's
position
parameter is not the one from the user's mouse down and instead the one after the "slop" movement. This makes is such that in any draggable region with multiple elements (
LazyColumn
) you cannot determine which element the user intended to drag from.
a
The slop is needed to distinguish click and drag. If you don't need to detect click, you can provide your own
ViewConfiguration
with a zero touch slop.
d
I understand what the slop is for, the problem is
onDragStart
gives you the pointer position after slop, instead the initial down position.
onDrag
already gives you that almost immediately, so it makes
onDragStart
almost useless.
a
So what is the problem? The drag starts after the touch movement exceed the touch slop, which is intended.
d
If the user starts their gesture at the edge of an element, within slop distance of its edge and moves their pointer towards that edge, the position the onDragStart will provide will be outside of the user's target element.
a
Yes that’s by design and you can always set touch slop to zero.
And the case where you need to determine which element the user intended to drag from is the minor. Usually you just detect drag gesture on individual elements.
d
How do you set slop? I'm on desktop.
a
By providing your own
ViewConfiguration
to
LocalViewConfiguration
.
d
Thanks! Just found it.