dimsuz
08/07/2022, 12:46 PMBox and I want to use pointerInput to detect drag gestures inside this box, but I want to ignore cases when drag starts in the smaller child in center of that box. For example box is 400x400.dp and I want to ignore drags coming from within 100x100.dp of its centered child.
How can I achieve this? Use onGlobalLayout to capture the position and size of the child and then in onDrag check if change: PointerInputChange comes from a child area and do not do what I usually do there in this case?MR3Y
08/07/2022, 1:19 PMinteractionSource of the child, and do nothing in case it was being dragged:
val interactionSource = remember { MutableInteractionSource() }
val isChildDragged by interactionSource.collectIsDraggedAsState()
Box(
modifier = Modifier.pointerInput{
// check if isChildDragged or not
}
) {
Child(
modifier = Modifier.draggable(
interactionSource = interactionSource,
...
)
)
}Zach Klippenstein (he/him) [MOD]
08/07/2022, 2:59 PMonGloballyPositioned for this case, onPlaced is sufficient and much cheaper since you're only using it to grab the LayoutCoordinates and then read it later.Zach Klippenstein (he/him) [MOD]
08/07/2022, 3:00 PMdimsuz
08/07/2022, 3:18 PMZach Klippenstein (he/him) [MOD]
08/07/2022, 6:27 PMZach Klippenstein (he/him) [MOD]
08/07/2022, 6:27 PMdimsuz
08/07/2022, 8:45 PMpointerInput + detectDragGestures . I see that change parameter of the latter has the consume method, so I will play with this! 🙂