Last active
November 23, 2023 11:25
-
-
Save V-Abhilash-1999/c7e273e43ed85dbabb409b97f4140a8d 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
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