https://kotlinlang.org logo
#compose
Title
# compose
p

Piotr Prus

02/16/2021, 12:48 PM
I am experimenting with gesture detection in compose. Here is the code snipped:
Copy code
Surface(color = MaterialTheme.colors.background) {
                    Box(modifier = Modifier.size(100.dp).background(Color.Yellow)
                        .pointerInput(Unit) {
                            detectVerticalDragGestures(
                                onDragCancel = { Log.d("AAAA", "onDragCancel") },
                                onDragEnd = { Log.d("AAAA", "onDragEnd") },
                                onVerticalDrag = { change, dragAmount -> Log.d("AAAA", "Drag change: $dragAmount") }
                            )
                        })
                }
It is a simple Box. The issue:
onDragEnd
and
onDragCancel
are never called. The
onVerticalDrag
works like a charm. Is there any mistake in my code or should I file a bug? Compose version : alpha12
j

Jan Bína

02/16/2021, 12:56 PM
you have to consume the
change
in
onVerticalDrag
if you want to accept the drag motion
p

Piotr Prus

02/16/2021, 1:00 PM
Thank you. You save my day!
👍 1
5 Views