Skip to content

Instantly share code, notes, and snippets.

@Skyyo
Last active April 14, 2021 08:12
Show Gist options
  • Save Skyyo/37fbca46bc1ff31b79b6ad02d24d35e6 to your computer and use it in GitHub Desktop.
Save Skyyo/37fbca46bc1ff31b79b6ad02d24d35e6 to your computer and use it in GitHub Desktop.
.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