# androidx.compose.ui.input.pointer.util

Common/All

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/VelocityTracker` | Calculates the velocity of a pointer based on tracked pointer events or positions and timestamps. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/VelocityTracker1D` | A velocity tracker calculating velocity in 1 dimension. | Cmn |

## Extension functions summary

|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/VelocityTracker.https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/package-summary#(androidx.compose.ui.input.pointer.util.VelocityTracker).addPointerInputChange(androidx.compose.ui.input.pointer.PointerInputChange)(event: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputChange)` Track the positions and timestamps inside this event change. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/VelocityTracker.https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/package-summary#(androidx.compose.ui.input.pointer.util.VelocityTracker).addPointerInputChange(androidx.compose.ui.input.pointer.PointerInputChange,androidx.compose.ui.geometry.Offset)( event: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputChange, offset: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset )` Track the positions and timestamps inside this event change. | Cmn |

## Extension functions

### VelocityTracker.addPointerInputChange

Cmn Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/input/pointer/util/VelocityTracker.kt+function:addPointerInputChange) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.1.0)

```
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: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputChange` | Pointer change to track. |

### VelocityTracker.addPointerInputChange

Cmn Artifact: [androidx.compose.ui:ui](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/input/pointer/util/VelocityTracker.kt+function:addPointerInputChange) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun VelocityTracker.addPointerInputChange(
    event: PointerInputChange,
    offset: Offset
): 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: https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputChange` | Pointer change to track. |
| `offset: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset` | An optional offset that should be applied to the position of the `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/util/package-summary#(androidx.compose.ui.input.pointer.util.VelocityTracker).addPointerInputChange(androidx.compose.ui.input.pointer.PointerInputChange,androidx.compose.ui.geometry.Offset)` before adding it to the tracker. |