forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interact.d.ts
247 lines (224 loc) · 7.89 KB
/
interact.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
// Type definitions for Interacting for interact.js v1.0.25
// Project: https://github.com/taye/interact.js
// Definitions by: Douglas Eichelberger <https://github.com/dduugg>, Adi Dahiya <https://github.com/adidahiya>, Tom Hasner <https://github.com/thasner>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// API documentation: http://interactjs.io/docs
declare module Interact {
interface Interactable {
// returns Element or string
accept(): any;
accept(newValue: Element): Interactable;
accept(newValue: string): Interactable;
actionChecker(): Function;
actionChecker(checker: Function): Interactable;
// returns boolean or {[key: string]: any}
autoScroll(): any;
autoScroll(options: boolean): Interactable;
autoScroll(options: {[key: string]: any}): Interactable;
context(): Node;
defaultActionChecker(event: any): string;
deltaSource(): string;
// returns Interactable if newValue is "page" or "client", otherwise returns string
deltaSource(newValue: String): Interactable;
draggable(): boolean;
draggable(options: boolean): Interactable;
draggable(options: {[key: string]: any}): Interactable;
dropCheck(event: MouseEvent): boolean;
dropCheck(event: TouchEvent): boolean;
dropChecker(): Function;
dropChecker(checker: Function): Interactable;
// returns boolean or {[key: string]: any}
dropzone(): any;
dropzone(options: boolean): Interactable;
dropzone(options: {[key: string]: any}): Interactable;
// return HTMLElement or SVGElement
element(): Element;
fire(iEvent: InteractEvent): Interactable;
// returns boolean or {[key: string]: any}
gesturable(): any;
gesturable(options: boolean): Interactable;
gesturable(options: {[key: string]: any}): Interactable;
getRect(): ClientRect;
// returns Element or string
ignoreFrom(): any;
ignoreFrom(newValue: string): Interactable;
ignoreFrom(newValue: Element): Interactable;
// returns boolean or {[key: string]: any}
inertia(): any;
inertia(options: boolean): Interactable;
inertia(options: {[key: string]: any}): Interactable;
off(eventType: string, listener: Function, useCapture?: boolean): Interactable;
on(eventType: string, listener: Function, useCapture?: boolean): Interactable;
origin(): Point;
origin(newValue: HTMLElement): Interactable;
origin(newValue: SVGElement): Interactable;
origin(newValue: Point): Interactable;
preventDefault(newValue: boolean | string): Interactable;
rectChecker(): Function;
rectChecker(newValue: Function): Interactable;
resizable(): Interactable;
resizable(options: boolean): Interactable;
resizable(options: {[key: string]: any}): Interactable;
restrict(): Restrict;
restrict(newValue: Restrict): Interactable;
set(options: {[key: string]: any}): Interactable;
// returns boolean or {[key: string]: any}
snap(): any;
snap(options: boolean): Interactable;
snap(options: {[key: string]: any}): Interactable;
squareResize(): boolean;
squareResize(newValue: boolean): Interactable;
styleCursor(): boolean;
styleCursor(newValue: boolean): Interactable;
unset(): InteractStatic;
validateSetting(context: string, option: string, value: any): any;
}
interface Coordinates {
clientX: number;
clientY: number;
pageX: number;
pageY: number;
timeStamp: number;
}
interface Debug {
target: any;
dragging: any;
resizing: any;
gesturing: any;
prepared: any;
prevCoords: Coordinates;
downCoords: Coordinates;
pointerIds: any[];
pointerMoves: any[];
addPointer: any;
removePointer: any;
recordPointers: any;
inertia: InertiaStatus;
downTime: any;
downEvent: any;
prevEvent: any;
Interactable: any;
IOptions: any;
interactables: any;
dropzones: any;
pointerIsDown: any;
defaultOptions: any;
defaultActionChecker: any;
actions: any;
dragMove: any;
resizeMove: any;
gestureMove: any;
pointerUp: any;
pointerDown: any;
pointerMove: any;
pointerHover: any;
events: any;
globalEvents: any;
delegatedEvents: any;
}
interface InertiaStatus {
active: boolean;
target: any;
targetElement: any;
startEvent: any;
pointerUp: any
xe: number;
ye: number;
duration: number;
t0: number;
vx0: number;
vys: number;
lambda_v0: number;
one_ve_v0: number;
i: any;
}
interface Point {
x: number;
y: number;
}
// value types are either ClientRect or Element
interface Restrict {
drag?: any;
gesture?: any;
resize?: any;
elementRect?: {[direction: string]: number};
}
interface InteractEvent {
altKey: boolean;
axes: string;
button: number
clientX0: number;
clientX: number
clientY0: number;
clientY: number
ctrlKey: boolean
dt: number;
duration: number;
dx: number;
dy: number;
metaKey: boolean;
pageX: number;
pageY: number;
shiftKey: boolean;
speed: number;
t0: number;
target: any;
timeStamp: number;
type: string;
velocityX: number;
velocityY: number;
x0: number;
y0: number;
}
interface TouchEvent {
pageX: number;
pageY: number;
type: string;
}
interface InteractStatic {
(element: HTMLElement): Interactable;
(element: SVGElement): Interactable;
(element: string): Interactable;
// returns boolean or {[key: string]: any}
autoScroll(): any;
autoScroll(options: boolean): InteractStatic;
autoScroll(options: {[key: string]: any}): InteractStatic;
currentAction(): string
debug(): Debug;
deltaSource(): string;
// "page" and "client" are the valid parameters
deltaSource(newValue: string): InteractStatic;
dynamicDrop(): boolean;
dynamicDrop(newValue: boolean): InteractStatic;
enableDragging(): boolean;
enableDragging(newValue: boolean): InteractStatic;
enableGesturing(): boolean;
enableGesturing(newValue: boolean): InteractStatic;
enableResizing(): boolean;
enableResizing(newValue: boolean): InteractStatic;
// returns boolean or {[key: string]: any}
inertia(): any;
inertia(options: boolean): InteractStatic;
inertia(options: {[key: string]: any}): InteractStatic;
isSet(element: Element): boolean;
margin(): number;
margin(newvalue: number): InteractStatic;
off(type: string, listener: Function, useCapture?: boolean): InteractStatic;
on(type: string, listener: Function, useCapture?: boolean): InteractStatic;
restrict(): Restrict;
restrict(newValue: Restrict): InteractStatic;
simulate(action: string, element: Element, pointerEvent?: any): InteractStatic;
// returns boolean or {[key: string]: any}
snap(): any;
snap(options: boolean): InteractStatic;
snap(options: {[key: string]: any}): InteractStatic;
stop(event: Event): InteractStatic;
styleCursor(): boolean;
styleCursor(newValue: boolean): InteractStatic;
supportsTouch(): boolean
}
}
declare var interact: Interact.InteractStatic;
declare module "interact" {
export = interact;
}