Skip to content

Instantly share code, notes, and snippets.

@andreymusth
Created July 19, 2021 08:48
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 andreymusth/4dc80ef19a4f1f99b79be7603c45c16e to your computer and use it in GitHub Desktop.
Save andreymusth/4dc80ef19a4f1f99b79be7603c45c16e to your computer and use it in GitHub Desktop.
fun Modifier.pointerInput(
key1: Any?,
block: suspend PointerInputScope.() -> Unit
): Modifier = composed(
...
) {
val density = LocalDensity.current
val viewConfiguration = LocalViewConfiguration.current
remember(density) { SuspendingPointerInputFilter(viewConfiguration, density) }.apply {
LaunchedEffect(this, key1) {
block()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment