FlingAnimator

class FlingAnimator(scheduler: FrameScheduler, applyPanDelta: (deltaPxX: Double, deltaPxY: Double) -> Unit, onActiveChange: (active: Boolean) -> Unit = {})

Drives a per-frame action with monotonically decaying velocity until the velocity drops below a threshold. The platform supplies a FrameScheduler that fires a tick on each render frame (Choreographer / requestAnimationFrame / Swing Timer); each tick computes its own elapsed time so the animation stays correct even when the scheduler's interval drifts.

Used for inertial pan ("fling") after a drag/pan gesture. Distance integrates to v0 / k (linear in initial velocity) and duration is ln(v0 / vMin) / k (logarithmic) — so harder flicks travel proportionally further while still settling in roughly the same wall-clock time.

Constructors

Link copied to clipboard
constructor(scheduler: FrameScheduler, applyPanDelta: (deltaPxX: Double, deltaPxY: Double) -> Unit, onActiveChange: (active: Boolean) -> Unit = {})

Properties

Link copied to clipboard

Exponential decay rate per second. With decayPerSecond = 3.0 velocity halves every ~230 ms.

Link copied to clipboard
Link copied to clipboard

Velocities below this magnitude (in caller's units per millisecond) are treated as stopped.

Functions

Link copied to clipboard
fun cancel()

Cancels an in-progress fling. Safe to call when not active.

Link copied to clipboard
fun start(vx0: Double, vy0: Double)

Begins a fling at the given velocity. A no-op if the speed is below minVelocity.