UNPKG

material-motion

Version:

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

133 lines (132 loc) 6.14 kB
import { NextChannel, Observable, Subscription } from 'indefinite-observable'; export { Connect, Disconnect, NextChannel, Observable, Observer, ObserverOrNext, Subscription } from 'indefinite-observable'; export { MotionAddable, MotionAppendUnitable, MotionClampable, MotionDebounceable, MotionDeduplicable, MotionDivisible, MotionFilterable, MotionFlattenable, MotionInvertible, MotionIsAnyOfable, MotionLoggable, MotionMappable, MotionMathOperable, MotionMeasurable, MotionMemorable, MotionMergeable, MotionMulticastable, MotionMultipliable, MotionNextOperable, MotionPluckable, MotionPolarizable, MotionReactiveMappable, MotionReactiveNextOperable, MotionReadable, MotionRenameable, MotionRewritable, MotionRewriteRangeable, MotionRewriteToable, MotionSeedable, MotionSubtractable, MotionTappable, MotionThresholdRangeable, MotionThresholdable, MotionTimestampable, MotionWindowable, ObservableWithFoundationalMotionOperators, ObservableWithMotionOperators } from './operators'; import { ObservableWithMotionOperators } from './operators'; import { State } from './enums'; export declare type Constructor<T> = new (...args: Array<any>) => T; export declare type Predicate<T> = (value: T) => boolean; export interface Subject<T> extends Observable<T> { next(value: T): void; } export declare type Operation<T, D> = (values: { upstream: T; } & D) => void; export declare type EmittingOperation<T, D, U> = (kwargs: { emit: NextChannel<U>; }) => Operation<T, D>; export declare type MathOperation = (a: number, b: number) => number; export declare type Dimensions = { width: number; height: number; }; export declare type Point2D = { x: number; y: number; }; export declare type PolarCoords = { angle: number; distance: number; }; export interface Spring<T> { readonly destination$: ObservableWithMotionOperators<T>; destination: T; readonly initialValue$: ObservableWithMotionOperators<T>; initialValue: T; readonly initialVelocity$: ObservableWithMotionOperators<T>; initialVelocity: T; readonly stiffness$: ObservableWithMotionOperators<number>; stiffness: number; readonly damping$: ObservableWithMotionOperators<number>; damping: number; readonly threshold$: ObservableWithMotionOperators<number>; threshold: number; readonly enabled$: ObservableWithMotionOperators<boolean>; enabled: boolean; readonly state$: ObservableWithMotionOperators<State>; readonly state: State; value$: ObservableWithMotionOperators<T>; } /** * There are 2 competing input events on the Web: `PointerEvent`s and * `TouchEvent`s. Our gesture system only needs 4 properties: x, y, type and an * ID. In both models, x and y are provided (both relative to the page and the * viewport). `TouchEvent` calls its ID `identifier`; whereas, `PointerEvent` * uses `pointerId`. * * `PartialPointerEvent` is the subset we care about. `PointerEvent` already * has this shape. `TouchEvent` can be trivially converted by extracting the * touches and renaming `identifier` to `pointerId`. */ export declare type PartialPointerEvent = Point2D & { pointerId?: number; type: string; }; export declare type PointerEventStreams = { down$: ObservableWithMotionOperators<PartialPointerEvent>; move$: ObservableWithMotionOperators<PartialPointerEvent>; up$: ObservableWithMotionOperators<PartialPointerEvent>; cancel$: ObservableWithMotionOperators<PartialPointerEvent>; contextMenu$: ObservableWithMotionOperators<PartialPointerEvent>; capturedClick$: ObservableWithMotionOperators<MouseEvent>; capturedDragStart$: ObservableWithMotionOperators<DragEvent>; }; export declare type Read<T> = () => T; export interface ScopedReadable<T> { read: Read<T>; } export declare type Write<T> = (value: T) => void; export interface ScopedWritable<T> { write: Write<T>; } export declare type TouchActionStyleStreams = { readonly touchAction$: ObservableWithMotionOperators<string>; }; export declare type WillChangeStyleStreams = { readonly willChange$: ObservableWithMotionOperators<string>; }; export declare type DimensionsStyleStreams = WillChangeStyleStreams & { readonly dimensions$: ObservableWithMotionOperators<Partial<Dimensions>>; }; export declare type TranslateStyleStreams = WillChangeStyleStreams & { readonly translate$: ObservableWithMotionOperators<Partial<Point2D>>; }; export declare type RotateStyleStreams = WillChangeStyleStreams & { readonly rotate$: ObservableWithMotionOperators<number>; }; export declare type ScaleStyleStreams = WillChangeStyleStreams & { readonly scale$: ObservableWithMotionOperators<number>; }; export declare type OpacityStyleStreams = WillChangeStyleStreams & { readonly opacity$: ObservableWithMotionOperators<number>; }; export declare type BoxShadowStyleStreams = { readonly boxShadow$: ObservableWithMotionOperators<string>; }; export declare type BorderRadiusStyleStreams = { readonly borderRadius$: ObservableWithMotionOperators<number | string | Array<number> | Array<string>>; }; export declare type StyleStreams = TouchActionStyleStreams & WillChangeStyleStreams & DimensionsStyleStreams & TranslateStyleStreams & ScaleStyleStreams & OpacityStyleStreams & BoxShadowStyleStreams & BorderRadiusStyleStreams; export declare type EqualityCheck = (a: any, b: any) => boolean; export interface Timestamped<T> { value: T; timestamp: number; } export declare type MaybeReactive<D> = { [K in keyof D]: D[K] | Observable<D[K]>; }; /** * `Array` has both members and methods. `MaybeReactive` iterates over all the * keys in an object. `MaybeReactive<NumericallyKeyed<T>>` allows you to * represent an array with potentially reactive members without worrying about * the methods. */ export declare type NumericallyKeyed<T> = { [index: number]: T; }; export declare type Dict<T> = { [index: string]: T; }; export declare type NumericDict = Dict<number>; export declare type StreamDict<T> = Dict<Observable<T>>; export declare type SubjectDict<T> = Dict<Subject<T>>; export declare type SubscriptionDict = Dict<Subscription>;