forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hammerjs.d.ts
333 lines (264 loc) · 7.68 KB
/
hammerjs.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
// Type definitions for Hammer.js 2.0.4
// Project: http://hammerjs.github.io/
// Definitions by: Philip Bulley <https://github.com/milkisevil/>, Han Lin Yap <https://github.com/codler>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var Hammer:HammerStatic;
declare module "hammerjs" {
export = Hammer;
}
interface HammerStatic
{
new( element:HTMLElement | SVGElement, options?:any ): HammerManager;
defaults:HammerDefaults;
VERSION: number;
INPUT_START: number;
INPUT_MOVE: number;
INPUT_END: number;
INPUT_CANCEL: number;
STATE_POSSIBLE: number;
STATE_BEGAN: number;
STATE_CHANGED: number;
STATE_ENDED: number;
STATE_RECOGNIZED: number;
STATE_CANCELLED: number;
STATE_FAILED: number;
DIRECTION_NONE: number;
DIRECTION_LEFT: number;
DIRECTION_RIGHT: number;
DIRECTION_UP: number;
DIRECTION_DOWN: number;
DIRECTION_HORIZONTAL: number;
DIRECTION_VERTICAL: number;
DIRECTION_ALL: number;
Manager: HammerManagerConstructor;
Input: HammerInput;
TouchAction: TouchAction;
TouchInput: TouchInput;
MouseInput: MouseInput;
PointerEventInput: PointerEventInput;
TouchMouseInput: TouchMouseInput;
SingleTouchInput: SingleTouchInput;
Recognizer: RecognizerStatic;
AttrRecognizer: AttrRecognizerStatic;
Tap: TapRecognizerStatic;
Pan: PanRecognizerStatic;
Swipe: SwipeRecognizerStatic;
Pinch: PinchRecognizerStatic;
Rotate: RotateRecognizerStatic;
Press: PressRecognizerStatic;
on( target:EventTarget, types:string, handler:Function ):void;
off( target:EventTarget, types:string, handler:Function ):void;
each( obj:any, iterator:Function, context:any ): void;
merge( dest:any, src:any ): any;
extend( dest:any, src:any, merge:boolean ): any;
inherit( child:Function, base:Function, properties:any ):any;
bindFn( fn:Function, context:any ):Function;
prefixed( obj:any, property:string ):string;
}
interface HammerDefaults
{
domEvents:boolean;
enable:boolean;
preset:any[];
touchAction:string;
cssProps:CssProps;
inputClass():void;
inputTarget():void;
}
interface CssProps
{
contentZooming:string;
tapHighlightColor:string;
touchCallout:string;
touchSelect:string;
userDrag:string;
userSelect:string;
}
interface HammerOptions extends HammerDefaults
{
}
interface HammerManagerConstructor {
new( element:HTMLElement, options?:any ):HammerManager;
}
interface HammerManager
{
add( recogniser:Recognizer ):Recognizer;
add( recogniser:Recognizer ):HammerManager;
add( recogniser:Recognizer[] ):Recognizer;
add( recogniser:Recognizer[] ):HammerManager;
destroy():void;
emit( event:string, data:any ):void;
get( recogniser:Recognizer ):Recognizer;
get( recogniser:string ):Recognizer;
off( events:string, handler?:( event:HammerInput ) => void ):void;
on( events:string, handler:( event:HammerInput ) => void ):void;
recognize( inputData:any ):void;
remove( recogniser:Recognizer ):HammerManager;
remove( recogniser:string ):HammerManager;
set( options:HammerOptions ):HammerManager;
stop( force:boolean ):void;
}
declare class HammerInput
{
constructor( manager:HammerManager, callback:Function );
destroy():void;
handler():void;
init():void;
/** Name of the event. Like panstart. */
type:string;
/** Movement of the X axis. */
deltaX:number;
/** Movement of the Y axis. */
deltaY:number;
/** Total time in ms since the first input. */
deltaTime:number;
/** Distance moved. */
distance:number;
/** Angle moved. */
angle:number;
/** Velocity on the X axis, in px/ms. */
velocityX:number;
/** Velocity on the Y axis, in px/ms */
velocityY:number;
/** Highest velocityX/Y value. */
velocity:number;
/** Direction moved. Matches the DIRECTION constants. */
direction:number;
/** Direction moved from it's starting point. Matches the DIRECTION constants. */
offsetDirection:string;
/** Scaling that has been done when multi-touch. 1 on a single touch. */
scale:number;
/** Rotation that has been done when multi-touch. 0 on a single touch. */
rotation:number;
/** Center position for multi-touch, or just the single pointer. */
center:HammerPoint;
/** Source event object, type TouchEvent, MouseEvent or PointerEvent. */
srcEvent:TouchEvent | MouseEvent | PointerEvent;
/** Target that received the event. */
target:HTMLElement;
/** Primary pointer type, could be touch, mouse, pen or kinect. */
pointerType:string;
/** Event type, matches the INPUT constants. */
eventType:string;
/** true when the first input. */
isFirst:boolean;
/** true when the final (last) input. */
isFinal:boolean;
/** Array with all pointers, including the ended pointers (touchend, mouseup). */
pointers:any[];
/** Array with all new/moved/lost pointers. */
changedPointers:any[];
/** Reference to the srcEvent.preventDefault() method. Only for experts! */
preventDefault:Function;
}
declare class MouseInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class PointerEventInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class SingleTouchInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class TouchInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
declare class TouchMouseInput extends HammerInput
{
constructor( manager:HammerManager, callback:Function );
}
interface RecognizerStatic
{
new( options?:any ):Recognizer;
}
interface Recognizer
{
defaults:any;
canEmit():boolean;
canRecognizeWith( otherRecognizer:Recognizer ):boolean;
dropRecognizeWith( otherRecognizer:Recognizer ):Recognizer;
dropRecognizeWith( otherRecognizer:string ):Recognizer;
dropRequireFailure( otherRecognizer:Recognizer ):Recognizer;
dropRequireFailure( otherRecognizer:string ):Recognizer;
emit( input:HammerInput ):void;
getTouchAction():any[];
hasRequireFailures():boolean;
process( inputData:HammerInput ):string;
recognize( inputData:HammerInput ):void;
recognizeWith( otherRecognizer:Recognizer ):Recognizer;
recognizeWith( otherRecognizer:string ):Recognizer;
requireFailure( otherRecognizer:Recognizer ):Recognizer;
requireFailure( otherRecognizer:string ):Recognizer;
reset():void;
set( options?:any ):Recognizer;
tryEmit( input:HammerInput ):void;
}
interface AttrRecognizerStatic
{
attrTest( input:HammerInput ):boolean;
process( input:HammerInput ):any;
}
interface AttrRecognizer extends Recognizer
{
new( options?:any ):AttrRecognizer;
}
interface PanRecognizerStatic
{
new( options?:any ):PanRecognizer;
}
interface PanRecognizer extends AttrRecognizer
{
}
interface PinchRecognizerStatic
{
new( options?:any ):PinchRecognizer;
}
interface PinchRecognizer extends AttrRecognizer
{
}
interface PressRecognizerStatic
{
new( options?:any ):PressRecognizer;
}
interface PressRecognizer extends AttrRecognizer
{
}
interface RotateRecognizerStatic
{
new( options?:any ):RotateRecognizer;
}
interface RotateRecognizer extends AttrRecognizer
{
}
interface SwipeRecognizerStatic
{
new( options?:any ):SwipeRecognizer;
}
interface SwipeRecognizer extends AttrRecognizer
{
}
interface TapRecognizerStatic
{
new( options?:any ):TapRecognizer;
}
interface TapRecognizer extends AttrRecognizer
{
}
declare class TouchAction
{
constructor( manager:HammerManager, value:string );
compute():string;
preventDefaults( input:HammerInput ):void;
preventSrc( srcEvent:any ):void;
set( value:string ):void;
update():void;
}
interface HammerPoint
{
x: number;
y: number;
}