forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slideout.d.ts
157 lines (132 loc) · 4.35 KB
/
slideout.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
// Type definitions for Slideout 0.1.12
// Project: https://github.com/mango/slideout
// Definitions by: Markus Peloso <https://github.com/ToastHawaii/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "slideout" {
export = Slideout;
}
declare namespace Slideout {
/**
* Options to customize a new instance of Slideout.
*/
interface Options {
/**
* The DOM element that contains all your application content (.slideout-panel).
*/
panel: HTMLElement;
/**
* The DOM element that contains your menu application (.slideout-menu).
*/
menu: HTMLElement;
/**
* The time (milliseconds) to open/close the slideout.
* Default: 300.
*/
duration?: number;
/**
* The CSS effect to use when animating the opening and closing of the slideout.
* Default: ease.
*/
fx?: string;
/**
* Default: 256.
*/
padding?: number;
/**
* The number of px needed for the menu can be opened completely, otherwise it closes.
* Default: 70.
*/
tolerance?: number;
/**
* Set this option to false to disable Slideout touch events.
* Default: true.
*/
touch?: boolean;
/**
* The side to open the slideout.
* Default: left.
*/
side?: "left" | "right";
}
type Events = "beforeopen" | "open" | "beforeclose" | "close" | "translatestart" | "translate" | "translateend";
}
/**
* A touch slideout navigation menu for your mobile web apps.
*/
declare class Slideout {
/**
* A touch slideout navigation menu for your mobile web apps.
* @param options Options to customize a new instance of Slideout.
*/
constructor(options: Slideout.Options);
/**
* Opens the slideout menu. It emits beforeopen and open events.
*/
open(): Slideout;
/**
* Closes the slideout menu. It emits beforeclose and close events.
*/
close(): Slideout;
/**
* Toggles (open/close) the slideout menu.
*/
toggle(): Slideout;
/**
* Returns true if the slideout is currently open, and false if it is closed.
*/
isOpen(): boolean;
/**
* Cleans up the instance so another slideout can be created on the same area.
*/
destroy(): Slideout;
/**
* Enables opening the slideout via touch events.
*/
enableTouch(): Slideout;
/**
* Disables opening the slideout via touch events.
*/
disableTouch(): Slideout;
/**
* Adds a listener to the collection for the specified event.
* @param event The event name.
* @param listener A listener function to add.
*/
on(event: "translate", listener: (translateX: number) => any): Slideout;
/**
* Adds a listener to the collection for the specified event.
* @param event The event name.
* @param listener A listener function to add.
*/
on(event: Slideout.Events, listener: Function): Slideout;
/**
* Adds a listener to the collection for the specified event that will be called only once.
* @param event The event name.
* @param listener A listener function to add.
*/
once(event: "translate", listener: (translateX: number) => any): Slideout;
/**
* Adds a listener to the collection for the specified event that will be called only once.
* @param event The event name.
* @param listener A listener function to add.
*/
once(event: Slideout.Events, listener: Function): Slideout;
/**
* Removes a listener from the collection for the specified event.
* @param event The event name.
* @param listener A listener function to remove.
*/
off(event: "translate", listener: (translateX: number) => any): Slideout;
/**
* Removes a listener from the collection for the specified event.
* @param event The event name.
* @param listener A listener function to remove.
*/
off(event: Slideout.Events, listener: Function): Slideout;
/**
* Execute each item in the listener collection in order with the specified data.
* @param event The name of the event you want to emit.
* @param data Data to pass to the listeners.
*/
emit(event: Slideout.Events, ...data: any[]): Slideout;
}