Skip to content

Instantly share code, notes, and snippets.

@PiotrPrus
Created December 1, 2021 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PiotrPrus/9299796a940f96e064cb9940ef19b157 to your computer and use it in GitHub Desktop.
Save PiotrPrus/9299796a940f96e064cb9940ef19b157 to your computer and use it in GitHub Desktop.
@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