https://kotlinlang.org logo
Title
m

Michael Paus

11/26/2021, 11:51 AM
I would like to be able to pan my canvas content with some inertia effect. Does compose have any concept or tools to achieve that? Searching for “inertia” in the context of compose did not reveal anything useful. (E.g., JavaFX has this built into gesture handling by default. https://openjfx.io/javadoc/17/javafx.graphics/javafx/scene/input/GestureEvent.html)
a

Albert Chang

11/26/2021, 2:44 PM
Do you mean something like this? This is usually called "fling" in Android. You can use a
VelocityTracker
to calculate the velocity when a drag ends, and then use
animateDecay()
with the initial velocity.
m

Michael Paus

11/26/2021, 2:48 PM
Yes, that looks like it could be useful. Having the right keywords helps searching 😉