-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTactile.d.ts
427 lines (427 loc) · 15.4 KB
/
Tactile.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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
entries(): any;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
keys(): any;
set(key: K, value?: V): Map<K, V>;
size: number;
values(): any;
}
interface MapConstructor {
new (): Map<any, any>;
new <K, V>(): Map<K, V>;
prototype: Map<any, any>;
}
declare var Map: MapConstructor;
interface VelocityUtilities {
removeData(el: HTMLElement, keys: string[]): any;
}
interface Velocity {
(el: HTMLElement | HTMLElement[], properties: any, options?: any): void;
Utilities: VelocityUtilities;
}
declare var Velocity: Velocity;
declare module Tactile.Animation {
function set(els: HTMLElement | HTMLElement[], target: any, options?: AnimationOptions, complete?: () => void): void;
function stop(els: HTMLElement | HTMLElement[]): void;
function clear(els: HTMLElement | HTMLElement[]): void;
function animateDomMutation(el: HTMLElement, mutationFunction: Function, options: any, complete?: () => void): void;
function animateDomMutationLayoutSize(el: HTMLElement, mutationFunction: Function, options: any): void;
}
declare module Tactile.Attributes {
function get(el: Element, attrName: string, defaultIfPresent?: string, defaultIfNotPresent?: string): string;
function getTags(el: Element, attrName: string, defaultIfPresent?: string[], defaultIfNotPresent?: string[]): string[];
}
declare module Tactile.Dom {
function matches(el: HTMLElement, selector: string): boolean;
function indexOf(el: HTMLElement): number;
function isChild(el: HTMLElement, childEl: Element): boolean;
function isDescendant(el: HTMLElement, descendantEl: HTMLElement): boolean;
function closest(el: HTMLElement, selector: string): HTMLElement;
function parents(el: HTMLElement, selector?: string): HTMLElement[];
function ancestors(el: HTMLElement, selector: string): HTMLElement[];
function copyComputedStyles(sourceEl: HTMLElement, targetEl: HTMLElement): void;
function stripClasses(el: HTMLElement): void;
function getContentBoxClientRect(el: Element): {
top: number;
left: number;
right: number;
bottom: number;
width: number;
height: number;
};
function children(el: HTMLElement, selector?: string): HTMLElement[];
function clientScale(el: HTMLElement): [number, number];
function outerHeight(el: HTMLElement, includeMargins?: boolean): number;
function outerWidth(el: HTMLElement, includeMargins?: boolean): number;
function translate(el: HTMLElement, xy: [number, number]): void;
function transform(el: HTMLElement, options: any): void;
function topLeft(el: HTMLElement, xy: [number, number]): void;
function transformOrigin(el: HTMLElement, xy: [number, number]): void;
function elementFromPoint(xy: [number, number]): HTMLElement;
function elementFromPointViaSelection(xy: [number, number]): HTMLElement;
function clearSelection(): void;
function scrollDirections(el: Element): any;
function canScrollDown(el: Element): boolean;
function canScrollUp(el: Element): boolean;
function canScrollRight(el: Element): boolean;
function canScrollLeft(el: Element): boolean;
}
declare module Tactile.Events {
var pointerDownEvent: string;
var pointerMoveEvent: string;
var pointerUpEvent: string;
function cancel(e: Event): void;
function raise(source: Element, eventName: string, eventData: any): CustomEvent;
interface NormalizedPointerEvent {
id: number;
target: HTMLElement;
xy: [number, number];
xyEl: HTMLElement;
}
function normalizePointerEvent(e: MouseEvent | TouchEvent): NormalizedPointerEvent[];
}
declare module Tactile.Maths {
function coerce(value: number, min: number, max: number): number;
function scale(value: number, domain: [number, number], range: [number, number]): number;
}
declare module Tactile.Geometry {
function rectContains(rect: ClientRect, xy: [number, number]): boolean;
}
declare module Tactile.Polyfill {
function requestAnimationFrame(callback: FrameRequestCallback): number;
function cancelAnimationFrame(handle: number): void;
function addClass(el: HTMLElement, className: string): void;
function removeClass(el: HTMLElement, className: string): void;
function remove(el: HTMLElement): void;
}
declare module Tactile.Text {
function toProperCase(text: string): string;
}
declare module Tactile.Vector {
function add(a: [number, number], b: [number, number]): [number, number];
function subtract(a: [number, number], b: [number, number]): [number, number];
function multiply(a: [number, number], b: [number, number]): [number, number];
function multiplyScalar(a: [number, number], s: number): [number, number];
function divide(a: [number, number], b: [number, number]): [number, number];
function divideScalar(v: [number, number], s: number): [number, number];
function lengthSquared(v: [number, number]): number;
function length(v: [number, number]): number;
function equals(a: [number, number], b: [number, number]): boolean;
}
declare module Tactile {
class Container {
el: HTMLElement;
drag: Drag;
static closest(el: HTMLElement): HTMLElement;
static closestAcceptingTarget(el: HTMLElement, draggable: Draggable): Container;
static buildContainer(el: HTMLElement, drag: Drag): Container;
placeholder: Placeholder;
helperSize: [number, number];
helperScale: [number, number];
accepts: string[];
leaveAction: DragAction;
enterAction: DragAction;
isSource: boolean;
constructor(el: HTMLElement, drag: Drag);
willAccept(draggable: Draggable): boolean;
enter(xy: [number, number]): void;
move(xy: [number, number]): void;
leave(): void;
finalizePosition(el: HTMLElement): void;
dispose(): void;
}
}
declare module Tactile {
interface AnimationOptions {
duration?: number;
easing?: string | number[];
}
interface Options {
cancel?: string;
helperResize?: boolean;
helperCloneStyles?: boolean;
animation?: boolean;
revertBehaviour?: string;
pickUpAnimation?: AnimationOptions;
pickDownAnimation?: AnimationOptions;
resizeAnimation?: AnimationOptions;
dropAnimation?: AnimationOptions;
reorderAnimation?: AnimationOptions;
deleteAnimation?: AnimationOptions;
containerResizeAnimation?: AnimationOptions;
pickUpDelay?: number;
pickUpDistance?: number;
helperRotation?: number;
helperShadowSize?: number;
placeholderClass?: string;
avoidDomMutations?: boolean;
scrollAutoDetect?: boolean;
scrollSensitivity?: string | number;
scrollSpeed?: number;
}
var defaults: Options;
}
declare module Tactile {
class Cache {
private _id;
private _els;
private _cache;
constructor();
get(el: HTMLElement, key: string, fn?: Function): any;
set(el: HTMLElement, key: string, value: any): void;
clear(): void;
dispose(): void;
getElements(): HTMLElement[];
forEach(key: string, fn: (value: any, el?: HTMLElement) => void): void;
private _getElementCache(el);
}
}
declare module Tactile {
class Canvas extends Container {
offset: [number, number];
grid: [number, number];
domain: [number, number];
constructor(el: HTMLElement, drag: Drag);
enter(xy: [number, number]): void;
move(xy: [number, number]): void;
leave(): void;
finalizePosition(el: HTMLElement): void;
dispose(): void;
private _insertPlaceholder();
}
}
declare module Tactile {
class Drag {
xy: [number, number];
options: Options;
xyEl: HTMLElement;
draggable: Draggable;
helper: Helper;
source: Container;
target: Container;
boundary: Boundary;
action: DragAction;
geometryCache: Cache;
containerCache: Cache;
private _xyChanged;
private _hasScrolled;
private _scroller;
private _lastXyEl;
private _afRequestId;
private _onScrollOrWheelListener;
private _dragEnded;
constructor(draggableEl: HTMLElement, xy: [number, number], xyEl: HTMLElement, options: Options);
move(xy: [number, number], xyEl: HTMLElement): void;
cancel(debugElements?: boolean): void;
drop(): void;
dispose(): void;
private _bindScrollEvents();
private _unbindScrollEvents();
private _onScrollOrWheel();
private _scheduleTick();
private _cancelTick();
private _tick();
private _updateTarget();
private _tryEnterTarget(container);
private _tryLeaveTarget(container);
private _finalizeAction();
private _computeAction(source, target);
private _setAction(action);
private _raise(el, eventName);
}
}
declare module Tactile {
enum DragAction {
Copy = 0,
Move = 1,
Delete = 2,
Revert = 3,
Cancel = 4,
}
}
declare module Tactile {
class Draggable {
el: HTMLElement;
drag: Drag;
static closest(el: HTMLElement): HTMLElement;
static closestEnabled(el: HTMLElement): HTMLElement;
data: any;
draggableId: string;
tags: string[];
originalParentEl: HTMLElement;
originalIndex: number;
originalSize: [number, number];
originalScale: [number, number];
originalStyle: string;
originalOffset: [number, number];
private _mutObserver;
constructor(el: HTMLElement, drag: Drag);
private _captureOriginalPosition();
private _initializeMutationListener();
private _onDomMutation(e);
private _disposeMutationListener();
private _updateDraggableElement();
dispose(): void;
finalizeMove(target: Container): void;
finalizeCopy(target: Container): void;
finalizeDelete(): void;
finalizeRevert(): void;
}
}
declare module Tactile {
class DragManager {
options: Options;
private _drags;
private _pendingDrags;
private _onPointerDownListener;
private _onPointerMoveListener;
private _onPointerUpListener;
private _onKeyDownListener;
private _onClickListener;
constructor(options?: Options);
set(options: Options): void;
destroy(): void;
private _bindEvents();
private _unbindEvents();
private _bindDragPendingEvents();
private _unbindDragPendingEvents();
private _bindDraggingEvents();
private _unbindDraggingEvents();
private _bindDraggingEventsForTarget(el);
private _unbindDraggingEventsForTarget(el);
private _onClick(e);
private _onPointerDown(e);
private _onPointerMove(e);
private _onPointerUp(e);
private _onKeyDown(e);
private _scheduleDrag(draggableEl, dragId, xy);
private _startScheduledDrag(dragId);
private _cancelScheduledDrag(dragId);
private _startDrag(draggableEl, dragId, xy, xyEl);
private _endDrag(dragId, cancel?, abort?);
}
}
declare module Tactile {
class Droppable extends Container {
constructor(el: HTMLElement, drag: Drag);
enter(xy: [number, number]): void;
move(xy: [number, number]): void;
leave(): void;
finalizePosition(el: HTMLElement): void;
}
}
declare module Tactile {
class Boundary {
el: HTMLElement;
drag: Drag;
static closestForDraggable(drag: Drag, draggable: Draggable): Boundary;
tags: string[];
constructor(el: HTMLElement, drag: Drag);
constrains(tags: string[]): boolean;
getConstrainedXY(xy: [number, number]): [number, number];
}
}
declare module Tactile {
class Helper {
drag: Drag;
el: HTMLElement;
xy: [number, number];
gripXY: [number, number];
gripRelative: [number, number];
gripOffset: [number, number];
size: [number, number];
scale: [number, number];
constructor(drag: Drag, draggable: Draggable);
private _initialize(draggable);
setAction(action: DragAction): void;
setPosition(xy: [number, number]): void;
setSizeAndScale(size: [number, number], scale: [number, number], animate?: boolean): void;
animateToElementAndPutDown(el: HTMLElement, complete?: () => void): void;
animateDelete(complete?: () => void): void;
dispose(): void;
private _pickUp();
}
}
declare module Tactile {
class Placeholder {
el: HTMLElement;
drag: Drag;
size: [number, number];
scale: [number, number];
outerSize: [number, number];
isOriginalEl: boolean;
state: string;
_originalStyles: CSSStyleDeclaration;
static buildPlaceholder(containerEl: HTMLElement, drag: Drag): Placeholder;
constructor(el: HTMLElement, drag: Drag, isOriginalEl?: boolean);
private _updateDimensions();
setState(state: string, animate?: boolean): void;
dispose(): void;
}
}
declare module Tactile {
enum Direction {
Neither = 0,
Horizontal = 1,
Vertical = 2,
Both = 3,
}
class Scrollable {
el: HTMLElement;
drag: Drag;
private static _overflowScrollValues;
private static _detectScrollableDirection(el);
private static _getScrollableDirection(drag, el);
static closestScrollableScrollable(drag: Drag, xy: [number, number], xyEl: HTMLElement): any;
private _bounds;
private _offset;
private _velocity;
private _direction;
private _sensitivity;
private _lastUpdate;
constructor(el: HTMLElement, drag: Drag);
canScroll(xy: [number, number]): boolean;
continueScroll(xy: [number, number]): boolean;
private _updateVelocity(xy);
}
}
declare module Tactile {
class Sortable extends Container {
private index;
private _direction;
private _directionProperties;
private _childEls;
private _siblingEls;
private _childGeometry;
private _style;
private _avoidDomMutations;
private _mutObserver;
private _entered;
constructor(el: HTMLElement, drag: Drag);
enter(viewportXY: [number, number]): void;
move(xy: [number, number]): void;
leave(): void;
finalizePosition(el: HTMLElement): void;
dispose(): void;
private _initializeMutationListener();
private _onDomMutation(e);
private _updateIndex(viewportXY);
private _updateIndexViaOffset(viewportXY);
private _updateIndexViaSelectionApi(viewportXY);
private _initializeDirection();
private _initializePlaceholder();
private _initializeChildAndSiblingEls();
private _setPlaceholderIndex(newIndex);
private _updatePlaceholderPosition(animate?, complete?);
private _getChildGeometry(el);
private _updatePlaceholderIndex(complete?);
private _updateChildTranslations(animate?, complete?);
_resizeToExcludePlaceholder(): void;
_resizeToIncludePlaceholder(): void;
private _clearChildTranslations();
}
}