calculateImpulseVelocity

Commons
stable

Estimate the fling velocity from a reversed-time array of pointer samples using a weighted impulse algorithm. Returns 0 when fewer than 2 samples are available.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

samples
required
Array<ISample>
Array of { d: number, t: number } displacement/time pairs in reversed time order (most recent sample at index 0). ISample is { d: number; t: number }.

API

Return value

The value returned by this util.

Estimated velocity in pixels per millisecond. Returns 0 when the input has fewer than 2 samples or all timestamps are identical.

Usage

Examples

Ready-to-paste usage snippets.

Compute fling velocity from touch samples

typescript