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