Skip to content

Instantly share code, notes, and snippets.

@V-Abhilash-1999
Last active November 23, 2023 11:25
Show Gist options
  • Save V-Abhilash-1999/c7e273e43ed85dbabb409b97f4140a8d to your computer and use it in GitHub Desktop.
Save V-Abhilash-1999/c7e273e43ed85dbabb409b97f4140a8d to your computer and use it in GitHub Desktop.
Modifier.pointerInput(Unit) {
var moveSkipped = false
forEachGesture {
awaitPointerEventScope {
while (true) {
val event = awaitPointerEvent()
val firstChange = event.changes.firstOrNull() ?: continue
val position = firstChange.position
if(event.type == PointerEventType.Release && moveSkipped) {
moveSkipped = false
continue
}
if (event.type == PointerEventType.Move) {
val isUpward = firstChange.previousPosition.y < position.y
if ((webView.scrollY == 0 && isUpward)) {
moveSkipped = true
continue
} else if (webView.scrollY == webView.verticalScrollRange && !isUpward) {
moveSkipped = true
continue
} else {
event.changes.forEach { it.consume() }
}
} else {
event.changes.forEach { it.consume() }
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment