UNPKG

material-motion

Version:

Makes it easy to add rich, interactive motion to your application.

25 lines (24 loc) 1.28 kB
import { ObservableWithMotionOperators, Point2D } from './types'; export declare const MAXIMUM_AGE = 250; export declare const MAXIMUM_INCOMING_DISPATCHES = 5; export declare type GetVelocity$Args<U extends number | Point2D> = { value$: ObservableWithMotionOperators<U>; pulse$: ObservableWithMotionOperators<any>; maximumVelocity?: number; defaultVelocity?: number; }; /** * Computes the velocity of an incoming stream and emits the result. Velocity's * denominator is in milliseconds; if the incoming stream is measured in pixels, * the resulting stream will be in pixels / millisecond. * * Velocity is computed by watching the trailing 250ms of up to 5 emissions and * measuring the distance between the longest pair of events moving in the * current direction. This approach is more resiliant to anomolous data than a * simple (nextPosition - prevPosition) / (nextTime - prevTime). * * If `pulse$` is supplied, `velocity(pulse$)` will only emit values when * `pulse$` emits a value. This is useful for ensuring that velocity is only * calculated when it will be used. */ export declare function getVelocity$<U extends number | Point2D>({value$, pulse$, maximumVelocity, defaultVelocity}: GetVelocity$Args<U>): ObservableWithMotionOperators<U>;