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