import
import androidx.compose.foundation.gestures.detectHorizontalDragGestures
import androidx.compose.ui.input.pointer.pointerInput
コード
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
var totalDrag = 0f Column( modifier = Modifier .pointerInput(Unit) { detectHorizontalDragGestures( onDragStart = { totalDrag = 0f }, onDragEnd = { when { totalDrag < -150f -> { // 右から左 } totalDrag > 150f -> { // 左から右 } } } ) { _, dragAmount -> totalDrag += dragAmount } } ) |