UNPKG

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