Created
December 1, 2021 23:10
-
-
Save PiotrPrus/9299796a940f96e064cb9940ef19b157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun Modifier.startGesture( | |
onStart: (offsetX: Float) -> Unit | |
): Modifier { | |
val interactionSource = remember { MutableInteractionSource() } | |
return this.pointerInput(interactionSource) { | |
forEachGesture { | |
coroutineScope { | |
awaitPointerEventScope { | |
val touch = awaitFirstDown().also { it.consumeDownChange() } | |
onStart(touch.position.x) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment