Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active Apr 14, 2021
Embed
What would you like to do?
.pointerInput(Unit) {
detectHorizontalDragGestures { change, dragAmount ->
val original = Offset(offsetX.value, 0f)
val summed = original + Offset(x = dragAmount, y = 0f)
val newValue = Offset(x = summed.x.coerceIn(0f, cardOffset), y = 0f)
if (newValue.x >= 10) {
onExpand()
return@detectHorizontalDragGestures
} else if (newValue.x <= 0) {
onCollapse()
return@detectHorizontalDragGestures
}
change.consumePositionChange()
offsetX.value = newValue.x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment