Last active
April 14, 2021 08:12
-
-
Save Skyyo/37fbca46bc1ff31b79b6ad02d24d35e6 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
.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