androidx.compose.ui.input.pointer.util

Classes

VelocityTracker

Computes a pointer's velocity.

Cmn
VelocityTracker1D

A velocity tracker calculating velocity in 1 dimension.

Cmn

Annotations

Extension functions summary

Unit

Track the positions and timestamps inside this event change.

Cmn

Top-level properties summary

Boolean

A flag to indicate that we'll use the fix of how we add points to the velocity tracker.

Cmn
Boolean

Selecting flag to enable impulse strategy for the velocity trackers.

Cmn

Extension functions

addPointerInputChange

fun VelocityTracker.addPointerInputChange(event: PointerInputChange): Unit

Track the positions and timestamps inside this event change.

For optimal tracking, this should be called for the DOWN event and all MOVE events, including any touch-slop-captured MOVE event.

Since Compose uses relative positions inside PointerInputChange, this should be taken into consideration when using this method. Right now, we use the first down to initialize an accumulator and use subsequent deltas to simulate an actual movement from relative positions in PointerInputChange. This is required because VelocityTracker requires data that can be fit into a curve, which might not happen with relative positions inside a moving target for instance.

Parameters
event: PointerInputChange

Pointer change to track.

Top-level properties

VelocityTrackerAddPointsFix

@ExperimentalComposeUiApi
var VelocityTrackerAddPointsFixBoolean

A flag to indicate that we'll use the fix of how we add points to the velocity tracker.

This is an experiment flag and will be removed once the experiments with the fix a finished. The final goal is that we will use the true path once the flag is removed. If you find any issues with the new fix, flip this flag to false to confirm they are newly introduced then file a bug. Tracking bug: (b/318621681)

VelocityTrackerStrategyUseImpulse

@ExperimentalVelocityTrackerApi
var VelocityTrackerStrategyUseImpulseBoolean

Selecting flag to enable impulse strategy for the velocity trackers. This is an experiment flag and will be removed once the experiments with the fix a finished. The final goal is that we will use the true path once the flag is removed. If you find any issues with the new fix, flip this flag to false to confirm they are newly introduced then file a bug. Tracking bug: (b/318621681)