UNPKG

12.9 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 * !INTERNAL: Event will fired after setting CSS classes on swiper container element
221 */
222 _containerClasses?: (swiper: SwiperClass, classNames: string) => void;
223 /**
224 * INTERNAL: Event will fired after setting CSS classes on swiper slide element
225 */
226 _slideClass?: (swiper: SwiperClass, el: HTMLElement, classNames: string) => void;
227
228 /**
229 * INTERNAL: Event will fired after setting CSS classes on all swiper slides
230 */
231 _slideClasses?: (
232 swiper: SwiperClass,
233 slides: { el: HTMLElement; classNames: string; index: number }[],
234 ) => void;
235
236 /**
237 * INTERNAL: Event will fired as soon as swiper instance available (before init)
238 */
239 _swiper?: (swiper: SwiperClass) => void;
240 /**
241 * Event will fired on active index change
242 */
243 onActiveIndexChange?: (swiper: SwiperClass) => void;
244 /**
245 * Event will fired on snap index change
246 */
247 onSnapIndexChange?: (swiper: SwiperClass) => void;
248 /**
249 * Event will fired on real index change
250 */
251 onRealIndexChange?: (swiper: SwiperClass) => void;
252 /**
253 * Event will fired right after initialization
254 */
255 onAfterInit?: (swiper: SwiperClass) => void;
256 /**
257 * Event will fired right before initialization
258 */
259 onBeforeInit?: (swiper: SwiperClass) => void;
260 /**
261 * Event will fired before resize handler
262 */
263 onBeforeResize?: (swiper: SwiperClass) => void;
264 /**
265 * Event will fired before slide change transition start
266 */
267 onBeforeSlideChangeStart?: (swiper: SwiperClass) => void;
268 /**
269 * Event will fired before transition start
270 */
271 onBeforeTransitionStart?: (swiper: SwiperClass, speed: number, internal: any) => void; // what is internal?
272 /**
273 * Event will fired on direction change
274 */
275 onChangeDirection?: (swiper: SwiperClass) => void;
276 /**
277 * Event will be fired when user double click/tap on Swiper
278 */
279 onDoubleClick?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
280 /**
281 * Event will be fired on swiper destroy
282 */
283 onDestroy?: (swiper: SwiperClass) => void;
284 /**
285 * Event will be fired on momentum bounce
286 */
287 onMomentumBounce?: (swiper: SwiperClass) => void;
288 /**
289 * Event will be fired on orientation change (e.g. landscape -> portrait)
290 */
291 onOrientationchange?: (swiper: SwiperClass) => void;
292 /**
293 * Event will be fired in the beginning of animation of resetting slide to current one
294 */
295 onSlideResetTransitionStart?: (swiper: SwiperClass) => void;
296 /**
297 * Event will be fired in the end of animation of resetting slide to current one
298 */
299 onSlideResetTransitionEnd?: (swiper: SwiperClass) => void;
300 /**
301 * Event will be fired with first touch/drag move
302 */
303 onSliderFirstMove?: (swiper: SwiperClass, event: TouchEvent) => void;
304 /**
305 * Event will be fired when number of slides has changed
306 */
307 onSlidesLengthChange?: (swiper: SwiperClass) => void;
308 /**
309 * Event will be fired when slides grid has changed
310 */
311 onSlidesGridLengthChange?: (swiper: SwiperClass) => void;
312 /**
313 * Event will be fired when snap grid has changed
314 */
315 onSnapGridLengthChange?: (swiper: SwiperClass) => void;
316 /**
317 * Event will be fired after swiper.update() call
318 */
319 onUpdate?: (swiper: SwiperClass) => void;
320
321 /**
322 * Event will be fired in when autoplay started
323 */
324 onAutoplayStart?: (swiper: SwiperClass) => void;
325 /**
326 * Event will be fired when autoplay stopped
327 */
328 onAutoplayStop?: (swiper: SwiperClass) => void;
329 /**
330 * Event will be fired when slide changed with autoplay
331 */
332 onAutoplay?: (swiper: SwiperClass) => void;/**
333 * Event will be fired on window hash change
334 */
335 onHashChange?: (swiper: SwiperClass) => void;
336 /**
337 * Event will be fired when swiper updates the hash
338 */
339 onHashSet?: (swiper: SwiperClass) => void;/**
340 * Event will be fired on key press
341 */
342 onKeyPress?: (swiper: SwiperClass, keyCode: string) => void;/**
343 * Event will be fired in the beginning of lazy loading of image
344 */
345 onLazyImageLoad?: (swiper: SwiperClass, slideEl: HTMLElement, imageEl: HTMLElement) => void;
346 /**
347 * Event will be fired when lazy loading image will be loaded
348 */
349 onLazyImageReady?: (swiper: SwiperClass, slideEl: HTMLElement, imageEl: HTMLElement) => void;/**
350 * Event will be fired on mousewheel scroll
351 */
352 onScroll?: (swiper: SwiperClass, event: WheelEvent) => void;/**
353 * Event will be fired on navigation hide
354 */
355 onNavigationHide?: (swiper: SwiperClass) => void;
356 /**
357 * Event will be fired on navigation show
358 */
359 onNavigationShow?: (swiper: SwiperClass) => void;/**
360 * Event will be fired after pagination rendered
361 */
362 onPaginationRender?: (swiper: SwiperClass, paginationEl: HTMLElement) => void;
363
364 /**
365 * Event will be fired when pagination updated
366 */
367 onPaginationUpdate?: (swiper: SwiperClass, paginationEl: HTMLElement) => void;
368
369 /**
370 * Event will be fired on pagination hide
371 */
372 onPaginationHide?: (swiper: SwiperClass) => void;
373
374 /**
375 * Event will be fired on pagination show
376 */
377 onPaginationShow?: (swiper: SwiperClass) => void;/**
378 * Event will be fired on draggable scrollbar drag start
379 */
380 onScrollbarDragStart?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
381
382 /**
383 * Event will be fired on draggable scrollbar drag move
384 */
385 onScrollbarDragMove?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;
386
387 /**
388 * Event will be fired on draggable scrollbar drag end
389 */
390 onScrollbarDragEnd?: (swiper: SwiperClass, event: MouseEvent | TouchEvent | PointerEvent) => void;/**
391 * Event will be fired on zoom change
392 */
393 onZoomChange?: (swiper: SwiperClass, scale: number, imageEl: HTMLElement, slideEl: HTMLElement) => void;
394}
395
396interface SwiperSlide {
397 /**
398 * Slide tag
399 *
400 * @default 'div'
401 */
402 tag?: string;
403
404 /**
405 * Enables additional wrapper required for zoom mode
406 *
407 * @default false
408 */
409 zoom?: boolean;
410
411 /**
412 * Slide's index in slides array/collection
413 *
414 * @default false
415 */
416 virtualIndex?: number;
417}
418
419interface Swiper
420 extends Omit<
421 React.HTMLAttributes<HTMLElement>,
422 | 'onProgress'
423 | 'onClick'
424 | 'onTouchEnd'
425 | 'onTouchMove'
426 | 'onTouchStart'
427 | 'onTransitionEnd'
428 | 'onKeyPress'
429 | 'onDoubleClick'
430 | 'onScroll'
431 > {}
432interface SwiperSlide extends React.HTMLAttributes<HTMLElement> {}
433
434declare const Swiper: React.FunctionComponent<Swiper>;
435declare const SwiperSlide: React.FunctionComponent<SwiperSlide>;
436
437export { Swiper, SwiperSlide };