-
Notifications
You must be signed in to change notification settings - Fork 8
/
fingers.d.ts
178 lines (141 loc) · 4.77 KB
/
fingers.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
declare namespace Fingers {
export class Position {
constructor(
pTimestamp: number,
pX: number,
pY: number,
)
public timestamp: number;
public x: number;
public y: number;
public set(pTimestamp: number, pX: number, pY: number): void;
public copy(pPosition: Position): void;
}
export class Finger {
constructor(
pId: number,
pTimestamp: number,
pX: number,
pY: number
);
public id: number;
public timestamp: number;
public startP: Position;
public previousP: Position;
public currentP: Position;
public nbListeningInstances: number;
/*---- time ----*/
public getTime(): number;
public getDeltaTime(): number;
public getTotalTime(): number;
public getInactivityTime(): number;
/*---- position ----*/
public getX(): number;
public getY(): number;
/*---- distance ----*/
public getDeltaX(): number;
public getDeltaY(): number;
public getDeltaDistance(): number;
public getTotalX(): number;
public getTotalY(): number;
public getDistance(): number;
/*---- direction ----*/
public getDeltaDirection(): number;
public getDirection(): number;
/*---- velocity ----*/
public getVelocityX(): number;
public getVelocityY(): number;
public getVelocity(): number;
public getVelocityAverage(): number;
public getOrientedVelocityX(): number;
public getOrientedVelocityY(): number;
}
export class Gesture {
constructor(
pOptions?: Fingers.gesture.GestureOptions,
pDefaults?: Fingers.gesture.GestureOptions
);
protected isListening: boolean;
protected fire<T>(event: keyof Gesture['EVENT_TYPE'], data: T): void;
protected _addListenedFinger(pNewFinger: Finger): void;
protected _onFingerAdded(pNewFinger: Finger, pFingerList: Finger[]): void;
protected _onFingerUpdate(pFinger: Finger): void;
protected _onFingerRemoved(pFinger: Finger): void;
public addHandler<T>(
handler: (
eventType: keyof Gesture['EVENT_TYPE'],
data: T,
fingerList: Finger[]
) => void
): Gesture;
public EVENT_TYPE : {
instant: "instant",
start: "start",
end: "end",
move: "move"
};
}
export class Instance {
constructor(pElement: HTMLElement);
public addGesture(
gesture: typeof Gesture,
options?: Fingers.gesture.GestureOptions
): Gesture;
}
export namespace gesture {
export interface HoldOptions {
nbFingers: number;
distanceThreshold: number;
duration: number;
}
export interface TapOptions {
nbFingers: number;
tapInterval: number;
}
export interface SwipeOptions {
nbFingers: number;
swipeVelocityX: number;
swipeVelocityY: number;
}
export interface PinchOptions {
pinchInDetect: number;
pinchOutDetect: number;
}
export interface TransformOptions {
rotation: boolean;
scale: boolean;
}
export interface RawOptions {
nbMaxFingers: number;
}
export type GestureOptions =
HoldOptions |
TapOptions |
SwipeOptions |
PinchOptions |
TransformOptions |
RawOptions;
export class Raw extends Gesture {
constructor(pOptions: RawOptions)
}
export class Swipe extends Gesture {
constructor(pOptions: SwipeOptions)
}
export class Tap extends Gesture {
constructor(pOptions: TapOptions)
}
export class Pinch extends Gesture {
constructor(pOptions: PinchOptions)
}
export class Transform extends Gesture {
constructor(pOptions: TransformOptions, pHandler: Function)
}
export class Hold extends Gesture {
constructor(pOptions: HoldOptions)
}
export class Drag extends Gesture {}
export class Rotate extends Gesture {}
export class Scale extends Gesture {}
export class ZoneHover extends Gesture {}
}
}