1 | import type { GesturesObserver as GesturesObserverDefinition } from '.';
|
2 | import type { View } from '../core/view';
|
3 | import type { EventData } from '../../data/observable';
|
4 | export * from './touch-manager';
|
5 | /**
|
6 | * Events emitted during gesture lifecycle
|
7 | */
|
8 | export declare enum GestureEvents {
|
9 | /**
|
10 | * When the gesture is attached to the view
|
11 | * Provides access to the native gesture recognizer for further customization
|
12 | */
|
13 | gestureAttached = "gestureAttached",
|
14 | /**
|
15 | * When a touch down was detected
|
16 | */
|
17 | touchDown = "touchDown",
|
18 | /**
|
19 | * When a touch up was detected
|
20 | */
|
21 | touchUp = "touchUp"
|
22 | }
|
23 | /**
|
24 | * Defines an enum with supported gesture types.
|
25 | */
|
26 | export declare enum GestureTypes {
|
27 | /**
|
28 | * Denotes tap (click) gesture.
|
29 | */
|
30 | tap = 1,
|
31 | /**
|
32 | * Denotes double tap gesture.
|
33 | */
|
34 | doubleTap = 2,
|
35 | /**
|
36 | * Denotes pinch gesture.
|
37 | */
|
38 | pinch = 4,
|
39 | /**
|
40 | * Denotes pan gesture.
|
41 | */
|
42 | pan = 8,
|
43 | /**
|
44 | * Denotes swipe gesture.
|
45 | */
|
46 | swipe = 16,
|
47 | /**
|
48 | * Denotes rotation gesture.
|
49 | */
|
50 | rotation = 32,
|
51 | /**
|
52 | * Denotes long press gesture.
|
53 | */
|
54 | longPress = 64,
|
55 | /**
|
56 | * Denotes touch action.
|
57 | */
|
58 | touch = 128
|
59 | }
|
60 | /**
|
61 | * Defines an enum with supported gesture states.
|
62 | */
|
63 | export declare enum GestureStateTypes {
|
64 | /**
|
65 | * Gesture canceled.
|
66 | */
|
67 | cancelled = 0,
|
68 | /**
|
69 | * Gesture began.
|
70 | */
|
71 | began = 1,
|
72 | /**
|
73 | * Gesture changed.
|
74 | */
|
75 | changed = 2,
|
76 | /**
|
77 | * Gesture ended.
|
78 | */
|
79 | ended = 3
|
80 | }
|
81 | /**
|
82 | * Defines an enum for swipe gesture direction.
|
83 | */
|
84 | export declare enum SwipeDirection {
|
85 | /**
|
86 | * Denotes right direction for swipe gesture.
|
87 | */
|
88 | right = 1,
|
89 | /**
|
90 | * Denotes left direction for swipe gesture.
|
91 | */
|
92 | left = 2,
|
93 | /**
|
94 | * Denotes up direction for swipe gesture.
|
95 | */
|
96 | up = 4,
|
97 | /**
|
98 | * Denotes down direction for swipe gesture.
|
99 | */
|
100 | down = 8
|
101 | }
|
102 | /**
|
103 | * Defines a touch action
|
104 | */
|
105 | export declare enum TouchAction {
|
106 | /**
|
107 | * Down action.
|
108 | */
|
109 | down = "down",
|
110 | /**
|
111 | * Up action.
|
112 | */
|
113 | up = "up",
|
114 | /**
|
115 | * Move action.
|
116 | */
|
117 | move = "move",
|
118 | /**
|
119 | * Cancel action.
|
120 | */
|
121 | cancel = "cancel"
|
122 | }
|
123 | /**
|
124 | * Provides gesture event data.
|
125 | */
|
126 | export interface GestureEventData extends EventData {
|
127 | /**
|
128 | * Gets the type of the gesture.
|
129 | */
|
130 | type: GestureTypes;
|
131 | /**
|
132 | * Gets the view which originates the gesture.
|
133 | */
|
134 | view: View;
|
135 | /**
|
136 | * Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/).
|
137 | */
|
138 | ios: any;
|
139 | /**
|
140 | * Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html).
|
141 | */
|
142 | android: any;
|
143 | }
|
144 | /**
|
145 | * Provides gesture event data.
|
146 | */
|
147 | export interface TapGestureEventData extends GestureEventData {
|
148 | /**
|
149 | * Gets the number of pointers in the event.
|
150 | */
|
151 | getPointerCount(): number;
|
152 | /**
|
153 | * Gets the X coordinate of this event inside the view that triggered the event
|
154 | */
|
155 | getX(): number;
|
156 | /**
|
157 | * Gets the Y coordinate of the event inside the view that triggered the event.
|
158 | */
|
159 | getY(): number;
|
160 | }
|
161 | /**
|
162 | * Provides gesture event data.
|
163 | */
|
164 | export interface TouchGestureEventData extends TapGestureEventData {
|
165 | /**
|
166 | * Gets action of the touch. Possible values: 'up', 'move', 'down', 'cancel'
|
167 | */
|
168 | action: 'up' | 'move' | 'down' | 'cancel';
|
169 | /**
|
170 | * Gets the pointers that triggered the event.
|
171 | * Note: In Android there is aways only one active pointer.
|
172 | */
|
173 | getActivePointers(): Array<Pointer>;
|
174 | /**
|
175 | * Gets all pointers.
|
176 | */
|
177 | getAllPointers(): Array<Pointer>;
|
178 | }
|
179 | /**
|
180 | * Pointer is an object representing a finger (or other object) that is touching the screen.
|
181 | */
|
182 | export interface Pointer {
|
183 | /**
|
184 | * The id of the pointer.
|
185 | */
|
186 | android: any;
|
187 | /**
|
188 | * The UITouch object associated to the touch
|
189 | */
|
190 | ios: any;
|
191 | /**
|
192 | * Gets the X coordinate of the pointer inside the view that triggered the event.
|
193 | */
|
194 | getX(): number;
|
195 | /**
|
196 | * Gets the Y coordinate of the pointer inside the view that triggered the event.
|
197 | */
|
198 | getY(): number;
|
199 | /**
|
200 | * Gests the X coordinate of the pointer inside the view that triggered the event.
|
201 | * @returns The X coordinate in _Device Pixels_.
|
202 | */
|
203 | getXPixels(): number;
|
204 | /**
|
205 | * Gets the X coordinate of the pointer inside the view that triggered the event.
|
206 | * @returns The X coordinate in _Device Independent Pixels_.
|
207 | */
|
208 | getXDIP(): number;
|
209 | /**
|
210 | * Gests the Y coordinate of the pointer inside the view that triggered the event.
|
211 | * @returns The Y coordinate in _Device Pixels_.
|
212 | */
|
213 | getYPixels(): number;
|
214 | /**
|
215 | * Gets the Y coordinate of the pointer inside the view that triggered the event.
|
216 | * @returns The Y coordinate in _Device Independent Pixels_.
|
217 | */
|
218 | getYDIP(): number;
|
219 | }
|
220 | /**
|
221 | * Provides gesture event data.
|
222 | */
|
223 | export interface GestureEventDataWithState extends GestureEventData {
|
224 | state: number;
|
225 | }
|
226 | /**
|
227 | * Provides gesture event data for pinch gesture.
|
228 | */
|
229 | export interface PinchGestureEventData extends GestureEventDataWithState {
|
230 | scale: number;
|
231 | getFocusX(): number;
|
232 | getFocusY(): number;
|
233 | }
|
234 | /**
|
235 | * Provides gesture event data for swipe gesture.
|
236 | */
|
237 | export interface SwipeGestureEventData extends GestureEventData {
|
238 | direction: SwipeDirection;
|
239 | }
|
240 | /**
|
241 | * Provides gesture event data for pan gesture.
|
242 | */
|
243 | export interface PanGestureEventData extends GestureEventDataWithState {
|
244 | deltaX: number;
|
245 | deltaY: number;
|
246 | }
|
247 | /**
|
248 | * Provides gesture event data for rotation gesture.
|
249 | */
|
250 | export interface RotationGestureEventData extends GestureEventDataWithState {
|
251 | rotation: number;
|
252 | }
|
253 | /**
|
254 | * Returns a string representation of a gesture type.
|
255 | * @param type - The singular type of the gesture. Looks for an exact match, so
|
256 | * passing plural types like `GestureTypes.tap & GestureTypes.doubleTap` will
|
257 | * simply return undefined.
|
258 | */
|
259 | export declare function toString(type: GestureTypes): (typeof GestureTypes)[GestureTypes] | undefined;
|
260 | /**
|
261 | * Returns a gesture type enum value from a string (case insensitive).
|
262 | *
|
263 | * @param type - A string representation of a single gesture type (e.g. "tap").
|
264 | */
|
265 | export declare function fromString(type: (typeof GestureTypes)[GestureTypes]): GestureTypes | undefined;
|
266 | export declare abstract class GesturesObserverBase implements GesturesObserverDefinition {
|
267 | private _callback;
|
268 | private _target;
|
269 | private _context?;
|
270 | /** This is populated on the first call to observe(). */
|
271 | type: GestureTypes;
|
272 | get callback(): (args: GestureEventData) => void;
|
273 | get target(): View;
|
274 | get context(): any;
|
275 | constructor(target: View, callback: (args: GestureEventData) => void, context?: any);
|
276 | abstract androidOnTouchEvent(motionEvent: android.view.MotionEvent): any;
|
277 | abstract observe(type: GestureTypes): any;
|
278 | disconnect(): void;
|
279 | }
|