UNPKG

1.73 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 * Gesture type attached to the observer.
31 */
32 type: GestureTypes;
33
34 /**
35 * A function that will be executed when a gesture is received.
36 */
37 callback: (args: GestureEventData) => void;
38
39 /**
40 * A context which will be used as `this` in callback execution.
41 */
42 context: any;
43
44 /**
45 * An internal Android specific method used to pass the motion event to the correct gesture observer.
46 */
47 androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void;
48}
49
50/**
51 * A short-hand function that is used to create a gesture observer for a view and gesture.
52 * @param target - View which will be watched for originating a specific gesture.
53 * @param type - Type of the gesture.
54 * @param callback - A function that will be executed when a gesture is received.
55 * @param context - this argument for the callback.
56 */
57export function observe(target: View, type: GestureTypes, callback: (args: GestureEventData) => void, context?: any): GesturesObserver;