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

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

samples
requis
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

Valeur de retour

La valeur retournée par cet util.

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

Usage

Exemples

Extraits de code prêts à coller.

Compute fling velocity from touch samples

typescript