UNPKG

1.86 kBTypeScriptView Raw
1import type { View } from '../core/view';
2
3export * from './gestures-common';
4export * from './touch-manager';
5
6/**
7 * Provides options for the GesturesObserver.
8 */
9export class GesturesObserver {
10 /**
11 * Creates an instance of GesturesObserver class.
12 * @param target - The view for which the observer is created.
13 * @param callback - A function that will be executed when a gesture is received.
14 * @param context - default this argument for the callbacks.
15 */
16 constructor(target: View, callback: (args: GestureEventData) => void, context: any);
17
18 /**
19 * Registers a gesture observer to a view and gesture.
20 * @param type - Type of the gesture.
21 */
22 observe(type: GestureTypes);
23
24 /**
25 * Disconnects the gesture observer.
26 */
27 disconnect();
28
29 /**
30 * Singular gesture type (e.g. GestureTypes.tap) attached to the observer.
31 * Does not support plural gesture types (e.g.
32 * GestureTypes.tap & GestureTypes.doubleTap).
33 */
34 type: GestureTypes;
35
36 /**
37 * A function that will be executed when a gesture is received.
38 */
39 callback: (args: GestureEventData) => void;
40
41 /**
42 * A context which will be used as `this` in callback execution.
43 */
44 context: any;
45
46 /**
47 * An internal Android specific method used to pass the motion event to the correct gesture observer.
48 */
49 androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void;
50}
51
52/**
53 * A short-hand function that is used to create a gesture observer for a view and gesture.
54 * @param target - View which will be watched for originating a specific gesture.
55 * @param type - Type of the gesture.
56 * @param callback - A function that will be executed when a gesture is received.
57 * @param context - this argument for the callback.
58 */
59export function observe(target: View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver;