forked from rcbyr/keen-slider
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vue.es.d.ts
298 lines (256 loc) · 6.71 KB
/
vue.es.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
import { Ref } from 'vue'
export declare interface AnimatorInstance {
active: boolean
start: (
keyframes: {
distance: number
duration: number
earlyExit?: number
easing: (t: number) => number
}[]
) => void
stop: () => void
targetIdx: number | null
}
export declare type Container =
| string
| HTMLElement
| NodeList
| ((
wrapper: HTMLElement | Document
) => HTMLElement[] | NodeList | HTMLCollection | null)
export declare type DRAG_ANIMATION_MODE_FREE = 'free'
export declare type DRAG_ANIMATION_MODE_FREE_SNAP = 'free-snap'
export declare type DRAG_ANIMATION_MODE_SNAP = 'snap'
export declare interface DragAnimationOptions<M> {
mode?: M
rubberband?: boolean
}
export declare interface DragOptions {
drag?: boolean
dragSpeed?: number | ((val: number) => number)
rubberband?: boolean
}
export declare type HOOK_ANIMATION_ENDED = 'animationEnded'
export declare type HOOK_ANIMATION_STARTED = 'animationStarted'
export declare type HOOK_ANIMATION_STOPPED = 'animationStopped'
export declare type HOOK_BEFORE_OPTIONS_CHANGED = 'beforeOptionsChanged'
export declare type HOOK_CREATED = 'created'
export declare type HOOK_DESTROYED = 'destroyed'
export declare type HOOK_DETAILS_CHANGED = 'detailsChanged'
export declare type HOOK_DRAG_CHECKED = 'dragChecked'
export declare type HOOK_DRAG_ENDED = 'dragEnded'
export declare type HOOK_DRAG_STARTED = 'dragStarted'
export declare type HOOK_DRAGGED = 'dragged'
export declare type HOOK_OPTIONS_CHANGED = 'optionsChanged'
export declare type HOOK_SLIDE_CHANGED = 'slideChanged'
export declare type HOOK_UPDATED = 'updated'
export declare type KeenSliderHooks =
| SliderHooks
| HOOK_OPTIONS_CHANGED
| HOOK_UPDATED
| HOOK_DRAGGED
| HOOK_DRAG_ENDED
| HOOK_DRAG_STARTED
| HOOK_DRAG_CHECKED
| HOOK_DESTROYED
| HOOK_BEFORE_OPTIONS_CHANGED
export declare type KeenSliderInstance<
O = {},
P = {},
H extends string = KeenSliderHooks
> = SliderInstance<
KeenSliderOptions<O, P, H>,
WebInstance<KeenSliderOptions<O, P, H>> & P,
KeenSliderHooks | H
>
export declare type KeenSliderOptions<
O = {},
P = {},
H extends string = KeenSliderHooks
> = SliderOptions<
WebOptions<KeenSliderOptions<O, P, H>> &
DragOptions &
RendererOptions &
DragAnimationOptions<
| DRAG_ANIMATION_MODE_SNAP
| DRAG_ANIMATION_MODE_FREE
| DRAG_ANIMATION_MODE_FREE_SNAP
>
> & {
[key in Exclude<
H | KeenSliderHooks,
keyof SliderOptions<WebOptions<{}>> &
DragOptions &
RendererOptions &
DragAnimationOptions<
| DRAG_ANIMATION_MODE_SNAP
| DRAG_ANIMATION_MODE_FREE
| DRAG_ANIMATION_MODE_FREE_SNAP
>
>]?: (slider: KeenSliderInstance<O, P, H>) => void
} & Omit<
O,
keyof SliderOptions<WebOptions<{}>> &
DragOptions &
RendererOptions &
DragAnimationOptions<
| DRAG_ANIMATION_MODE_SNAP
| DRAG_ANIMATION_MODE_FREE
| DRAG_ANIMATION_MODE_FREE_SNAP
>
>
export declare type KeenSliderPlugin<
O = {},
P = {},
H extends string = KeenSliderHooks
> = SliderPlugin<
KeenSliderOptions<O, P, H>,
KeenSliderInstance<O, P, H>,
KeenSliderHooks | H
>
export declare type RENDER_MODE_CUSTOM = 'custom'
export declare type RENDER_MODE_PERFORMANCE = 'performance'
export declare type RENDER_MODE_PRECISION = 'precision'
export declare interface RendererOptions {
renderMode?:
| RENDER_MODE_PRECISION
| RENDER_MODE_PERFORMANCE
| RENDER_MODE_CUSTOM
}
export declare type SliderHookOptions<H extends string, I> = {
[key in H]?: (slider: I) => void
}
export declare type SliderHooks =
| HOOK_CREATED
| HOOK_ANIMATION_ENDED
| HOOK_ANIMATION_STARTED
| HOOK_ANIMATION_STOPPED
| HOOK_SLIDE_CHANGED
| HOOK_DETAILS_CHANGED
export declare type SliderInstance<
O = {},
C = {},
H extends string = string
> = {
animator: AnimatorInstance
emit: (name: H | SliderHooks) => void
moveToIdx: (
idx: number,
absolute?: boolean,
animation?: {
duration?: number
easing?: (t: number) => number
}
) => void
on: (
name: H | SliderHooks,
cb: (props: SliderInstance<O, C, H>) => void,
remove?: boolean
) => void
options: SliderOptions<O>
track: TrackInstance
} & C
export declare type SliderOptions<O = {}> = {
defaultAnimation?: {
duration?: number
easing?: (t: number) => number
}
initial?: number
loop?:
| boolean
| {
min?: number
max?: number
}
range?: {
align?: boolean
min?: number
max?: number
}
rtl?: boolean
trackConfig?: TrackSlidesConfigOption
} & O
export declare type SliderPlugin<O = {}, C = {}, H extends string = string> = (
slider: SliderInstance<O, C, H>
) => void
export declare type TrackDetails = {
abs: number
length: number
max: number
maxIdx: number
min: number
minIdx: number
position: number
rel: number
progress: number
slides: {
abs: number
distance: number
portion: number
size: number
}[]
slidesLength: number
}
export declare interface TrackInstance {
absToRel: (absoluteIdx: number) => number
add: (value: number) => void
details: TrackDetails
distToIdx: (distance: number) => number
idxToDist: (idx: number, absolute?: boolean, fromPosition?: number) => number
init: (idx?: number) => void
to: (value: number) => void
velocity: () => number
}
export declare type TrackSlidesConfigEntry = {
origin?: Number
size?: Number
spacing?: Number
} | null
export declare type TrackSlidesConfigOption = TrackSlidesConfigEntry[]
export declare function useKeenSlider<
T extends HTMLElement,
O = {},
P = {},
H extends string = KeenSliderHooks
>(
options: Ref<KeenSliderOptions<O, P, H>> | KeenSliderOptions<O, P, H>,
plugins?: KeenSliderPlugin<O, P, H>[]
): [Ref<T | undefined>, Ref<KeenSliderInstance<O, P, H> | undefined>]
export declare interface WebInstance<O> {
container: HTMLElement
destroy: () => void
next: () => void
prev: () => void
slides: HTMLElement[]
size: number
update: (options?: O, idx?: number) => void
}
export declare interface WebOptions<O> {
disabled?: boolean
selector?:
| string
| HTMLElement[]
| NodeList
| HTMLCollection
| ((
container: HTMLElement
) => HTMLElement[] | NodeList | HTMLCollection | null)
| null
slides?:
| ((size: number, slides: HTMLElement[]) => TrackSlidesConfigOption)
| number
| {
origin?: 'center' | 'auto' | number
number?: number | (() => number | null) | null
perView?: 'auto' | number | (() => number | 'auto')
spacing?: number | (() => number)
numberOfFullWidthShow?: number
}
| null
vertical?: boolean
breakpoints?: {
[key: string]: Omit<O, 'breakpoints'>
}
}
export {}