Function

detectVerticalDragGestures

Gesture detector that waits for pointer down and touch slop in the vertical direction and then calls [onVerticalDrag] for each vertical drag event.

DetectVerticalDragGesturesSample

@Composable
fun DetectVerticalDragGesturesSample() {
    val offsetX = remember { mutableStateOf(0f) }
    val offsetY = remember { mutableStateOf(0f) }
    var height by remember { mutableStateOf(0f) }
    Box(Modifier.fillMaxSize().onSizeChanged { height = it.height.toFloat() }) {
        Box(
            Modifier.offset { IntOffset(offsetX.value.roundToInt(), offsetY.value.roundToInt()) }
                .fillMaxWidth()
                .height(50.dp)
                .background(Color.Blue)
                .pointerInput(Unit) {
                    detectVerticalDragGestures { _, dragAmount ->
                        val originalY = offsetY.value
                        val newValue = (originalY + dragAmount).coerceIn(0f, height - 50.dp.toPx())
                        offsetY.value = newValue
                    }
                }
        )
    }
}