UNPKG

13.7 kBTypeScriptView Raw
1import * as React from 'react';
2
3import { SwiperOptions } from './types/swiper-options';
4import SwiperClass from './types/swiper-class';
5
6interface Swiper extends SwiperOptions {
7 /**
8 * Swiper container tag
9 *
10 * @default 'div'
11 */
12 tag?: string;
13
14 /**
15 * Swiper wrapper tag
16 *
17 * @default 'div'
18 */
19 wrapperTag?: string;
20
21 /**
22 * Get Swiper instance
23 */
24 onSwiper?: (swiper: SwiperClass) => void;
25
26
27 /**
28 * Fired right after Swiper initialization.
29 * @note Note that with `swiper.on('init')` syntax it will
30 * work only in case you set `init: false` parameter.
31 *
32 * @example
33 * ```js
34 * const swiper = new Swiper('.swiper-container', {
35 * init: false,
36 * // other parameters
37 * });
38 * swiper.on('init', function() {
39 * // do something
40 * });
41 * // init Swiper
42 * swiper.init();
43 * ```
44 *
45 * @example
46 * ```js
47 * // Otherwise use it as the parameter:
48 * const swiper = new Swiper('.swiper-container', {
49 * // other parameters
50 * on: {
51 * init: function () {
52 * // do something
53 * },
54 * }
55 * });
56 * ```
57 */
58 onInit?: (swiper: SwiperClass) => any;
59
60 /**
61 * Event will be fired right before Swiper destroyed
62 */
63 onBeforeDestroy?: (swiper: SwiperClass) => void;
64
65 /**
66 * Event will be fired when currently active slide is changed
67 */
68 onSlideChange?: (swiper: SwiperClass) => void;
69
70 /**
71 * Event will be fired in the beginning of animation to other slide (next or previous).
72 */
73 onSlideChangeTransitionStart?: (swiper: SwiperClass) => void;
74
75 /**
76 * Event will be fired after animation to other slide (next or previous).
77 */
78 onSlideChangeTransitionEnd?: (swiper: SwiperClass) => void;
79
80 /**
81 * Same as "slideChangeTransitionStart" but for "forward" direction only
82 */
83 onSlideNextTransitionStart?: (swiper: SwiperClass) => void;
84
85 /**
86 * Same as "slideChangeTransitionEnd" but for "forward" direction only
87 */
88 onSlideNextTransitionEnd?: (swiper: SwiperClass) => void;
89
90 /**
91 * Same as "slideChangeTransitionStart" but for "backward" direction only
92 */
93 onSlidePrevTransitionStart?: (swiper: SwiperClass) => void;
94
95 /**
96 * Same as "slideChangeTransitionEnd" but for "backward" direction only
97 */
98 onSlidePrevTransitionEnd?: (swiper: SwiperClass) => void;
99
100 /**
101 * Event will be fired in the beginning of transition.
102 */
103 onTransitionStart?: (swiper: SwiperClass) => void;
104
105 /**
106 * Event will be fired after transition.
107 */
108 onTransitionEnd?: (swiper: SwiperClass) => void;
109
110 /**
111 * Event will be fired when user touch Swiper. Receives `touchstart` event as an arguments.
112 */
113 onTouchStart?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
114
115 /**
116 * Event will be fired when user touch and move finger over Swiper. Receives `touchmove` event as an arguments.
117 */
118 onTouchMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
119
120 /**
121 * Event will be fired when user touch and move finger over Swiper in direction opposite to direction parameter. Receives `touchmove` event as an arguments.
122 */
123 onTouchMoveOpposite?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
124
125 /**
126 * Event will be fired when user touch and move finger over Swiper and move it. Receives `touchmove` event as an arguments.
127 */
128 onSliderMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
129
130 /**
131 * Event will be fired when user release Swiper. Receives `touchend` event as an arguments.
132 */
133 onTouchEnd?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
134
135 /**
136 * Event will be fired when user click/tap on Swiper. Receives `touchend` event as an arguments.
137 */
138 onClick?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
139
140 /**
141 * Event will be fired when user click/tap on Swiper. Receives `touchend` event as an arguments.
142 */
143 onTap?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
144
145 /**
146 * Event will be fired when user double tap on Swiper's container. Receives `touchend` event as an arguments
147 */
148 onDoubleTap?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
149
150 /**
151 * Event will be fired right after all inner images are loaded. updateOnImagesReady should be also enabled
152 */
153 onImagesReady?: (swiper: SwiperClass) => void;
154
155 /**
156 * Event will be fired when Swiper progress is changed, as an arguments it receives progress that is always from 0 to 1
157 */
158 onProgress?: (swiper: SwiperClass, progress: number) => void;
159
160 /**
161 * Event will be fired when Swiper reach its beginning (initial position)
162 */
163 onReachBeginning?: (swiper: SwiperClass) => void;
164
165 /**
166 * Event will be fired when Swiper reach last slide
167 */
168 onReachEnd?: (swiper: SwiperClass) => void;
169
170 /**
171 * Event will be fired when Swiper goes to beginning or end position
172 */
173 onToEdge?: (swiper: SwiperClass) => void;
174
175 /**
176 * Event will be fired when Swiper goes from beginning or end position
177 */
178 onFromEdge?: (swiper: SwiperClass) => void;
179
180 /**
181 * Event will be fired when swiper's wrapper change its position. Receives current translate value as an arguments
182 */
183 onSetTranslate?: (swiper: SwiperClass, translate: number) => void;
184
185 /**
186 * Event will be fired everytime when swiper starts animation. Receives current transition duration (in ms) as an arguments
187 */
188 onSetTransition?: (swiper: SwiperClass, transition: number) => void;
189
190 /**
191 * Event will be fired on window resize right before swiper's onresize manipulation
192 */
193 onResize?: (swiper: SwiperClass) => void;
194
195 /**
196 * Event will be fired if observer is enabled and it detects DOM mutations
197 */
198 onObserverUpdate?: (swiper: SwiperClass) => void;
199
200 /**
201 * Event will be fired right before "loop fix"
202 */
203 onBeforeLoopFix?: (swiper: SwiperClass) => void;
204
205 /**
206 * Event will be fired after "loop fix"
207 */
208 onLoopFix?: (swiper: SwiperClass) => void;
209
210 /**
211 * Event will be fired on breakpoint change
212 */
213 onBreakpoint?: (swiper: SwiperClass, breakpointParams: SwiperOptions) => void;
214
215 /**
216 * !INTERNAL: Event will fired right before breakpoint change
217 */
218 _beforeBreakpoint?: (swiper: SwiperClass, breakpointParams: SwiperOptions) => void;
219
220 /**
221 * !INTERNAL: Event will fired after setting CSS classes on swiper container element
222 */
223 _containerClasses?: (swiper: SwiperClass, classNames: string) => void;
224
225 /**
226 * !INTERNAL: Event will fired after setting CSS classes on swiper slide element
227 */
228 _slideClass?: (swiper: SwiperClass, slideEl: HTMLElement, classNames: string) => void;
229
230 /**
231 * !INTERNAL: Event will fired after setting CSS classes on all swiper slides
232 */
233 _slideClasses?: (
234 swiper: SwiperClass,
235 slides: { slideEl: HTMLElement; classNames: string; index: number }[],
236 ) => void;
237
238 /**
239 * !INTERNAL: Event will fired as soon as swiper instance available (before init)
240 */
241 _swiper?: (swiper: SwiperClass) => void;
242
243 /**
244 * !INTERNAL: Event will be fired on free mode touch end (release) and there will no be momentum
245 */
246 _freeModeNoMomentumRelease?: (swiper: SwiperClass) => void;
247
248 /**
249 * Event will fired on active index change
250 */
251 onActiveIndexChange?: (swiper: SwiperClass) => void;
252 /**
253 * Event will fired on snap index change
254 */
255 onSnapIndexChange?: (swiper: SwiperClass) => void;
256 /**
257 * Event will fired on real index change
258 */
259 onRealIndexChange?: (swiper: SwiperClass) => void;
260 /**
261 * Event will fired right after initialization
262 */
263 onAfterInit?: (swiper: SwiperClass) => void;
264 /**
265 * Event will fired right before initialization
266 */
267 onBeforeInit?: (swiper: SwiperClass) => void;
268 /**
269 * Event will fired before resize handler
270 */
271 onBeforeResize?: (swiper: SwiperClass) => void;
272 /**
273 * Event will fired before slide change transition start
274 */
275 onBeforeSlideChangeStart?: (swiper: SwiperClass) => void;
276 /**
277 * Event will fired before transition start
278 */
279 onBeforeTransitionStart?: (swiper: SwiperClass, speed: number, internal: any) => void; // what is internal?
280 /**
281 * Event will fired on direction change
282 */
283 onChangeDirection?: (swiper: SwiperClass) => void;
284 /**
285 * Event will be fired when user double click/tap on Swiper
286 */
287 onDoubleClick?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
288 /**
289 * Event will be fired on swiper destroy
290 */
291 onDestroy?: (swiper: SwiperClass) => void;
292 /**
293 * Event will be fired on momentum bounce
294 */
295 onMomentumBounce?: (swiper: SwiperClass) => void;
296 /**
297 * Event will be fired on orientation change (e.g. landscape -> portrait)
298 */
299 onOrientationchange?: (swiper: SwiperClass) => void;
300 /**
301 * Event will be fired in the beginning of animation of resetting slide to current one
302 */
303 onSlideResetTransitionStart?: (swiper: SwiperClass) => void;
304 /**
305 * Event will be fired in the end of animation of resetting slide to current one
306 */
307 onSlideResetTransitionEnd?: (swiper: SwiperClass) => void;
308 /**
309 * Event will be fired with first touch/drag move
310 */
311 onSliderFirstMove?: (swiper: SwiperClass, event: TouchEvent) => void;
312 /**
313 * Event will be fired when number of slides has changed
314 */
315 onSlidesLengthChange?: (swiper: SwiperClass) => void;
316 /**
317 * Event will be fired when slides grid has changed
318 */
319 onSlidesGridLengthChange?: (swiper: SwiperClass) => void;
320 /**
321 * Event will be fired when snap grid has changed
322 */
323 onSnapGridLengthChange?: (swiper: SwiperClass) => void;
324 /**
325 * Event will be fired after swiper.update() call
326 */
327 onUpdate?: (swiper: SwiperClass) => void;
328 /**
329 * Event will be fired when swiper is locked (when `watchOverflow` enabled)
330 */
331 onLock?: (swiper: SwiperClass) => void;
332 /**
333 * Event will be fired when swiper is unlocked (when `watchOverflow` enabled)
334 */
335 onUnlock?: (swiper: SwiperClass) => void;
336
337 /**
338 * Event will be fired in when autoplay started
339 */
340 onAutoplayStart?: (swiper: SwiperClass) => void;
341 /**
342 * Event will be fired when autoplay stopped
343 */
344 onAutoplayStop?: (swiper: SwiperClass) => void;
345 /**
346 * Event will be fired when slide changed with autoplay
347 */
348 onAutoplay?: (swiper: SwiperClass) => void;/**
349 * Event will be fired on window hash change
350 */
351 onHashChange?: (swiper: SwiperClass) => void;
352 /**
353 * Event will be fired when swiper updates the hash
354 */
355 onHashSet?: (swiper: SwiperClass) => void;/**
356 * Event will be fired on key press
357 */
358 onKeyPress?: (swiper: SwiperClass, keyCode: string) => void;/**
359 * Event will be fired in the beginning of lazy loading of image
360 */
361 onLazyImageLoad?: (swiper: SwiperClass, slideEl: HTMLElement, imageEl: HTMLElement) => void;
362 /**
363 * Event will be fired when lazy loading image will be loaded
364 */
365 onLazyImageReady?: (swiper: SwiperClass, slideEl: HTMLElement, imageEl: HTMLElement) => void;/**
366 * Event will be fired on mousewheel scroll
367 */
368 onScroll?: (swiper: SwiperClass, event: WheelEvent) => void;/**
369 * Event will be fired on navigation hide
370 */
371 onNavigationHide?: (swiper: SwiperClass) => void;
372 /**
373 * Event will be fired on navigation show
374 */
375 onNavigationShow?: (swiper: SwiperClass) => void;/**
376 * Event will be fired after pagination rendered
377 */
378 onPaginationRender?: (swiper: SwiperClass, paginationEl: HTMLElement) => void;
379
380 /**
381 * Event will be fired when pagination updated
382 */
383 onPaginationUpdate?: (swiper: SwiperClass, paginationEl: HTMLElement) => void;
384
385 /**
386 * Event will be fired on pagination hide
387 */
388 onPaginationHide?: (swiper: SwiperClass) => void;
389
390 /**
391 * Event will be fired on pagination show
392 */
393 onPaginationShow?: (swiper: SwiperClass) => void;/**
394 * Event will be fired on draggable scrollbar drag start
395 */
396 onScrollbarDragStart?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
397
398 /**
399 * Event will be fired on draggable scrollbar drag move
400 */
401 onScrollbarDragMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
402
403 /**
404 * Event will be fired on draggable scrollbar drag end
405 */
406 onScrollbarDragEnd?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;/**
407 * Event will be fired on zoom change
408 */
409 onZoomChange?: (swiper: SwiperClass, scale: number, imageEl: HTMLElement, slideEl: HTMLElement) => void;
410}
411
412interface SlideData {
413 isActive: boolean;
414 isVisible: boolean;
415 isDuplicate: boolean;
416 isPrev: boolean;
417 isNext: boolean;
418}
419
420interface SwiperSlide {
421 /**
422 * Slide tag
423 *
424 * @default 'div'
425 */
426 tag?: string;
427
428 /**
429 * Enables additional wrapper required for zoom mode
430 *
431 * @default false
432 */
433 zoom?: boolean;
434
435 /**
436 * Slide's index in slides array/collection
437 *
438 * @default false
439 */
440 virtualIndex?: number;
441
442 /**
443 * Slide's child element or render function
444 *
445 * @default undefined
446 */
447 children?: React.ReactNode | ((slideData: SlideData) => React.ReactNode);
448}
449
450interface Swiper
451 extends Omit<
452 React.HTMLAttributes<HTMLElement>,
453 | 'onProgress'
454 | 'onClick'
455 | 'onTouchEnd'
456 | 'onTouchMove'
457 | 'onTouchStart'
458 | 'onTransitionEnd'
459 | 'onKeyPress'
460 | 'onDoubleClick'
461 | 'onScroll'
462 > {}
463interface SwiperSlide extends React.HTMLAttributes<HTMLElement> {}
464
465declare const Swiper: React.FunctionComponent<Swiper>;
466declare const SwiperSlide: React.VoidFunctionComponent<SwiperSlide>;
467
468export { Swiper, SwiperSlide };
469
\No newline at end of file