PluginProbe ʕ •ᴥ•ʔ
Jetpack – WP Security, Backup, Speed, & Growth / 12.9.5
Jetpack – WP Security, Backup, Speed, & Growth v12.9.5
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 14.5.1 14.6.1 14.7.1 14.8.1 14.9.2 15.0.3 15.1.2 15.2.1 15.3.2 15.4.1 15.5.1 15.6.1 15.7.2 15.8.1 15.9.2 16.0.2 16.1.3 16.2-a.5 16.2-a.3 16.1.2 16.2-a.1 16.1.1 16.1 16.1-beta 16.1-beta.2 16.1-beta.3 16.1-a.5 16.1-a.3 16.0.1 16.1-a.1 16.0 16.0-beta 16.0-a.7 16.0-a.5 15.9.1 16.0-a.3 16.0-a.1 15.9 15.9-beta 15.9-a.7 15.9-a.5 15.9-a.3 15.9-a.1 15.8 15.8-beta 15.8-a.7 15.8-a.5 5.2.5 5.3.4 5.4.4 5.5.5 5.6.5 5.7.5 5.8.4 5.9.4 6.0.4 6.1 6.1.1 6.1.2 6.1.3 6.1.4 6.1.5 6.2 6.2.1 6.2.2 6.2.3 6.2.4 6.2.5 6.3 6.3.1 6.3.2 6.3.3 6.3.4 6.3.5 6.3.6 6.3.7 6.4 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.5 6.5.1 6.5.2 6.5.3 6.5.4 6.6 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.7 6.7.1 6.7.2 6.7.3 6.7.4 6.8 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.9 6.9.1 6.9.2 6.9.3 6.9.4 7.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.1 7.1.1 7.1.2 7.1.3 7.1.4 7.1.5 7.2 7.2.1 7.2.1.1 7.2.2 7.2.3 7.2.4 7.2.5 7.3 7.3.0.1 7.3.1 7.3.1.1 7.3.2 7.3.3 7.3.4 7.3.5 7.4 7.4.1 7.4.2 7.4.3 7.4.4 7.4.5 7.5 7.5.0.1 7.5.1 7.5.2 7.5.3 7.5.4 7.5.5 7.5.6 7.5.7 7.6 7.6.1 7.6.2 7.6.3 7.6.4 7.7 7.7.1 7.7.2 7.7.3 7.7.4 7.7.5 7.7.6 7.8 7.8.1 7.8.2 7.8.3 7.8.4 7.9 7.9.1 7.9.2 7.9.3 7.9.4 8.0 8.0.1 8.0.2 8.0.3 8.1 8.1.1 8.1.2 8.1.3 8.1.4 8.2 8.2.0.1 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.2.6 8.3 8.3.1 8.3.2 8.3.3 8.4 8.4.1 8.4.2 8.4.3 8.4.4 8.4.5 8.5 8.5.1 8.5.2 8.5.3 8.6 8.6.1 8.6.2 8.6.3 8.6.4 8.7 8.7.0.1 8.7.1 8.7.2 8.7.3 8.7.4 8.8 8.8.1 8.8.2 8.8.3 8.8.4 8.8.5 8.9 8.9.1 8.9.2 8.9.3 8.9.4 9.0 9.0.1 9.0.2 9.0.3 9.0.4 9.0.5 9.1 9.1.1 9.1.2 9.1.3 9.2 9.2.1 9.2.2 9.2.3 9.2.4 9.3 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.4 9.4.1 9.4.2 9.4.3 9.4.4 9.5 9.5.1 9.5.2 9.5.3 9.5.4 9.5.5 9.6 9.6.1 9.6.2 9.6.3 9.6.4 9.7 9.7.1 9.7.2 15.7-beta.2 9.7.3 15.7.1 9.8 15.8-a.1 9.8.1 15.8-a.3 9.8.2 2.0.9 9.8.3 2.1.7 9.9 2.2.10 9.9.1 2.3.10 9.9.2 2.4.7 9.9.3 2.5.5 2.6.6 2.7.5 2.8.5 2.9.6 3.0.6 3.1.5 3.2.5 3.3.6 3.4.6 3.5.6 3.6.4 3.7.5 3.8.5 3.9.10 4.0.7 4.1.4 4.2.5 4.3.5 4.4.5 4.5.3 4.6.3 4.7.4 4.8.5 4.9.3 5.0.3 5.1.4 trunk 10.0 10.0.1 10.0.2 10.1 10.1.1 10.1.2 10.2 10.2.1 10.2.2 10.2.3 10.3 10.3.1 10.3.2 10.4 10.4.1 10.4.2 10.5 10.5.1 10.5.2 10.5.3 10.6 10.6.1 10.6.2 10.7 10.7.1 10.7.2 10.8 10.8.1 10.8.2 10.9 10.9.1 10.9.2 10.9.3 11.0 11.0.1 11.0.2 11.1 11.1.1 11.1.2 11.1.3 11.1.4 11.2 11.2.1 11.2.2 11.3 11.3.1 11.3.2 11.3.3 11.3.4 11.4 11.4.1 11.4.2 11.5 11.5.1 11.5.2 11.5.3 11.6 11.6.1 11.6.2 11.7 11.7.1 11.7.2 11.7.3 11.8 11.8.3 11.8.4 11.8.5 11.8.6 11.9 11.9.1 11.9.2 11.9.3 12.0 12.0.1 12.0.2 12.1 12.1.1 12.1.2 12.2 12.2.1 12.2.2 12.3 12.3.1 12.4 12.4.1 12.5 12.5.1 12.6 12.6.1 12.6.2 12.6.3 12.7 12.7.1 12.7.2 12.8 12.8.1 12.8.2 12.9 12.9.1 12.9.2 12.9.3 12.9.4 13.0 13.0.1 13.1 13.1.1 13.1.2 13.1.3 13.1.4 13.2 13.2.1 13.2.2 13.2.3 13.3 13.3.1 13.3.2 13.4 13.4.1 13.4.2 13.4.3 13.4.4 13.5 13.5.1 13.6 13.6.1 13.7 13.7.1 13.8 13.8.1 13.8.2 13.9 13.9.1 14.0 14.1 14.2 14.2.1 14.3 14.4 14.4.1 14.5 14.6 14.7 14.8 14.9 14.9.1 15.0 15.0.1 15.0.2 15.1 15.1.1 15.2 15.3 15.3.1 15.4 15.5 15.6 15.7 15.7-a.1 15.7-a.3 15.7-a.5 15.7-a.7 15.7-beta
jetpack / modules / carousel / swiper-bundle.js
jetpack / modules / carousel Last commit date
jetpack-carousel-rtl.css 3 years ago jetpack-carousel.css 3 years ago jetpack-carousel.js 2 years ago jetpack-carousel.php 2 years ago readme.md 5 years ago swiper-bundle.css 5 years ago swiper-bundle.js 4 years ago
swiper-bundle.js
7818 lines
1 /* eslint-disable */
2 /* If a new version is imported from swiper the global.Swiper definition at around line
3 * 25 should be changed to global.SwiperVersionNo., eg. global.Swiper670, and the corresponding
4 * references in jetpack-carousel.js updated to match new version number. This is to prevent
5 * clashes with 3rd party plugin/themes usage of swiper
6 */
7 /*!
8 * Swiper 6.7.0
9 * Most modern mobile touch slider and framework with hardware accelerated transitions
10 * https://swiperjs.com
11 *
12 * Copyright 2014-2021 Vladimir Kharlampidi
13 *
14 * Released under the MIT License
15 *
16 * Released on: June 22, 2021
17 */
18
19 ( function ( global, factory ) {
20 typeof exports === 'object' && typeof module !== 'undefined'
21 ? ( module.exports = factory() )
22 : typeof define === 'function' && define.amd
23 ? define( factory )
24 : ( ( global = typeof globalThis !== 'undefined' ? globalThis : global || self ),
25 ( global.Swiper670 = factory() ) );
26 } )( this, function () {
27 'use strict';
28
29 function _defineProperties( target, props ) {
30 for ( var i = 0; i < props.length; i++ ) {
31 var descriptor = props[ i ];
32 descriptor.enumerable = descriptor.enumerable || false;
33 descriptor.configurable = true;
34 if ( 'value' in descriptor ) descriptor.writable = true;
35 Object.defineProperty( target, descriptor.key, descriptor );
36 }
37 }
38
39 function _createClass( Constructor, protoProps, staticProps ) {
40 if ( protoProps ) _defineProperties( Constructor.prototype, protoProps );
41 if ( staticProps ) _defineProperties( Constructor, staticProps );
42 return Constructor;
43 }
44
45 function _extends() {
46 _extends =
47 Object.assign ||
48 function ( target ) {
49 for ( var i = 1; i < arguments.length; i++ ) {
50 var source = arguments[ i ];
51
52 for ( var key in source ) {
53 if ( Object.prototype.hasOwnProperty.call( source, key ) ) {
54 target[ key ] = source[ key ];
55 }
56 }
57 }
58
59 return target;
60 };
61
62 return _extends.apply( this, arguments );
63 }
64
65 /*!
66 * SSR Window 3.0.0
67 * Better handling for window object in SSR environment
68 * https://github.com/nolimits4web/ssr-window
69 *
70 * Copyright 2020, Vladimir Kharlampidi
71 *
72 * Licensed under MIT
73 *
74 * Released on: November 9, 2020
75 */
76
77 /* eslint-disable no-param-reassign */
78 function isObject$1( obj ) {
79 return (
80 obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object
81 );
82 }
83
84 function extend$1( target, src ) {
85 if ( target === void 0 ) {
86 target = {};
87 }
88
89 if ( src === void 0 ) {
90 src = {};
91 }
92
93 Object.keys( src ).forEach( function ( key ) {
94 if ( typeof target[ key ] === 'undefined' ) target[ key ] = src[ key ];
95 else if (
96 isObject$1( src[ key ] ) &&
97 isObject$1( target[ key ] ) &&
98 Object.keys( src[ key ] ).length > 0
99 ) {
100 extend$1( target[ key ], src[ key ] );
101 }
102 } );
103 }
104
105 var ssrDocument = {
106 body: {},
107 addEventListener: function addEventListener() {},
108 removeEventListener: function removeEventListener() {},
109 activeElement: {
110 blur: function blur() {},
111 nodeName: '',
112 },
113 querySelector: function querySelector() {
114 return null;
115 },
116 querySelectorAll: function querySelectorAll() {
117 return [];
118 },
119 getElementById: function getElementById() {
120 return null;
121 },
122 createEvent: function createEvent() {
123 return {
124 initEvent: function initEvent() {},
125 };
126 },
127 createElement: function createElement() {
128 return {
129 children: [],
130 childNodes: [],
131 style: {},
132 setAttribute: function setAttribute() {},
133 getElementsByTagName: function getElementsByTagName() {
134 return [];
135 },
136 };
137 },
138 createElementNS: function createElementNS() {
139 return {};
140 },
141 importNode: function importNode() {
142 return null;
143 },
144 location: {
145 hash: '',
146 host: '',
147 hostname: '',
148 href: '',
149 origin: '',
150 pathname: '',
151 protocol: '',
152 search: '',
153 },
154 };
155
156 function getDocument() {
157 var doc = typeof document !== 'undefined' ? document : {};
158 extend$1( doc, ssrDocument );
159 return doc;
160 }
161
162 var ssrWindow = {
163 document: ssrDocument,
164 navigator: {
165 userAgent: '',
166 },
167 location: {
168 hash: '',
169 host: '',
170 hostname: '',
171 href: '',
172 origin: '',
173 pathname: '',
174 protocol: '',
175 search: '',
176 },
177 history: {
178 replaceState: function replaceState() {},
179 pushState: function pushState() {},
180 go: function go() {},
181 back: function back() {},
182 },
183 CustomEvent: function CustomEvent() {
184 return this;
185 },
186 addEventListener: function addEventListener() {},
187 removeEventListener: function removeEventListener() {},
188 getComputedStyle: function getComputedStyle() {
189 return {
190 getPropertyValue: function getPropertyValue() {
191 return '';
192 },
193 };
194 },
195 Image: function Image() {},
196 Date: function Date() {},
197 screen: {},
198 setTimeout: function setTimeout() {},
199 clearTimeout: function clearTimeout() {},
200 matchMedia: function matchMedia() {
201 return {};
202 },
203 requestAnimationFrame: function requestAnimationFrame( callback ) {
204 if ( typeof setTimeout === 'undefined' ) {
205 callback();
206 return null;
207 }
208
209 return setTimeout( callback, 0 );
210 },
211 cancelAnimationFrame: function cancelAnimationFrame( id ) {
212 if ( typeof setTimeout === 'undefined' ) {
213 return;
214 }
215
216 clearTimeout( id );
217 },
218 };
219
220 function getWindow() {
221 var win = typeof window !== 'undefined' ? window : {};
222 extend$1( win, ssrWindow );
223 return win;
224 }
225
226 /*!
227 * Dom7 3.0.0
228 * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
229 * https://framework7.io/docs/dom7.html
230 *
231 * Copyright 2020, Vladimir Kharlampidi
232 *
233 * Licensed under MIT
234 *
235 * Released on: November 9, 2020
236 */
237
238 function _inheritsLoose( subClass, superClass ) {
239 subClass.prototype = Object.create( superClass.prototype );
240 subClass.prototype.constructor = subClass;
241 subClass.__proto__ = superClass;
242 }
243
244 function _getPrototypeOf( o ) {
245 _getPrototypeOf = Object.setPrototypeOf
246 ? Object.getPrototypeOf
247 : function _getPrototypeOf( o ) {
248 return o.__proto__ || Object.getPrototypeOf( o );
249 };
250 return _getPrototypeOf( o );
251 }
252
253 function _setPrototypeOf( o, p ) {
254 _setPrototypeOf =
255 Object.setPrototypeOf ||
256 function _setPrototypeOf( o, p ) {
257 o.__proto__ = p;
258 return o;
259 };
260
261 return _setPrototypeOf( o, p );
262 }
263
264 function _isNativeReflectConstruct() {
265 if ( typeof Reflect === 'undefined' || ! Reflect.construct ) return false;
266 if ( Reflect.construct.sham ) return false;
267 if ( typeof Proxy === 'function' ) return true;
268
269 try {
270 Date.prototype.toString.call( Reflect.construct( Date, [], function () {} ) );
271 return true;
272 } catch ( e ) {
273 return false;
274 }
275 }
276
277 function _construct( Parent, args, Class ) {
278 if ( _isNativeReflectConstruct() ) {
279 _construct = Reflect.construct;
280 } else {
281 _construct = function _construct( Parent, args, Class ) {
282 var a = [ null ];
283 a.push.apply( a, args );
284 var Constructor = Function.bind.apply( Parent, a );
285 var instance = new Constructor();
286 if ( Class ) _setPrototypeOf( instance, Class.prototype );
287 return instance;
288 };
289 }
290
291 return _construct.apply( null, arguments );
292 }
293
294 function _isNativeFunction( fn ) {
295 return Function.toString.call( fn ).indexOf( '[native code]' ) !== -1;
296 }
297
298 function _wrapNativeSuper( Class ) {
299 var _cache = typeof Map === 'function' ? new Map() : undefined;
300
301 _wrapNativeSuper = function _wrapNativeSuper( Class ) {
302 if ( Class === null || ! _isNativeFunction( Class ) ) return Class;
303
304 if ( typeof Class !== 'function' ) {
305 throw new TypeError( 'Super expression must either be null or a function' );
306 }
307
308 if ( typeof _cache !== 'undefined' ) {
309 if ( _cache.has( Class ) ) return _cache.get( Class );
310
311 _cache.set( Class, Wrapper );
312 }
313
314 function Wrapper() {
315 return _construct( Class, arguments, _getPrototypeOf( this ).constructor );
316 }
317
318 Wrapper.prototype = Object.create( Class.prototype, {
319 constructor: {
320 value: Wrapper,
321 enumerable: false,
322 writable: true,
323 configurable: true,
324 },
325 } );
326 return _setPrototypeOf( Wrapper, Class );
327 };
328
329 return _wrapNativeSuper( Class );
330 }
331
332 function _assertThisInitialized( self ) {
333 if ( self === void 0 ) {
334 throw new ReferenceError( "this hasn't been initialised - super() hasn't been called" );
335 }
336
337 return self;
338 }
339 /* eslint-disable no-proto */
340
341 function makeReactive( obj ) {
342 var proto = obj.__proto__;
343 Object.defineProperty( obj, '__proto__', {
344 get: function get() {
345 return proto;
346 },
347 set: function set( value ) {
348 proto.__proto__ = value;
349 },
350 } );
351 }
352
353 var Dom7 = /*#__PURE__*/ ( function ( _Array ) {
354 _inheritsLoose( Dom7, _Array );
355
356 function Dom7( items ) {
357 var _this;
358
359 _this = _Array.call.apply( _Array, [ this ].concat( items ) ) || this;
360 makeReactive( _assertThisInitialized( _this ) );
361 return _this;
362 }
363
364 return Dom7;
365 } )( /*#__PURE__*/ _wrapNativeSuper( Array ) );
366
367 function arrayFlat( arr ) {
368 if ( arr === void 0 ) {
369 arr = [];
370 }
371
372 var res = [];
373 arr.forEach( function ( el ) {
374 if ( Array.isArray( el ) ) {
375 res.push.apply( res, arrayFlat( el ) );
376 } else {
377 res.push( el );
378 }
379 } );
380 return res;
381 }
382
383 function arrayFilter( arr, callback ) {
384 return Array.prototype.filter.call( arr, callback );
385 }
386
387 function arrayUnique( arr ) {
388 var uniqueArray = [];
389
390 for ( var i = 0; i < arr.length; i += 1 ) {
391 if ( uniqueArray.indexOf( arr[ i ] ) === -1 ) uniqueArray.push( arr[ i ] );
392 }
393
394 return uniqueArray;
395 }
396
397 function qsa( selector, context ) {
398 if ( typeof selector !== 'string' ) {
399 return [ selector ];
400 }
401
402 var a = [];
403 var res = context.querySelectorAll( selector );
404
405 for ( var i = 0; i < res.length; i += 1 ) {
406 a.push( res[ i ] );
407 }
408
409 return a;
410 }
411
412 function $( selector, context ) {
413 var window = getWindow();
414 var document = getDocument();
415 var arr = [];
416
417 if ( ! context && selector instanceof Dom7 ) {
418 return selector;
419 }
420
421 if ( ! selector ) {
422 return new Dom7( arr );
423 }
424
425 if ( typeof selector === 'string' ) {
426 var html = selector.trim();
427
428 if ( html.indexOf( '<' ) >= 0 && html.indexOf( '>' ) >= 0 ) {
429 var toCreate = 'div';
430 if ( html.indexOf( '<li' ) === 0 ) toCreate = 'ul';
431 if ( html.indexOf( '<tr' ) === 0 ) toCreate = 'tbody';
432 if ( html.indexOf( '<td' ) === 0 || html.indexOf( '<th' ) === 0 ) toCreate = 'tr';
433 if ( html.indexOf( '<tbody' ) === 0 ) toCreate = 'table';
434 if ( html.indexOf( '<option' ) === 0 ) toCreate = 'select';
435 var tempParent = document.createElement( toCreate );
436 tempParent.innerHTML = html;
437
438 for ( var i = 0; i < tempParent.childNodes.length; i += 1 ) {
439 arr.push( tempParent.childNodes[ i ] );
440 }
441 } else {
442 arr = qsa( selector.trim(), context || document );
443 } // arr = qsa(selector, document);
444 } else if ( selector.nodeType || selector === window || selector === document ) {
445 arr.push( selector );
446 } else if ( Array.isArray( selector ) ) {
447 if ( selector instanceof Dom7 ) return selector;
448 arr = selector;
449 }
450
451 return new Dom7( arrayUnique( arr ) );
452 }
453
454 $.fn = Dom7.prototype;
455
456 function addClass() {
457 for (
458 var _len = arguments.length, classes = new Array( _len ), _key = 0;
459 _key < _len;
460 _key++
461 ) {
462 classes[ _key ] = arguments[ _key ];
463 }
464
465 var classNames = arrayFlat(
466 classes.map( function ( c ) {
467 return c.split( ' ' );
468 } )
469 );
470 this.forEach( function ( el ) {
471 var _el$classList;
472
473 ( _el$classList = el.classList ).add.apply( _el$classList, classNames );
474 } );
475 return this;
476 }
477
478 function removeClass() {
479 for (
480 var _len2 = arguments.length, classes = new Array( _len2 ), _key2 = 0;
481 _key2 < _len2;
482 _key2++
483 ) {
484 classes[ _key2 ] = arguments[ _key2 ];
485 }
486
487 var classNames = arrayFlat(
488 classes.map( function ( c ) {
489 return c.split( ' ' );
490 } )
491 );
492 this.forEach( function ( el ) {
493 var _el$classList2;
494
495 ( _el$classList2 = el.classList ).remove.apply( _el$classList2, classNames );
496 } );
497 return this;
498 }
499
500 function toggleClass() {
501 for (
502 var _len3 = arguments.length, classes = new Array( _len3 ), _key3 = 0;
503 _key3 < _len3;
504 _key3++
505 ) {
506 classes[ _key3 ] = arguments[ _key3 ];
507 }
508
509 var classNames = arrayFlat(
510 classes.map( function ( c ) {
511 return c.split( ' ' );
512 } )
513 );
514 this.forEach( function ( el ) {
515 classNames.forEach( function ( className ) {
516 el.classList.toggle( className );
517 } );
518 } );
519 }
520
521 function hasClass() {
522 for (
523 var _len4 = arguments.length, classes = new Array( _len4 ), _key4 = 0;
524 _key4 < _len4;
525 _key4++
526 ) {
527 classes[ _key4 ] = arguments[ _key4 ];
528 }
529
530 var classNames = arrayFlat(
531 classes.map( function ( c ) {
532 return c.split( ' ' );
533 } )
534 );
535 return (
536 arrayFilter( this, function ( el ) {
537 return (
538 classNames.filter( function ( className ) {
539 return el.classList.contains( className );
540 } ).length > 0
541 );
542 } ).length > 0
543 );
544 }
545
546 function attr( attrs, value ) {
547 if ( arguments.length === 1 && typeof attrs === 'string' ) {
548 // Get attr
549 if ( this[ 0 ] ) return this[ 0 ].getAttribute( attrs );
550 return undefined;
551 } // Set attrs
552
553 for ( var i = 0; i < this.length; i += 1 ) {
554 if ( arguments.length === 2 ) {
555 // String
556 this[ i ].setAttribute( attrs, value );
557 } else {
558 // Object
559 for ( var attrName in attrs ) {
560 this[ i ][ attrName ] = attrs[ attrName ];
561 this[ i ].setAttribute( attrName, attrs[ attrName ] );
562 }
563 }
564 }
565
566 return this;
567 }
568
569 function removeAttr( attr ) {
570 for ( var i = 0; i < this.length; i += 1 ) {
571 this[ i ].removeAttribute( attr );
572 }
573
574 return this;
575 }
576
577 function transform( transform ) {
578 for ( var i = 0; i < this.length; i += 1 ) {
579 this[ i ].style.transform = transform;
580 }
581
582 return this;
583 }
584
585 function transition$1( duration ) {
586 for ( var i = 0; i < this.length; i += 1 ) {
587 this[ i ].style.transitionDuration =
588 typeof duration !== 'string' ? duration + 'ms' : duration;
589 }
590
591 return this;
592 }
593
594 function on() {
595 for (
596 var _len5 = arguments.length, args = new Array( _len5 ), _key5 = 0;
597 _key5 < _len5;
598 _key5++
599 ) {
600 args[ _key5 ] = arguments[ _key5 ];
601 }
602
603 var eventType = args[ 0 ],
604 targetSelector = args[ 1 ],
605 listener = args[ 2 ],
606 capture = args[ 3 ];
607
608 if ( typeof args[ 1 ] === 'function' ) {
609 eventType = args[ 0 ];
610 listener = args[ 1 ];
611 capture = args[ 2 ];
612 targetSelector = undefined;
613 }
614
615 if ( ! capture ) capture = false;
616
617 function handleLiveEvent( e ) {
618 var target = e.target;
619 if ( ! target ) return;
620 var eventData = e.target.dom7EventData || [];
621
622 if ( eventData.indexOf( e ) < 0 ) {
623 eventData.unshift( e );
624 }
625
626 if ( $( target ).is( targetSelector ) ) listener.apply( target, eventData );
627 else {
628 var _parents = $( target ).parents(); // eslint-disable-line
629
630 for ( var k = 0; k < _parents.length; k += 1 ) {
631 if ( $( _parents[ k ] ).is( targetSelector ) ) listener.apply( _parents[ k ], eventData );
632 }
633 }
634 }
635
636 function handleEvent( e ) {
637 var eventData = e && e.target ? e.target.dom7EventData || [] : [];
638
639 if ( eventData.indexOf( e ) < 0 ) {
640 eventData.unshift( e );
641 }
642
643 listener.apply( this, eventData );
644 }
645
646 var events = eventType.split( ' ' );
647 var j;
648
649 for ( var i = 0; i < this.length; i += 1 ) {
650 var el = this[ i ];
651
652 if ( ! targetSelector ) {
653 for ( j = 0; j < events.length; j += 1 ) {
654 var event = events[ j ];
655 if ( ! el.dom7Listeners ) el.dom7Listeners = {};
656 if ( ! el.dom7Listeners[ event ] ) el.dom7Listeners[ event ] = [];
657 el.dom7Listeners[ event ].push( {
658 listener: listener,
659 proxyListener: handleEvent,
660 } );
661 el.addEventListener( event, handleEvent, capture );
662 }
663 } else {
664 // Live events
665 for ( j = 0; j < events.length; j += 1 ) {
666 var _event = events[ j ];
667 if ( ! el.dom7LiveListeners ) el.dom7LiveListeners = {};
668 if ( ! el.dom7LiveListeners[ _event ] ) el.dom7LiveListeners[ _event ] = [];
669
670 el.dom7LiveListeners[ _event ].push( {
671 listener: listener,
672 proxyListener: handleLiveEvent,
673 } );
674
675 el.addEventListener( _event, handleLiveEvent, capture );
676 }
677 }
678 }
679
680 return this;
681 }
682
683 function off() {
684 for (
685 var _len6 = arguments.length, args = new Array( _len6 ), _key6 = 0;
686 _key6 < _len6;
687 _key6++
688 ) {
689 args[ _key6 ] = arguments[ _key6 ];
690 }
691
692 var eventType = args[ 0 ],
693 targetSelector = args[ 1 ],
694 listener = args[ 2 ],
695 capture = args[ 3 ];
696
697 if ( typeof args[ 1 ] === 'function' ) {
698 eventType = args[ 0 ];
699 listener = args[ 1 ];
700 capture = args[ 2 ];
701 targetSelector = undefined;
702 }
703
704 if ( ! capture ) capture = false;
705 var events = eventType.split( ' ' );
706
707 for ( var i = 0; i < events.length; i += 1 ) {
708 var event = events[ i ];
709
710 for ( var j = 0; j < this.length; j += 1 ) {
711 var el = this[ j ];
712 var handlers = void 0;
713
714 if ( ! targetSelector && el.dom7Listeners ) {
715 handlers = el.dom7Listeners[ event ];
716 } else if ( targetSelector && el.dom7LiveListeners ) {
717 handlers = el.dom7LiveListeners[ event ];
718 }
719
720 if ( handlers && handlers.length ) {
721 for ( var k = handlers.length - 1; k >= 0; k -= 1 ) {
722 var handler = handlers[ k ];
723
724 if ( listener && handler.listener === listener ) {
725 el.removeEventListener( event, handler.proxyListener, capture );
726 handlers.splice( k, 1 );
727 } else if (
728 listener &&
729 handler.listener &&
730 handler.listener.dom7proxy &&
731 handler.listener.dom7proxy === listener
732 ) {
733 el.removeEventListener( event, handler.proxyListener, capture );
734 handlers.splice( k, 1 );
735 } else if ( ! listener ) {
736 el.removeEventListener( event, handler.proxyListener, capture );
737 handlers.splice( k, 1 );
738 }
739 }
740 }
741 }
742 }
743
744 return this;
745 }
746
747 function trigger() {
748 var window = getWindow();
749
750 for (
751 var _len9 = arguments.length, args = new Array( _len9 ), _key9 = 0;
752 _key9 < _len9;
753 _key9++
754 ) {
755 args[ _key9 ] = arguments[ _key9 ];
756 }
757
758 var events = args[ 0 ].split( ' ' );
759 var eventData = args[ 1 ];
760
761 for ( var i = 0; i < events.length; i += 1 ) {
762 var event = events[ i ];
763
764 for ( var j = 0; j < this.length; j += 1 ) {
765 var el = this[ j ];
766
767 if ( window.CustomEvent ) {
768 var evt = new window.CustomEvent( event, {
769 detail: eventData,
770 bubbles: true,
771 cancelable: true,
772 } );
773 el.dom7EventData = args.filter( function ( data, dataIndex ) {
774 return dataIndex > 0;
775 } );
776 el.dispatchEvent( evt );
777 el.dom7EventData = [];
778 delete el.dom7EventData;
779 }
780 }
781 }
782
783 return this;
784 }
785
786 function transitionEnd$1( callback ) {
787 var dom = this;
788
789 function fireCallBack( e ) {
790 if ( e.target !== this ) return;
791 callback.call( this, e );
792 dom.off( 'transitionend', fireCallBack );
793 }
794
795 if ( callback ) {
796 dom.on( 'transitionend', fireCallBack );
797 }
798
799 return this;
800 }
801
802 function outerWidth( includeMargins ) {
803 if ( this.length > 0 ) {
804 if ( includeMargins ) {
805 var _styles = this.styles();
806
807 return (
808 this[ 0 ].offsetWidth +
809 parseFloat( _styles.getPropertyValue( 'margin-right' ) ) +
810 parseFloat( _styles.getPropertyValue( 'margin-left' ) )
811 );
812 }
813
814 return this[ 0 ].offsetWidth;
815 }
816
817 return null;
818 }
819
820 function outerHeight( includeMargins ) {
821 if ( this.length > 0 ) {
822 if ( includeMargins ) {
823 var _styles2 = this.styles();
824
825 return (
826 this[ 0 ].offsetHeight +
827 parseFloat( _styles2.getPropertyValue( 'margin-top' ) ) +
828 parseFloat( _styles2.getPropertyValue( 'margin-bottom' ) )
829 );
830 }
831
832 return this[ 0 ].offsetHeight;
833 }
834
835 return null;
836 }
837
838 function offset() {
839 if ( this.length > 0 ) {
840 var window = getWindow();
841 var document = getDocument();
842 var el = this[ 0 ];
843 var box = el.getBoundingClientRect();
844 var body = document.body;
845 var clientTop = el.clientTop || body.clientTop || 0;
846 var clientLeft = el.clientLeft || body.clientLeft || 0;
847 var scrollTop = el === window ? window.scrollY : el.scrollTop;
848 var scrollLeft = el === window ? window.scrollX : el.scrollLeft;
849 return {
850 top: box.top + scrollTop - clientTop,
851 left: box.left + scrollLeft - clientLeft,
852 };
853 }
854
855 return null;
856 }
857
858 function styles() {
859 var window = getWindow();
860 if ( this[ 0 ] ) return window.getComputedStyle( this[ 0 ], null );
861 return {};
862 }
863
864 function css( props, value ) {
865 var window = getWindow();
866 var i;
867
868 if ( arguments.length === 1 ) {
869 if ( typeof props === 'string' ) {
870 // .css('width')
871 if ( this[ 0 ] )
872 return window.getComputedStyle( this[ 0 ], null ).getPropertyValue( props );
873 } else {
874 // .css({ width: '100px' })
875 for ( i = 0; i < this.length; i += 1 ) {
876 for ( var _prop in props ) {
877 this[ i ].style[ _prop ] = props[ _prop ];
878 }
879 }
880
881 return this;
882 }
883 }
884
885 if ( arguments.length === 2 && typeof props === 'string' ) {
886 // .css('width', '100px')
887 for ( i = 0; i < this.length; i += 1 ) {
888 this[ i ].style[ props ] = value;
889 }
890
891 return this;
892 }
893
894 return this;
895 }
896
897 function each( callback ) {
898 if ( ! callback ) return this;
899 this.forEach( function ( el, index ) {
900 callback.apply( el, [ el, index ] );
901 } );
902 return this;
903 }
904
905 function filter( callback ) {
906 var result = arrayFilter( this, callback );
907 return $( result );
908 }
909
910 function html( html ) {
911 if ( typeof html === 'undefined' ) {
912 return this[ 0 ] ? this[ 0 ].innerHTML : null;
913 }
914
915 for ( var i = 0; i < this.length; i += 1 ) {
916 this[ i ].innerHTML = html;
917 }
918
919 return this;
920 }
921
922 function text( text ) {
923 if ( typeof text === 'undefined' ) {
924 return this[ 0 ] ? this[ 0 ].textContent.trim() : null;
925 }
926
927 for ( var i = 0; i < this.length; i += 1 ) {
928 this[ i ].textContent = text;
929 }
930
931 return this;
932 }
933
934 function is( selector ) {
935 var window = getWindow();
936 var document = getDocument();
937 var el = this[ 0 ];
938 var compareWith;
939 var i;
940 if ( ! el || typeof selector === 'undefined' ) return false;
941
942 if ( typeof selector === 'string' ) {
943 if ( el.matches ) return el.matches( selector );
944 if ( el.webkitMatchesSelector ) return el.webkitMatchesSelector( selector );
945 if ( el.msMatchesSelector ) return el.msMatchesSelector( selector );
946 compareWith = $( selector );
947
948 for ( i = 0; i < compareWith.length; i += 1 ) {
949 if ( compareWith[ i ] === el ) return true;
950 }
951
952 return false;
953 }
954
955 if ( selector === document ) {
956 return el === document;
957 }
958
959 if ( selector === window ) {
960 return el === window;
961 }
962
963 if ( selector.nodeType || selector instanceof Dom7 ) {
964 compareWith = selector.nodeType ? [ selector ] : selector;
965
966 for ( i = 0; i < compareWith.length; i += 1 ) {
967 if ( compareWith[ i ] === el ) return true;
968 }
969
970 return false;
971 }
972
973 return false;
974 }
975
976 function index() {
977 var child = this[ 0 ];
978 var i;
979
980 if ( child ) {
981 i = 0; // eslint-disable-next-line
982
983 while ( ( child = child.previousSibling ) !== null ) {
984 if ( child.nodeType === 1 ) i += 1;
985 }
986
987 return i;
988 }
989
990 return undefined;
991 }
992
993 function eq( index ) {
994 if ( typeof index === 'undefined' ) return this;
995 var length = this.length;
996
997 if ( index > length - 1 ) {
998 return $( [] );
999 }
1000
1001 if ( index < 0 ) {
1002 var returnIndex = length + index;
1003 if ( returnIndex < 0 ) return $( [] );
1004 return $( [ this[ returnIndex ] ] );
1005 }
1006
1007 return $( [ this[ index ] ] );
1008 }
1009
1010 function append() {
1011 var newChild;
1012 var document = getDocument();
1013
1014 for ( var k = 0; k < arguments.length; k += 1 ) {
1015 newChild = k < 0 || arguments.length <= k ? undefined : arguments[ k ];
1016
1017 for ( var i = 0; i < this.length; i += 1 ) {
1018 if ( typeof newChild === 'string' ) {
1019 var tempDiv = document.createElement( 'div' );
1020 tempDiv.innerHTML = newChild;
1021
1022 while ( tempDiv.firstChild ) {
1023 this[ i ].appendChild( tempDiv.firstChild );
1024 }
1025 } else if ( newChild instanceof Dom7 ) {
1026 for ( var j = 0; j < newChild.length; j += 1 ) {
1027 this[ i ].appendChild( newChild[ j ] );
1028 }
1029 } else {
1030 this[ i ].appendChild( newChild );
1031 }
1032 }
1033 }
1034
1035 return this;
1036 }
1037
1038 function prepend( newChild ) {
1039 var document = getDocument();
1040 var i;
1041 var j;
1042
1043 for ( i = 0; i < this.length; i += 1 ) {
1044 if ( typeof newChild === 'string' ) {
1045 var tempDiv = document.createElement( 'div' );
1046 tempDiv.innerHTML = newChild;
1047
1048 for ( j = tempDiv.childNodes.length - 1; j >= 0; j -= 1 ) {
1049 this[ i ].insertBefore( tempDiv.childNodes[ j ], this[ i ].childNodes[ 0 ] );
1050 }
1051 } else if ( newChild instanceof Dom7 ) {
1052 for ( j = 0; j < newChild.length; j += 1 ) {
1053 this[ i ].insertBefore( newChild[ j ], this[ i ].childNodes[ 0 ] );
1054 }
1055 } else {
1056 this[ i ].insertBefore( newChild, this[ i ].childNodes[ 0 ] );
1057 }
1058 }
1059
1060 return this;
1061 }
1062
1063 function next( selector ) {
1064 if ( this.length > 0 ) {
1065 if ( selector ) {
1066 if ( this[ 0 ].nextElementSibling && $( this[ 0 ].nextElementSibling ).is( selector ) ) {
1067 return $( [ this[ 0 ].nextElementSibling ] );
1068 }
1069
1070 return $( [] );
1071 }
1072
1073 if ( this[ 0 ].nextElementSibling ) return $( [ this[ 0 ].nextElementSibling ] );
1074 return $( [] );
1075 }
1076
1077 return $( [] );
1078 }
1079
1080 function nextAll( selector ) {
1081 var nextEls = [];
1082 var el = this[ 0 ];
1083 if ( ! el ) return $( [] );
1084
1085 while ( el.nextElementSibling ) {
1086 var _next = el.nextElementSibling; // eslint-disable-line
1087
1088 if ( selector ) {
1089 if ( $( _next ).is( selector ) ) nextEls.push( _next );
1090 } else nextEls.push( _next );
1091
1092 el = _next;
1093 }
1094
1095 return $( nextEls );
1096 }
1097
1098 function prev( selector ) {
1099 if ( this.length > 0 ) {
1100 var el = this[ 0 ];
1101
1102 if ( selector ) {
1103 if ( el.previousElementSibling && $( el.previousElementSibling ).is( selector ) ) {
1104 return $( [ el.previousElementSibling ] );
1105 }
1106
1107 return $( [] );
1108 }
1109
1110 if ( el.previousElementSibling ) return $( [ el.previousElementSibling ] );
1111 return $( [] );
1112 }
1113
1114 return $( [] );
1115 }
1116
1117 function prevAll( selector ) {
1118 var prevEls = [];
1119 var el = this[ 0 ];
1120 if ( ! el ) return $( [] );
1121
1122 while ( el.previousElementSibling ) {
1123 var _prev = el.previousElementSibling; // eslint-disable-line
1124
1125 if ( selector ) {
1126 if ( $( _prev ).is( selector ) ) prevEls.push( _prev );
1127 } else prevEls.push( _prev );
1128
1129 el = _prev;
1130 }
1131
1132 return $( prevEls );
1133 }
1134
1135 function parent( selector ) {
1136 var parents = []; // eslint-disable-line
1137
1138 for ( var i = 0; i < this.length; i += 1 ) {
1139 if ( this[ i ].parentNode !== null ) {
1140 if ( selector ) {
1141 if ( $( this[ i ].parentNode ).is( selector ) ) parents.push( this[ i ].parentNode );
1142 } else {
1143 parents.push( this[ i ].parentNode );
1144 }
1145 }
1146 }
1147
1148 return $( parents );
1149 }
1150
1151 function parents( selector ) {
1152 var parents = []; // eslint-disable-line
1153
1154 for ( var i = 0; i < this.length; i += 1 ) {
1155 var _parent = this[ i ].parentNode; // eslint-disable-line
1156
1157 while ( _parent ) {
1158 if ( selector ) {
1159 if ( $( _parent ).is( selector ) ) parents.push( _parent );
1160 } else {
1161 parents.push( _parent );
1162 }
1163
1164 _parent = _parent.parentNode;
1165 }
1166 }
1167
1168 return $( parents );
1169 }
1170
1171 function closest( selector ) {
1172 var closest = this; // eslint-disable-line
1173
1174 if ( typeof selector === 'undefined' ) {
1175 return $( [] );
1176 }
1177
1178 if ( ! closest.is( selector ) ) {
1179 closest = closest.parents( selector ).eq( 0 );
1180 }
1181
1182 return closest;
1183 }
1184
1185 function find( selector ) {
1186 var foundElements = [];
1187
1188 for ( var i = 0; i < this.length; i += 1 ) {
1189 var found = this[ i ].querySelectorAll( selector );
1190
1191 for ( var j = 0; j < found.length; j += 1 ) {
1192 foundElements.push( found[ j ] );
1193 }
1194 }
1195
1196 return $( foundElements );
1197 }
1198
1199 function children( selector ) {
1200 var children = []; // eslint-disable-line
1201
1202 for ( var i = 0; i < this.length; i += 1 ) {
1203 var childNodes = this[ i ].children;
1204
1205 for ( var j = 0; j < childNodes.length; j += 1 ) {
1206 if ( ! selector || $( childNodes[ j ] ).is( selector ) ) {
1207 children.push( childNodes[ j ] );
1208 }
1209 }
1210 }
1211
1212 return $( children );
1213 }
1214
1215 function remove() {
1216 for ( var i = 0; i < this.length; i += 1 ) {
1217 if ( this[ i ].parentNode ) this[ i ].parentNode.removeChild( this[ i ] );
1218 }
1219
1220 return this;
1221 }
1222
1223 var Methods = {
1224 addClass: addClass,
1225 removeClass: removeClass,
1226 hasClass: hasClass,
1227 toggleClass: toggleClass,
1228 attr: attr,
1229 removeAttr: removeAttr,
1230 transform: transform,
1231 transition: transition$1,
1232 on: on,
1233 off: off,
1234 trigger: trigger,
1235 transitionEnd: transitionEnd$1,
1236 outerWidth: outerWidth,
1237 outerHeight: outerHeight,
1238 styles: styles,
1239 offset: offset,
1240 css: css,
1241 each: each,
1242 html: html,
1243 text: text,
1244 is: is,
1245 index: index,
1246 eq: eq,
1247 append: append,
1248 prepend: prepend,
1249 next: next,
1250 nextAll: nextAll,
1251 prev: prev,
1252 prevAll: prevAll,
1253 parent: parent,
1254 parents: parents,
1255 closest: closest,
1256 find: find,
1257 children: children,
1258 filter: filter,
1259 remove: remove,
1260 };
1261 Object.keys( Methods ).forEach( function ( methodName ) {
1262 Object.defineProperty( $.fn, methodName, {
1263 value: Methods[ methodName ],
1264 writable: true,
1265 } );
1266 } );
1267
1268 function deleteProps( obj ) {
1269 var object = obj;
1270 Object.keys( object ).forEach( function ( key ) {
1271 try {
1272 object[ key ] = null;
1273 } catch ( e ) {
1274 // no getter for object
1275 }
1276
1277 try {
1278 delete object[ key ];
1279 } catch ( e ) {
1280 // something got wrong
1281 }
1282 } );
1283 }
1284
1285 function nextTick( callback, delay ) {
1286 if ( delay === void 0 ) {
1287 delay = 0;
1288 }
1289
1290 return setTimeout( callback, delay );
1291 }
1292
1293 function now() {
1294 return Date.now();
1295 }
1296
1297 function getComputedStyle$1( el ) {
1298 var window = getWindow();
1299 var style;
1300
1301 if ( window.getComputedStyle ) {
1302 style = window.getComputedStyle( el, null );
1303 }
1304
1305 if ( ! style && el.currentStyle ) {
1306 style = el.currentStyle;
1307 }
1308
1309 if ( ! style ) {
1310 style = el.style;
1311 }
1312
1313 return style;
1314 }
1315
1316 function getTranslate( el, axis ) {
1317 if ( axis === void 0 ) {
1318 axis = 'x';
1319 }
1320
1321 var window = getWindow();
1322 var matrix;
1323 var curTransform;
1324 var transformMatrix;
1325 var curStyle = getComputedStyle$1( el );
1326
1327 if ( window.WebKitCSSMatrix ) {
1328 curTransform = curStyle.transform || curStyle.webkitTransform;
1329
1330 if ( curTransform.split( ',' ).length > 6 ) {
1331 curTransform = curTransform
1332 .split( ', ' )
1333 .map( function ( a ) {
1334 return a.replace( ',', '.' );
1335 } )
1336 .join( ', ' );
1337 } // Some old versions of Webkit choke when 'none' is passed; pass
1338 // empty string instead in this case
1339
1340 transformMatrix = new window.WebKitCSSMatrix( curTransform === 'none' ? '' : curTransform );
1341 } else {
1342 transformMatrix =
1343 curStyle.MozTransform ||
1344 curStyle.OTransform ||
1345 curStyle.MsTransform ||
1346 curStyle.msTransform ||
1347 curStyle.transform ||
1348 curStyle.getPropertyValue( 'transform' ).replace( 'translate(', 'matrix(1, 0, 0, 1,' );
1349 matrix = transformMatrix.toString().split( ',' );
1350 }
1351
1352 if ( axis === 'x' ) {
1353 // Latest Chrome and webkits Fix
1354 if ( window.WebKitCSSMatrix ) curTransform = transformMatrix.m41;
1355 // Crazy IE10 Matrix
1356 else if ( matrix.length === 16 ) curTransform = parseFloat( matrix[ 12 ] );
1357 // Normal Browsers
1358 else curTransform = parseFloat( matrix[ 4 ] );
1359 }
1360
1361 if ( axis === 'y' ) {
1362 // Latest Chrome and webkits Fix
1363 if ( window.WebKitCSSMatrix ) curTransform = transformMatrix.m42;
1364 // Crazy IE10 Matrix
1365 else if ( matrix.length === 16 ) curTransform = parseFloat( matrix[ 13 ] );
1366 // Normal Browsers
1367 else curTransform = parseFloat( matrix[ 5 ] );
1368 }
1369
1370 return curTransform || 0;
1371 }
1372
1373 function isObject( o ) {
1374 return (
1375 typeof o === 'object' &&
1376 o !== null &&
1377 o.constructor &&
1378 Object.prototype.toString.call( o ).slice( 8, -1 ) === 'Object'
1379 );
1380 }
1381
1382 function extend() {
1383 var to = Object( arguments.length <= 0 ? undefined : arguments[ 0 ] );
1384 var noExtend = [ '__proto__', 'constructor', 'prototype' ]; // eslint-disable-next-line
1385
1386 var HTMLElement = typeof window !== 'undefined' ? window.HTMLElement : undefined;
1387
1388 for ( var i = 1; i < arguments.length; i += 1 ) {
1389 var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[ i ];
1390
1391 if (
1392 nextSource !== undefined &&
1393 nextSource !== null &&
1394 ! ( HTMLElement && nextSource instanceof HTMLElement )
1395 ) {
1396 var keysArray = Object.keys( Object( nextSource ) ).filter( function ( key ) {
1397 return noExtend.indexOf( key ) < 0;
1398 } );
1399
1400 for ( var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1 ) {
1401 var nextKey = keysArray[ nextIndex ];
1402 var desc = Object.getOwnPropertyDescriptor( nextSource, nextKey );
1403
1404 if ( desc !== undefined && desc.enumerable ) {
1405 if ( isObject( to[ nextKey ] ) && isObject( nextSource[ nextKey ] ) ) {
1406 if ( nextSource[ nextKey ].__swiper__ ) {
1407 to[ nextKey ] = nextSource[ nextKey ];
1408 } else {
1409 extend( to[ nextKey ], nextSource[ nextKey ] );
1410 }
1411 } else if ( ! isObject( to[ nextKey ] ) && isObject( nextSource[ nextKey ] ) ) {
1412 to[ nextKey ] = {};
1413
1414 if ( nextSource[ nextKey ].__swiper__ ) {
1415 to[ nextKey ] = nextSource[ nextKey ];
1416 } else {
1417 extend( to[ nextKey ], nextSource[ nextKey ] );
1418 }
1419 } else {
1420 to[ nextKey ] = nextSource[ nextKey ];
1421 }
1422 }
1423 }
1424 }
1425 }
1426
1427 return to;
1428 }
1429
1430 function bindModuleMethods( instance, obj ) {
1431 Object.keys( obj ).forEach( function ( key ) {
1432 if ( isObject( obj[ key ] ) ) {
1433 Object.keys( obj[ key ] ).forEach( function ( subKey ) {
1434 if ( typeof obj[ key ][ subKey ] === 'function' ) {
1435 obj[ key ][ subKey ] = obj[ key ][ subKey ].bind( instance );
1436 }
1437 } );
1438 }
1439
1440 instance[ key ] = obj[ key ];
1441 } );
1442 }
1443
1444 function classesToSelector( classes ) {
1445 if ( classes === void 0 ) {
1446 classes = '';
1447 }
1448
1449 return (
1450 '.' +
1451 classes
1452 .trim()
1453 .replace( /([\.:\/])/g, '\\$1' ) // eslint-disable-line
1454 .replace( / /g, '.' )
1455 );
1456 }
1457
1458 function createElementIfNotDefined( $container, params, createElements, checkProps ) {
1459 var document = getDocument();
1460
1461 if ( createElements ) {
1462 Object.keys( checkProps ).forEach( function ( key ) {
1463 if ( ! params[ key ] && params.auto === true ) {
1464 var element = document.createElement( 'div' );
1465 element.className = checkProps[ key ];
1466 $container.append( element );
1467 params[ key ] = element;
1468 }
1469 } );
1470 }
1471
1472 return params;
1473 }
1474
1475 var support;
1476
1477 function calcSupport() {
1478 var window = getWindow();
1479 var document = getDocument();
1480 return {
1481 touch: !! (
1482 'ontouchstart' in window ||
1483 ( window.DocumentTouch && document instanceof window.DocumentTouch )
1484 ),
1485 pointerEvents:
1486 !! window.PointerEvent &&
1487 'maxTouchPoints' in window.navigator &&
1488 window.navigator.maxTouchPoints >= 0,
1489 observer: ( function checkObserver() {
1490 return 'MutationObserver' in window || 'WebkitMutationObserver' in window;
1491 } )(),
1492 passiveListener: ( function checkPassiveListener() {
1493 var supportsPassive = false;
1494
1495 try {
1496 var opts = Object.defineProperty( {}, 'passive', {
1497 // eslint-disable-next-line
1498 get: function get() {
1499 supportsPassive = true;
1500 },
1501 } );
1502 window.addEventListener( 'testPassiveListener', null, opts );
1503 } catch ( e ) {
1504 // No support
1505 }
1506
1507 return supportsPassive;
1508 } )(),
1509 gestures: ( function checkGestures() {
1510 return 'ongesturestart' in window;
1511 } )(),
1512 };
1513 }
1514
1515 function getSupport() {
1516 if ( ! support ) {
1517 support = calcSupport();
1518 }
1519
1520 return support;
1521 }
1522
1523 var device;
1524
1525 function calcDevice( _temp ) {
1526 var _ref = _temp === void 0 ? {} : _temp,
1527 userAgent = _ref.userAgent;
1528
1529 var support = getSupport();
1530 var window = getWindow();
1531 var platform = window.navigator.platform;
1532 var ua = userAgent || window.navigator.userAgent;
1533 var device = {
1534 ios: false,
1535 android: false,
1536 };
1537 var screenWidth = window.screen.width;
1538 var screenHeight = window.screen.height;
1539 var android = ua.match( /(Android);?[\s\/]+([\d.]+)?/ ); // eslint-disable-line
1540
1541 var ipad = ua.match( /(iPad).*OS\s([\d_]+)/ );
1542 var ipod = ua.match( /(iPod)(.*OS\s([\d_]+))?/ );
1543 var iphone = ! ipad && ua.match( /(iPhone\sOS|iOS)\s([\d_]+)/ );
1544 var windows = platform === 'Win32';
1545 var macos = platform === 'MacIntel'; // iPadOs 13 fix
1546
1547 var iPadScreens = [
1548 '1024x1366',
1549 '1366x1024',
1550 '834x1194',
1551 '1194x834',
1552 '834x1112',
1553 '1112x834',
1554 '768x1024',
1555 '1024x768',
1556 '820x1180',
1557 '1180x820',
1558 '810x1080',
1559 '1080x810',
1560 ];
1561
1562 if (
1563 ! ipad &&
1564 macos &&
1565 support.touch &&
1566 iPadScreens.indexOf( screenWidth + 'x' + screenHeight ) >= 0
1567 ) {
1568 ipad = ua.match( /(Version)\/([\d.]+)/ );
1569 if ( ! ipad ) ipad = [ 0, 1, '13_0_0' ];
1570 macos = false;
1571 } // Android
1572
1573 if ( android && ! windows ) {
1574 device.os = 'android';
1575 device.android = true;
1576 }
1577
1578 if ( ipad || iphone || ipod ) {
1579 device.os = 'ios';
1580 device.ios = true;
1581 } // Export object
1582
1583 return device;
1584 }
1585
1586 function getDevice( overrides ) {
1587 if ( overrides === void 0 ) {
1588 overrides = {};
1589 }
1590
1591 if ( ! device ) {
1592 device = calcDevice( overrides );
1593 }
1594
1595 return device;
1596 }
1597
1598 var browser;
1599
1600 function calcBrowser() {
1601 var window = getWindow();
1602
1603 function isSafari() {
1604 var ua = window.navigator.userAgent.toLowerCase();
1605 return (
1606 ua.indexOf( 'safari' ) >= 0 && ua.indexOf( 'chrome' ) < 0 && ua.indexOf( 'android' ) < 0
1607 );
1608 }
1609
1610 return {
1611 isEdge: !! window.navigator.userAgent.match( /Edge/g ),
1612 isSafari: isSafari(),
1613 isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test( window.navigator.userAgent ),
1614 };
1615 }
1616
1617 function getBrowser() {
1618 if ( ! browser ) {
1619 browser = calcBrowser();
1620 }
1621
1622 return browser;
1623 }
1624
1625 var supportsResizeObserver = function supportsResizeObserver() {
1626 var window = getWindow();
1627 return typeof window.ResizeObserver !== 'undefined';
1628 };
1629
1630 var Resize = {
1631 name: 'resize',
1632 create: function create() {
1633 var swiper = this;
1634 extend( swiper, {
1635 resize: {
1636 observer: null,
1637 createObserver: function createObserver() {
1638 if ( ! swiper || swiper.destroyed || ! swiper.initialized ) return;
1639 swiper.resize.observer = new ResizeObserver( function ( entries ) {
1640 var width = swiper.width,
1641 height = swiper.height;
1642 var newWidth = width;
1643 var newHeight = height;
1644 entries.forEach( function ( _ref ) {
1645 var contentBoxSize = _ref.contentBoxSize,
1646 contentRect = _ref.contentRect,
1647 target = _ref.target;
1648 if ( target && target !== swiper.el ) return;
1649 newWidth = contentRect
1650 ? contentRect.width
1651 : ( contentBoxSize[ 0 ] || contentBoxSize ).inlineSize;
1652 newHeight = contentRect
1653 ? contentRect.height
1654 : ( contentBoxSize[ 0 ] || contentBoxSize ).blockSize;
1655 } );
1656
1657 if ( newWidth !== width || newHeight !== height ) {
1658 swiper.resize.resizeHandler();
1659 }
1660 } );
1661 swiper.resize.observer.observe( swiper.el );
1662 },
1663 removeObserver: function removeObserver() {
1664 if ( swiper.resize.observer && swiper.resize.observer.unobserve && swiper.el ) {
1665 swiper.resize.observer.unobserve( swiper.el );
1666 swiper.resize.observer = null;
1667 }
1668 },
1669 resizeHandler: function resizeHandler() {
1670 if ( ! swiper || swiper.destroyed || ! swiper.initialized ) return;
1671 swiper.emit( 'beforeResize' );
1672 swiper.emit( 'resize' );
1673 },
1674 orientationChangeHandler: function orientationChangeHandler() {
1675 if ( ! swiper || swiper.destroyed || ! swiper.initialized ) return;
1676 swiper.emit( 'orientationchange' );
1677 },
1678 },
1679 } );
1680 },
1681 on: {
1682 init: function init( swiper ) {
1683 var window = getWindow();
1684
1685 if ( swiper.params.resizeObserver && supportsResizeObserver() ) {
1686 swiper.resize.createObserver();
1687 return;
1688 } // Emit resize
1689
1690 window.addEventListener( 'resize', swiper.resize.resizeHandler ); // Emit orientationchange
1691
1692 window.addEventListener( 'orientationchange', swiper.resize.orientationChangeHandler );
1693 },
1694 destroy: function destroy( swiper ) {
1695 var window = getWindow();
1696 swiper.resize.removeObserver();
1697 window.removeEventListener( 'resize', swiper.resize.resizeHandler );
1698 window.removeEventListener( 'orientationchange', swiper.resize.orientationChangeHandler );
1699 },
1700 },
1701 };
1702
1703 var Observer = {
1704 attach: function attach( target, options ) {
1705 if ( options === void 0 ) {
1706 options = {};
1707 }
1708
1709 var window = getWindow();
1710 var swiper = this;
1711 var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
1712 var observer = new ObserverFunc( function ( mutations ) {
1713 // The observerUpdate event should only be triggered
1714 // once despite the number of mutations. Additional
1715 // triggers are redundant and are very costly
1716 if ( mutations.length === 1 ) {
1717 swiper.emit( 'observerUpdate', mutations[ 0 ] );
1718 return;
1719 }
1720
1721 var observerUpdate = function observerUpdate() {
1722 swiper.emit( 'observerUpdate', mutations[ 0 ] );
1723 };
1724
1725 if ( window.requestAnimationFrame ) {
1726 window.requestAnimationFrame( observerUpdate );
1727 } else {
1728 window.setTimeout( observerUpdate, 0 );
1729 }
1730 } );
1731 observer.observe( target, {
1732 attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
1733 childList: typeof options.childList === 'undefined' ? true : options.childList,
1734 characterData: typeof options.characterData === 'undefined' ? true : options.characterData,
1735 } );
1736 swiper.observer.observers.push( observer );
1737 },
1738 init: function init() {
1739 var swiper = this;
1740 if ( ! swiper.support.observer || ! swiper.params.observer ) return;
1741
1742 if ( swiper.params.observeParents ) {
1743 var containerParents = swiper.$el.parents();
1744
1745 for ( var i = 0; i < containerParents.length; i += 1 ) {
1746 swiper.observer.attach( containerParents[ i ] );
1747 }
1748 } // Observe container
1749
1750 swiper.observer.attach( swiper.$el[ 0 ], {
1751 childList: swiper.params.observeSlideChildren,
1752 } ); // Observe wrapper
1753
1754 swiper.observer.attach( swiper.$wrapperEl[ 0 ], {
1755 attributes: false,
1756 } );
1757 },
1758 destroy: function destroy() {
1759 var swiper = this;
1760 swiper.observer.observers.forEach( function ( observer ) {
1761 observer.disconnect();
1762 } );
1763 swiper.observer.observers = [];
1764 },
1765 };
1766 var Observer$1 = {
1767 name: 'observer',
1768 params: {
1769 observer: false,
1770 observeParents: false,
1771 observeSlideChildren: false,
1772 },
1773 create: function create() {
1774 var swiper = this;
1775 bindModuleMethods( swiper, {
1776 observer: _extends( {}, Observer, {
1777 observers: [],
1778 } ),
1779 } );
1780 },
1781 on: {
1782 init: function init( swiper ) {
1783 swiper.observer.init();
1784 },
1785 destroy: function destroy( swiper ) {
1786 swiper.observer.destroy();
1787 },
1788 },
1789 };
1790
1791 var modular = {
1792 useParams: function useParams( instanceParams ) {
1793 var instance = this;
1794 if ( ! instance.modules ) return;
1795 Object.keys( instance.modules ).forEach( function ( moduleName ) {
1796 var module = instance.modules[ moduleName ]; // Extend params
1797
1798 if ( module.params ) {
1799 extend( instanceParams, module.params );
1800 }
1801 } );
1802 },
1803 useModules: function useModules( modulesParams ) {
1804 if ( modulesParams === void 0 ) {
1805 modulesParams = {};
1806 }
1807
1808 var instance = this;
1809 if ( ! instance.modules ) return;
1810 Object.keys( instance.modules ).forEach( function ( moduleName ) {
1811 var module = instance.modules[ moduleName ];
1812 var moduleParams = modulesParams[ moduleName ] || {}; // Add event listeners
1813
1814 if ( module.on && instance.on ) {
1815 Object.keys( module.on ).forEach( function ( moduleEventName ) {
1816 instance.on( moduleEventName, module.on[ moduleEventName ] );
1817 } );
1818 } // Module create callback
1819
1820 if ( module.create ) {
1821 module.create.bind( instance )( moduleParams );
1822 }
1823 } );
1824 },
1825 };
1826
1827 /* eslint-disable no-underscore-dangle */
1828 var eventsEmitter = {
1829 on: function on( events, handler, priority ) {
1830 var self = this;
1831 if ( typeof handler !== 'function' ) return self;
1832 var method = priority ? 'unshift' : 'push';
1833 events.split( ' ' ).forEach( function ( event ) {
1834 if ( ! self.eventsListeners[ event ] ) self.eventsListeners[ event ] = [];
1835 self.eventsListeners[ event ][ method ]( handler );
1836 } );
1837 return self;
1838 },
1839 once: function once( events, handler, priority ) {
1840 var self = this;
1841 if ( typeof handler !== 'function' ) return self;
1842
1843 function onceHandler() {
1844 self.off( events, onceHandler );
1845
1846 if ( onceHandler.__emitterProxy ) {
1847 delete onceHandler.__emitterProxy;
1848 }
1849
1850 for (
1851 var _len = arguments.length, args = new Array( _len ), _key = 0;
1852 _key < _len;
1853 _key++
1854 ) {
1855 args[ _key ] = arguments[ _key ];
1856 }
1857
1858 handler.apply( self, args );
1859 }
1860
1861 onceHandler.__emitterProxy = handler;
1862 return self.on( events, onceHandler, priority );
1863 },
1864 onAny: function onAny( handler, priority ) {
1865 var self = this;
1866 if ( typeof handler !== 'function' ) return self;
1867 var method = priority ? 'unshift' : 'push';
1868
1869 if ( self.eventsAnyListeners.indexOf( handler ) < 0 ) {
1870 self.eventsAnyListeners[ method ]( handler );
1871 }
1872
1873 return self;
1874 },
1875 offAny: function offAny( handler ) {
1876 var self = this;
1877 if ( ! self.eventsAnyListeners ) return self;
1878 var index = self.eventsAnyListeners.indexOf( handler );
1879
1880 if ( index >= 0 ) {
1881 self.eventsAnyListeners.splice( index, 1 );
1882 }
1883
1884 return self;
1885 },
1886 off: function off( events, handler ) {
1887 var self = this;
1888 if ( ! self.eventsListeners ) return self;
1889 events.split( ' ' ).forEach( function ( event ) {
1890 if ( typeof handler === 'undefined' ) {
1891 self.eventsListeners[ event ] = [];
1892 } else if ( self.eventsListeners[ event ] ) {
1893 self.eventsListeners[ event ].forEach( function ( eventHandler, index ) {
1894 if (
1895 eventHandler === handler ||
1896 ( eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler )
1897 ) {
1898 self.eventsListeners[ event ].splice( index, 1 );
1899 }
1900 } );
1901 }
1902 } );
1903 return self;
1904 },
1905 emit: function emit() {
1906 var self = this;
1907 if ( ! self.eventsListeners ) return self;
1908 var events;
1909 var data;
1910 var context;
1911
1912 for (
1913 var _len2 = arguments.length, args = new Array( _len2 ), _key2 = 0;
1914 _key2 < _len2;
1915 _key2++
1916 ) {
1917 args[ _key2 ] = arguments[ _key2 ];
1918 }
1919
1920 if ( typeof args[ 0 ] === 'string' || Array.isArray( args[ 0 ] ) ) {
1921 events = args[ 0 ];
1922 data = args.slice( 1, args.length );
1923 context = self;
1924 } else {
1925 events = args[ 0 ].events;
1926 data = args[ 0 ].data;
1927 context = args[ 0 ].context || self;
1928 }
1929
1930 data.unshift( context );
1931 var eventsArray = Array.isArray( events ) ? events : events.split( ' ' );
1932 eventsArray.forEach( function ( event ) {
1933 if ( self.eventsAnyListeners && self.eventsAnyListeners.length ) {
1934 self.eventsAnyListeners.forEach( function ( eventHandler ) {
1935 eventHandler.apply( context, [ event ].concat( data ) );
1936 } );
1937 }
1938
1939 if ( self.eventsListeners && self.eventsListeners[ event ] ) {
1940 self.eventsListeners[ event ].forEach( function ( eventHandler ) {
1941 eventHandler.apply( context, data );
1942 } );
1943 }
1944 } );
1945 return self;
1946 },
1947 };
1948
1949 function updateSize() {
1950 var swiper = this;
1951 var width;
1952 var height;
1953 var $el = swiper.$el;
1954
1955 if ( typeof swiper.params.width !== 'undefined' && swiper.params.width !== null ) {
1956 width = swiper.params.width;
1957 } else {
1958 width = $el[ 0 ].clientWidth;
1959 }
1960
1961 if ( typeof swiper.params.height !== 'undefined' && swiper.params.height !== null ) {
1962 height = swiper.params.height;
1963 } else {
1964 height = $el[ 0 ].clientHeight;
1965 }
1966
1967 if ( ( width === 0 && swiper.isHorizontal() ) || ( height === 0 && swiper.isVertical() ) ) {
1968 return;
1969 } // Subtract paddings
1970
1971 width =
1972 width -
1973 parseInt( $el.css( 'padding-left' ) || 0, 10 ) -
1974 parseInt( $el.css( 'padding-right' ) || 0, 10 );
1975 height =
1976 height -
1977 parseInt( $el.css( 'padding-top' ) || 0, 10 ) -
1978 parseInt( $el.css( 'padding-bottom' ) || 0, 10 );
1979 if ( Number.isNaN( width ) ) width = 0;
1980 if ( Number.isNaN( height ) ) height = 0;
1981 extend( swiper, {
1982 width: width,
1983 height: height,
1984 size: swiper.isHorizontal() ? width : height,
1985 } );
1986 }
1987
1988 function updateSlides() {
1989 var swiper = this;
1990
1991 function getDirectionLabel( property ) {
1992 if (swiper.isHorizontal()) {
1993 return property;
1994 } // prettier-ignore
1995
1996 return {
1997 width: 'height',
1998 'margin-top': 'margin-left',
1999 'margin-bottom ': 'margin-right',
2000 'margin-left': 'margin-top',
2001 'margin-right': 'margin-bottom',
2002 'padding-left': 'padding-top',
2003 'padding-right': 'padding-bottom',
2004 marginRight: 'marginBottom',
2005 }[ property ];
2006 }
2007
2008 function getDirectionPropertyValue( node, label ) {
2009 return parseFloat( node.getPropertyValue( getDirectionLabel( label ) ) || 0 );
2010 }
2011
2012 var params = swiper.params;
2013 var $wrapperEl = swiper.$wrapperEl,
2014 swiperSize = swiper.size,
2015 rtl = swiper.rtlTranslate,
2016 wrongRTL = swiper.wrongRTL;
2017 var isVirtual = swiper.virtual && params.virtual.enabled;
2018 var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
2019 var slides = $wrapperEl.children( '.' + swiper.params.slideClass );
2020 var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
2021 var snapGrid = [];
2022 var slidesGrid = [];
2023 var slidesSizesGrid = [];
2024 var offsetBefore = params.slidesOffsetBefore;
2025
2026 if ( typeof offsetBefore === 'function' ) {
2027 offsetBefore = params.slidesOffsetBefore.call( swiper );
2028 }
2029
2030 var offsetAfter = params.slidesOffsetAfter;
2031
2032 if ( typeof offsetAfter === 'function' ) {
2033 offsetAfter = params.slidesOffsetAfter.call( swiper );
2034 }
2035
2036 var previousSnapGridLength = swiper.snapGrid.length;
2037 var previousSlidesGridLength = swiper.slidesGrid.length;
2038 var spaceBetween = params.spaceBetween;
2039 var slidePosition = -offsetBefore;
2040 var prevSlideSize = 0;
2041 var index = 0;
2042
2043 if ( typeof swiperSize === 'undefined' ) {
2044 return;
2045 }
2046
2047 if ( typeof spaceBetween === 'string' && spaceBetween.indexOf( '%' ) >= 0 ) {
2048 spaceBetween = ( parseFloat( spaceBetween.replace( '%', '' ) ) / 100 ) * swiperSize;
2049 }
2050
2051 swiper.virtualSize = -spaceBetween; // reset margins
2052
2053 if ( rtl )
2054 slides.css( {
2055 marginLeft: '',
2056 marginTop: '',
2057 } );
2058 else
2059 slides.css( {
2060 marginRight: '',
2061 marginBottom: '',
2062 } );
2063 var slidesNumberEvenToRows;
2064
2065 if ( params.slidesPerColumn > 1 ) {
2066 if (
2067 Math.floor( slidesLength / params.slidesPerColumn ) ===
2068 slidesLength / swiper.params.slidesPerColumn
2069 ) {
2070 slidesNumberEvenToRows = slidesLength;
2071 } else {
2072 slidesNumberEvenToRows =
2073 Math.ceil( slidesLength / params.slidesPerColumn ) * params.slidesPerColumn;
2074 }
2075
2076 if ( params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row' ) {
2077 slidesNumberEvenToRows = Math.max(
2078 slidesNumberEvenToRows,
2079 params.slidesPerView * params.slidesPerColumn
2080 );
2081 }
2082 } // Calc slides
2083
2084 var slideSize;
2085 var slidesPerColumn = params.slidesPerColumn;
2086 var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
2087 var numFullColumns = Math.floor( slidesLength / params.slidesPerColumn );
2088
2089 for ( var i = 0; i < slidesLength; i += 1 ) {
2090 slideSize = 0;
2091 var slide = slides.eq( i );
2092
2093 if ( params.slidesPerColumn > 1 ) {
2094 // Set slides order
2095 var newSlideOrderIndex = void 0;
2096 var column = void 0;
2097 var row = void 0;
2098
2099 if ( params.slidesPerColumnFill === 'row' && params.slidesPerGroup > 1 ) {
2100 var groupIndex = Math.floor( i / ( params.slidesPerGroup * params.slidesPerColumn ) );
2101 var slideIndexInGroup = i - params.slidesPerColumn * params.slidesPerGroup * groupIndex;
2102 var columnsInGroup =
2103 groupIndex === 0
2104 ? params.slidesPerGroup
2105 : Math.min(
2106 Math.ceil(
2107 ( slidesLength - groupIndex * slidesPerColumn * params.slidesPerGroup ) /
2108 slidesPerColumn
2109 ),
2110 params.slidesPerGroup
2111 );
2112 row = Math.floor( slideIndexInGroup / columnsInGroup );
2113 column = slideIndexInGroup - row * columnsInGroup + groupIndex * params.slidesPerGroup;
2114 newSlideOrderIndex = column + ( row * slidesNumberEvenToRows ) / slidesPerColumn;
2115 slide.css( {
2116 '-webkit-box-ordinal-group': newSlideOrderIndex,
2117 '-moz-box-ordinal-group': newSlideOrderIndex,
2118 '-ms-flex-order': newSlideOrderIndex,
2119 '-webkit-order': newSlideOrderIndex,
2120 order: newSlideOrderIndex,
2121 } );
2122 } else if ( params.slidesPerColumnFill === 'column' ) {
2123 column = Math.floor( i / slidesPerColumn );
2124 row = i - column * slidesPerColumn;
2125
2126 if (
2127 column > numFullColumns ||
2128 ( column === numFullColumns && row === slidesPerColumn - 1 )
2129 ) {
2130 row += 1;
2131
2132 if ( row >= slidesPerColumn ) {
2133 row = 0;
2134 column += 1;
2135 }
2136 }
2137 } else {
2138 row = Math.floor( i / slidesPerRow );
2139 column = i - row * slidesPerRow;
2140 }
2141
2142 slide.css(
2143 getDirectionLabel( 'margin-top' ),
2144 row !== 0 ? params.spaceBetween && params.spaceBetween + 'px' : ''
2145 );
2146 }
2147
2148 if ( slide.css( 'display' ) === 'none' ) continue; // eslint-disable-line
2149
2150 if ( params.slidesPerView === 'auto' ) {
2151 var slideStyles = getComputedStyle( slide[ 0 ] );
2152 var currentTransform = slide[ 0 ].style.transform;
2153 var currentWebKitTransform = slide[ 0 ].style.webkitTransform;
2154
2155 if ( currentTransform ) {
2156 slide[ 0 ].style.transform = 'none';
2157 }
2158
2159 if ( currentWebKitTransform ) {
2160 slide[ 0 ].style.webkitTransform = 'none';
2161 }
2162
2163 if ( params.roundLengths ) {
2164 slideSize = swiper.isHorizontal() ? slide.outerWidth( true ) : slide.outerHeight( true );
2165 } else {
2166 // eslint-disable-next-line
2167 var width = getDirectionPropertyValue( slideStyles, 'width' );
2168 var paddingLeft = getDirectionPropertyValue( slideStyles, 'padding-left' );
2169 var paddingRight = getDirectionPropertyValue( slideStyles, 'padding-right' );
2170 var marginLeft = getDirectionPropertyValue( slideStyles, 'margin-left' );
2171 var marginRight = getDirectionPropertyValue( slideStyles, 'margin-right' );
2172 var boxSizing = slideStyles.getPropertyValue( 'box-sizing' );
2173
2174 if ( boxSizing && boxSizing === 'border-box' ) {
2175 slideSize = width + marginLeft + marginRight;
2176 } else {
2177 var _slide$ = slide[ 0 ],
2178 clientWidth = _slide$.clientWidth,
2179 offsetWidth = _slide$.offsetWidth;
2180 slideSize =
2181 width +
2182 paddingLeft +
2183 paddingRight +
2184 marginLeft +
2185 marginRight +
2186 ( offsetWidth - clientWidth );
2187 }
2188 }
2189
2190 if ( currentTransform ) {
2191 slide[ 0 ].style.transform = currentTransform;
2192 }
2193
2194 if ( currentWebKitTransform ) {
2195 slide[ 0 ].style.webkitTransform = currentWebKitTransform;
2196 }
2197
2198 if ( params.roundLengths ) slideSize = Math.floor( slideSize );
2199 } else {
2200 slideSize =
2201 ( swiperSize - ( params.slidesPerView - 1 ) * spaceBetween ) / params.slidesPerView;
2202 if ( params.roundLengths ) slideSize = Math.floor( slideSize );
2203
2204 if ( slides[ i ] ) {
2205 slides[ i ].style[ getDirectionLabel( 'width' ) ] = slideSize + 'px';
2206 }
2207 }
2208
2209 if ( slides[ i ] ) {
2210 slides[ i ].swiperSlideSize = slideSize;
2211 }
2212
2213 slidesSizesGrid.push( slideSize );
2214
2215 if ( params.centeredSlides ) {
2216 slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
2217 if ( prevSlideSize === 0 && i !== 0 )
2218 slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
2219 if ( i === 0 ) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
2220 if ( Math.abs( slidePosition ) < 1 / 1000 ) slidePosition = 0;
2221 if ( params.roundLengths ) slidePosition = Math.floor( slidePosition );
2222 if ( index % params.slidesPerGroup === 0 ) snapGrid.push( slidePosition );
2223 slidesGrid.push( slidePosition );
2224 } else {
2225 if ( params.roundLengths ) slidePosition = Math.floor( slidePosition );
2226 if (
2227 ( index - Math.min( swiper.params.slidesPerGroupSkip, index ) ) %
2228 swiper.params.slidesPerGroup ===
2229 0
2230 )
2231 snapGrid.push( slidePosition );
2232 slidesGrid.push( slidePosition );
2233 slidePosition = slidePosition + slideSize + spaceBetween;
2234 }
2235
2236 swiper.virtualSize += slideSize + spaceBetween;
2237 prevSlideSize = slideSize;
2238 index += 1;
2239 }
2240
2241 swiper.virtualSize = Math.max( swiper.virtualSize, swiperSize ) + offsetAfter;
2242 var newSlidesGrid;
2243
2244 if ( rtl && wrongRTL && ( params.effect === 'slide' || params.effect === 'coverflow' ) ) {
2245 $wrapperEl.css( {
2246 width: swiper.virtualSize + params.spaceBetween + 'px',
2247 } );
2248 }
2249
2250 if ( params.setWrapperSize ) {
2251 var _$wrapperEl$css;
2252
2253 $wrapperEl.css(
2254 ( ( _$wrapperEl$css = {} ),
2255 ( _$wrapperEl$css[ getDirectionLabel( 'width' ) ] =
2256 swiper.virtualSize + params.spaceBetween + 'px' ),
2257 _$wrapperEl$css )
2258 );
2259 }
2260
2261 if ( params.slidesPerColumn > 1 ) {
2262 var _$wrapperEl$css2;
2263
2264 swiper.virtualSize = ( slideSize + params.spaceBetween ) * slidesNumberEvenToRows;
2265 swiper.virtualSize =
2266 Math.ceil( swiper.virtualSize / params.slidesPerColumn ) - params.spaceBetween;
2267 $wrapperEl.css(
2268 ( ( _$wrapperEl$css2 = {} ),
2269 ( _$wrapperEl$css2[ getDirectionLabel( 'width' ) ] =
2270 swiper.virtualSize + params.spaceBetween + 'px' ),
2271 _$wrapperEl$css2 )
2272 );
2273
2274 if ( params.centeredSlides ) {
2275 newSlidesGrid = [];
2276
2277 for ( var _i = 0; _i < snapGrid.length; _i += 1 ) {
2278 var slidesGridItem = snapGrid[ _i ];
2279 if ( params.roundLengths ) slidesGridItem = Math.floor( slidesGridItem );
2280 if ( snapGrid[ _i ] < swiper.virtualSize + snapGrid[ 0 ] )
2281 newSlidesGrid.push( slidesGridItem );
2282 }
2283
2284 snapGrid = newSlidesGrid;
2285 }
2286 } // Remove last grid elements depending on width
2287
2288 if ( ! params.centeredSlides ) {
2289 newSlidesGrid = [];
2290
2291 for ( var _i2 = 0; _i2 < snapGrid.length; _i2 += 1 ) {
2292 var _slidesGridItem = snapGrid[ _i2 ];
2293 if ( params.roundLengths ) _slidesGridItem = Math.floor( _slidesGridItem );
2294
2295 if ( snapGrid[ _i2 ] <= swiper.virtualSize - swiperSize ) {
2296 newSlidesGrid.push( _slidesGridItem );
2297 }
2298 }
2299
2300 snapGrid = newSlidesGrid;
2301
2302 if (
2303 Math.floor( swiper.virtualSize - swiperSize ) -
2304 Math.floor( snapGrid[ snapGrid.length - 1 ] ) >
2305 1
2306 ) {
2307 snapGrid.push( swiper.virtualSize - swiperSize );
2308 }
2309 }
2310
2311 if ( snapGrid.length === 0 ) snapGrid = [ 0 ];
2312
2313 if ( params.spaceBetween !== 0 ) {
2314 var _slides$filter$css;
2315
2316 var key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel( 'marginRight' );
2317 slides
2318 .filter( function ( _, slideIndex ) {
2319 if ( ! params.cssMode ) return true;
2320
2321 if ( slideIndex === slides.length - 1 ) {
2322 return false;
2323 }
2324
2325 return true;
2326 } )
2327 .css(
2328 ( ( _slides$filter$css = {} ),
2329 ( _slides$filter$css[ key ] = spaceBetween + 'px' ),
2330 _slides$filter$css )
2331 );
2332 }
2333
2334 if ( params.centeredSlides && params.centeredSlidesBounds ) {
2335 var allSlidesSize = 0;
2336 slidesSizesGrid.forEach( function ( slideSizeValue ) {
2337 allSlidesSize += slideSizeValue + ( params.spaceBetween ? params.spaceBetween : 0 );
2338 } );
2339 allSlidesSize -= params.spaceBetween;
2340 var maxSnap = allSlidesSize - swiperSize;
2341 snapGrid = snapGrid.map( function ( snap ) {
2342 if ( snap < 0 ) return -offsetBefore;
2343 if ( snap > maxSnap ) return maxSnap + offsetAfter;
2344 return snap;
2345 } );
2346 }
2347
2348 if ( params.centerInsufficientSlides ) {
2349 var _allSlidesSize = 0;
2350 slidesSizesGrid.forEach( function ( slideSizeValue ) {
2351 _allSlidesSize += slideSizeValue + ( params.spaceBetween ? params.spaceBetween : 0 );
2352 } );
2353 _allSlidesSize -= params.spaceBetween;
2354
2355 if ( _allSlidesSize < swiperSize ) {
2356 var allSlidesOffset = ( swiperSize - _allSlidesSize ) / 2;
2357 snapGrid.forEach( function ( snap, snapIndex ) {
2358 snapGrid[ snapIndex ] = snap - allSlidesOffset;
2359 } );
2360 slidesGrid.forEach( function ( snap, snapIndex ) {
2361 slidesGrid[ snapIndex ] = snap + allSlidesOffset;
2362 } );
2363 }
2364 }
2365
2366 extend( swiper, {
2367 slides: slides,
2368 snapGrid: snapGrid,
2369 slidesGrid: slidesGrid,
2370 slidesSizesGrid: slidesSizesGrid,
2371 } );
2372
2373 if ( slidesLength !== previousSlidesLength ) {
2374 swiper.emit( 'slidesLengthChange' );
2375 }
2376
2377 if ( snapGrid.length !== previousSnapGridLength ) {
2378 if ( swiper.params.watchOverflow ) swiper.checkOverflow();
2379 swiper.emit( 'snapGridLengthChange' );
2380 }
2381
2382 if ( slidesGrid.length !== previousSlidesGridLength ) {
2383 swiper.emit( 'slidesGridLengthChange' );
2384 }
2385
2386 if ( params.watchSlidesProgress || params.watchSlidesVisibility ) {
2387 swiper.updateSlidesOffset();
2388 }
2389 }
2390
2391 function updateAutoHeight( speed ) {
2392 var swiper = this;
2393 var activeSlides = [];
2394 var isVirtual = swiper.virtual && swiper.params.virtual.enabled;
2395 var newHeight = 0;
2396 var i;
2397
2398 if ( typeof speed === 'number' ) {
2399 swiper.setTransition( speed );
2400 } else if ( speed === true ) {
2401 swiper.setTransition( swiper.params.speed );
2402 }
2403
2404 var getSlideByIndex = function getSlideByIndex( index ) {
2405 if ( isVirtual ) {
2406 return swiper.slides.filter( function ( el ) {
2407 return parseInt( el.getAttribute( 'data-swiper-slide-index' ), 10 ) === index;
2408 } )[ 0 ];
2409 }
2410
2411 return swiper.slides.eq( index )[ 0 ];
2412 }; // Find slides currently in view
2413
2414 if ( swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1 ) {
2415 if ( swiper.params.centeredSlides ) {
2416 swiper.visibleSlides.each( function ( slide ) {
2417 activeSlides.push( slide );
2418 } );
2419 } else {
2420 for ( i = 0; i < Math.ceil( swiper.params.slidesPerView ); i += 1 ) {
2421 var index = swiper.activeIndex + i;
2422 if ( index > swiper.slides.length && ! isVirtual ) break;
2423 activeSlides.push( getSlideByIndex( index ) );
2424 }
2425 }
2426 } else {
2427 activeSlides.push( getSlideByIndex( swiper.activeIndex ) );
2428 } // Find new height from highest slide in view
2429
2430 for ( i = 0; i < activeSlides.length; i += 1 ) {
2431 if ( typeof activeSlides[ i ] !== 'undefined' ) {
2432 var height = activeSlides[ i ].offsetHeight;
2433 newHeight = height > newHeight ? height : newHeight;
2434 }
2435 } // Update Height
2436
2437 if ( newHeight ) swiper.$wrapperEl.css( 'height', newHeight + 'px' );
2438 }
2439
2440 function updateSlidesOffset() {
2441 var swiper = this;
2442 var slides = swiper.slides;
2443
2444 for ( var i = 0; i < slides.length; i += 1 ) {
2445 slides[ i ].swiperSlideOffset = swiper.isHorizontal()
2446 ? slides[ i ].offsetLeft
2447 : slides[ i ].offsetTop;
2448 }
2449 }
2450
2451 function updateSlidesProgress( translate ) {
2452 if ( translate === void 0 ) {
2453 translate = ( this && this.translate ) || 0;
2454 }
2455
2456 var swiper = this;
2457 var params = swiper.params;
2458 var slides = swiper.slides,
2459 rtl = swiper.rtlTranslate;
2460 if ( slides.length === 0 ) return;
2461 if ( typeof slides[ 0 ].swiperSlideOffset === 'undefined' ) swiper.updateSlidesOffset();
2462 var offsetCenter = -translate;
2463 if ( rtl ) offsetCenter = translate; // Visible Slides
2464
2465 slides.removeClass( params.slideVisibleClass );
2466 swiper.visibleSlidesIndexes = [];
2467 swiper.visibleSlides = [];
2468
2469 for ( var i = 0; i < slides.length; i += 1 ) {
2470 var slide = slides[ i ];
2471 var slideProgress =
2472 ( offsetCenter +
2473 ( params.centeredSlides ? swiper.minTranslate() : 0 ) -
2474 slide.swiperSlideOffset ) /
2475 ( slide.swiperSlideSize + params.spaceBetween );
2476
2477 if ( params.watchSlidesVisibility || ( params.centeredSlides && params.autoHeight ) ) {
2478 var slideBefore = -( offsetCenter - slide.swiperSlideOffset );
2479 var slideAfter = slideBefore + swiper.slidesSizesGrid[ i ];
2480 var isVisible =
2481 ( slideBefore >= 0 && slideBefore < swiper.size - 1 ) ||
2482 ( slideAfter > 1 && slideAfter <= swiper.size ) ||
2483 ( slideBefore <= 0 && slideAfter >= swiper.size );
2484
2485 if ( isVisible ) {
2486 swiper.visibleSlides.push( slide );
2487 swiper.visibleSlidesIndexes.push( i );
2488 slides.eq( i ).addClass( params.slideVisibleClass );
2489 }
2490 }
2491
2492 slide.progress = rtl ? -slideProgress : slideProgress;
2493 }
2494
2495 swiper.visibleSlides = $( swiper.visibleSlides );
2496 }
2497
2498 function updateProgress( translate ) {
2499 var swiper = this;
2500
2501 if ( typeof translate === 'undefined' ) {
2502 var multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line
2503
2504 translate = ( swiper && swiper.translate && swiper.translate * multiplier ) || 0;
2505 }
2506
2507 var params = swiper.params;
2508 var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2509 var progress = swiper.progress,
2510 isBeginning = swiper.isBeginning,
2511 isEnd = swiper.isEnd;
2512 var wasBeginning = isBeginning;
2513 var wasEnd = isEnd;
2514
2515 if ( translatesDiff === 0 ) {
2516 progress = 0;
2517 isBeginning = true;
2518 isEnd = true;
2519 } else {
2520 progress = ( translate - swiper.minTranslate() ) / translatesDiff;
2521 isBeginning = progress <= 0;
2522 isEnd = progress >= 1;
2523 }
2524
2525 extend( swiper, {
2526 progress: progress,
2527 isBeginning: isBeginning,
2528 isEnd: isEnd,
2529 } );
2530 if (
2531 params.watchSlidesProgress ||
2532 params.watchSlidesVisibility ||
2533 ( params.centeredSlides && params.autoHeight )
2534 )
2535 swiper.updateSlidesProgress( translate );
2536
2537 if ( isBeginning && ! wasBeginning ) {
2538 swiper.emit( 'reachBeginning toEdge' );
2539 }
2540
2541 if ( isEnd && ! wasEnd ) {
2542 swiper.emit( 'reachEnd toEdge' );
2543 }
2544
2545 if ( ( wasBeginning && ! isBeginning ) || ( wasEnd && ! isEnd ) ) {
2546 swiper.emit( 'fromEdge' );
2547 }
2548
2549 swiper.emit( 'progress', progress );
2550 }
2551
2552 function updateSlidesClasses() {
2553 var swiper = this;
2554 var slides = swiper.slides,
2555 params = swiper.params,
2556 $wrapperEl = swiper.$wrapperEl,
2557 activeIndex = swiper.activeIndex,
2558 realIndex = swiper.realIndex;
2559 var isVirtual = swiper.virtual && params.virtual.enabled;
2560 slides.removeClass(
2561 params.slideActiveClass +
2562 ' ' +
2563 params.slideNextClass +
2564 ' ' +
2565 params.slidePrevClass +
2566 ' ' +
2567 params.slideDuplicateActiveClass +
2568 ' ' +
2569 params.slideDuplicateNextClass +
2570 ' ' +
2571 params.slideDuplicatePrevClass
2572 );
2573 var activeSlide;
2574
2575 if ( isVirtual ) {
2576 activeSlide = swiper.$wrapperEl.find(
2577 '.' + params.slideClass + '[data-swiper-slide-index="' + activeIndex + '"]'
2578 );
2579 } else {
2580 activeSlide = slides.eq( activeIndex );
2581 } // Active classes
2582
2583 activeSlide.addClass( params.slideActiveClass );
2584
2585 if ( params.loop ) {
2586 // Duplicate to all looped slides
2587 if ( activeSlide.hasClass( params.slideDuplicateClass ) ) {
2588 $wrapperEl
2589 .children(
2590 '.' +
2591 params.slideClass +
2592 ':not(.' +
2593 params.slideDuplicateClass +
2594 ')[data-swiper-slide-index="' +
2595 realIndex +
2596 '"]'
2597 )
2598 .addClass( params.slideDuplicateActiveClass );
2599 } else {
2600 $wrapperEl
2601 .children(
2602 '.' +
2603 params.slideClass +
2604 '.' +
2605 params.slideDuplicateClass +
2606 '[data-swiper-slide-index="' +
2607 realIndex +
2608 '"]'
2609 )
2610 .addClass( params.slideDuplicateActiveClass );
2611 }
2612 } // Next Slide
2613
2614 var nextSlide = activeSlide
2615 .nextAll( '.' + params.slideClass )
2616 .eq( 0 )
2617 .addClass( params.slideNextClass );
2618
2619 if ( params.loop && nextSlide.length === 0 ) {
2620 nextSlide = slides.eq( 0 );
2621 nextSlide.addClass( params.slideNextClass );
2622 } // Prev Slide
2623
2624 var prevSlide = activeSlide
2625 .prevAll( '.' + params.slideClass )
2626 .eq( 0 )
2627 .addClass( params.slidePrevClass );
2628
2629 if ( params.loop && prevSlide.length === 0 ) {
2630 prevSlide = slides.eq( -1 );
2631 prevSlide.addClass( params.slidePrevClass );
2632 }
2633
2634 if ( params.loop ) {
2635 // Duplicate to all looped slides
2636 if ( nextSlide.hasClass( params.slideDuplicateClass ) ) {
2637 $wrapperEl
2638 .children(
2639 '.' +
2640 params.slideClass +
2641 ':not(.' +
2642 params.slideDuplicateClass +
2643 ')[data-swiper-slide-index="' +
2644 nextSlide.attr( 'data-swiper-slide-index' ) +
2645 '"]'
2646 )
2647 .addClass( params.slideDuplicateNextClass );
2648 } else {
2649 $wrapperEl
2650 .children(
2651 '.' +
2652 params.slideClass +
2653 '.' +
2654 params.slideDuplicateClass +
2655 '[data-swiper-slide-index="' +
2656 nextSlide.attr( 'data-swiper-slide-index' ) +
2657 '"]'
2658 )
2659 .addClass( params.slideDuplicateNextClass );
2660 }
2661
2662 if ( prevSlide.hasClass( params.slideDuplicateClass ) ) {
2663 $wrapperEl
2664 .children(
2665 '.' +
2666 params.slideClass +
2667 ':not(.' +
2668 params.slideDuplicateClass +
2669 ')[data-swiper-slide-index="' +
2670 prevSlide.attr( 'data-swiper-slide-index' ) +
2671 '"]'
2672 )
2673 .addClass( params.slideDuplicatePrevClass );
2674 } else {
2675 $wrapperEl
2676 .children(
2677 '.' +
2678 params.slideClass +
2679 '.' +
2680 params.slideDuplicateClass +
2681 '[data-swiper-slide-index="' +
2682 prevSlide.attr( 'data-swiper-slide-index' ) +
2683 '"]'
2684 )
2685 .addClass( params.slideDuplicatePrevClass );
2686 }
2687 }
2688
2689 swiper.emitSlidesClasses();
2690 }
2691
2692 function updateActiveIndex( newActiveIndex ) {
2693 var swiper = this;
2694 var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
2695 var slidesGrid = swiper.slidesGrid,
2696 snapGrid = swiper.snapGrid,
2697 params = swiper.params,
2698 previousIndex = swiper.activeIndex,
2699 previousRealIndex = swiper.realIndex,
2700 previousSnapIndex = swiper.snapIndex;
2701 var activeIndex = newActiveIndex;
2702 var snapIndex;
2703
2704 if ( typeof activeIndex === 'undefined' ) {
2705 for ( var i = 0; i < slidesGrid.length; i += 1 ) {
2706 if ( typeof slidesGrid[ i + 1 ] !== 'undefined' ) {
2707 if (
2708 translate >= slidesGrid[ i ] &&
2709 translate < slidesGrid[ i + 1 ] - ( slidesGrid[ i + 1 ] - slidesGrid[ i ] ) / 2
2710 ) {
2711 activeIndex = i;
2712 } else if ( translate >= slidesGrid[ i ] && translate < slidesGrid[ i + 1 ] ) {
2713 activeIndex = i + 1;
2714 }
2715 } else if ( translate >= slidesGrid[ i ] ) {
2716 activeIndex = i;
2717 }
2718 } // Normalize slideIndex
2719
2720 if ( params.normalizeSlideIndex ) {
2721 if ( activeIndex < 0 || typeof activeIndex === 'undefined' ) activeIndex = 0;
2722 }
2723 }
2724
2725 if ( snapGrid.indexOf( translate ) >= 0 ) {
2726 snapIndex = snapGrid.indexOf( translate );
2727 } else {
2728 var skip = Math.min( params.slidesPerGroupSkip, activeIndex );
2729 snapIndex = skip + Math.floor( ( activeIndex - skip ) / params.slidesPerGroup );
2730 }
2731
2732 if ( snapIndex >= snapGrid.length ) snapIndex = snapGrid.length - 1;
2733
2734 if ( activeIndex === previousIndex ) {
2735 if ( snapIndex !== previousSnapIndex ) {
2736 swiper.snapIndex = snapIndex;
2737 swiper.emit( 'snapIndexChange' );
2738 }
2739
2740 return;
2741 } // Get real index
2742
2743 var realIndex = parseInt(
2744 swiper.slides.eq( activeIndex ).attr( 'data-swiper-slide-index' ) || activeIndex,
2745 10
2746 );
2747 extend( swiper, {
2748 snapIndex: snapIndex,
2749 realIndex: realIndex,
2750 previousIndex: previousIndex,
2751 activeIndex: activeIndex,
2752 } );
2753 swiper.emit( 'activeIndexChange' );
2754 swiper.emit( 'snapIndexChange' );
2755
2756 if ( previousRealIndex !== realIndex ) {
2757 swiper.emit( 'realIndexChange' );
2758 }
2759
2760 if ( swiper.initialized || swiper.params.runCallbacksOnInit ) {
2761 swiper.emit( 'slideChange' );
2762 }
2763 }
2764
2765 function updateClickedSlide( e ) {
2766 var swiper = this;
2767 var params = swiper.params;
2768 var slide = $( e.target ).closest( '.' + params.slideClass )[ 0 ];
2769 var slideFound = false;
2770 var slideIndex;
2771
2772 if ( slide ) {
2773 for ( var i = 0; i < swiper.slides.length; i += 1 ) {
2774 if ( swiper.slides[ i ] === slide ) {
2775 slideFound = true;
2776 slideIndex = i;
2777 break;
2778 }
2779 }
2780 }
2781
2782 if ( slide && slideFound ) {
2783 swiper.clickedSlide = slide;
2784
2785 if ( swiper.virtual && swiper.params.virtual.enabled ) {
2786 swiper.clickedIndex = parseInt( $( slide ).attr( 'data-swiper-slide-index' ), 10 );
2787 } else {
2788 swiper.clickedIndex = slideIndex;
2789 }
2790 } else {
2791 swiper.clickedSlide = undefined;
2792 swiper.clickedIndex = undefined;
2793 return;
2794 }
2795
2796 if (
2797 params.slideToClickedSlide &&
2798 swiper.clickedIndex !== undefined &&
2799 swiper.clickedIndex !== swiper.activeIndex
2800 ) {
2801 swiper.slideToClickedSlide();
2802 }
2803 }
2804
2805 var update = {
2806 updateSize: updateSize,
2807 updateSlides: updateSlides,
2808 updateAutoHeight: updateAutoHeight,
2809 updateSlidesOffset: updateSlidesOffset,
2810 updateSlidesProgress: updateSlidesProgress,
2811 updateProgress: updateProgress,
2812 updateSlidesClasses: updateSlidesClasses,
2813 updateActiveIndex: updateActiveIndex,
2814 updateClickedSlide: updateClickedSlide,
2815 };
2816
2817 function getSwiperTranslate( axis ) {
2818 if ( axis === void 0 ) {
2819 axis = this.isHorizontal() ? 'x' : 'y';
2820 }
2821
2822 var swiper = this;
2823 var params = swiper.params,
2824 rtl = swiper.rtlTranslate,
2825 translate = swiper.translate,
2826 $wrapperEl = swiper.$wrapperEl;
2827
2828 if ( params.virtualTranslate ) {
2829 return rtl ? -translate : translate;
2830 }
2831
2832 if ( params.cssMode ) {
2833 return translate;
2834 }
2835
2836 var currentTranslate = getTranslate( $wrapperEl[ 0 ], axis );
2837 if ( rtl ) currentTranslate = -currentTranslate;
2838 return currentTranslate || 0;
2839 }
2840
2841 function setTranslate( translate, byController ) {
2842 var swiper = this;
2843 var rtl = swiper.rtlTranslate,
2844 params = swiper.params,
2845 $wrapperEl = swiper.$wrapperEl,
2846 wrapperEl = swiper.wrapperEl,
2847 progress = swiper.progress;
2848 var x = 0;
2849 var y = 0;
2850 var z = 0;
2851
2852 if ( swiper.isHorizontal() ) {
2853 x = rtl ? -translate : translate;
2854 } else {
2855 y = translate;
2856 }
2857
2858 if ( params.roundLengths ) {
2859 x = Math.floor( x );
2860 y = Math.floor( y );
2861 }
2862
2863 if ( params.cssMode ) {
2864 wrapperEl[ swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop' ] = swiper.isHorizontal()
2865 ? -x
2866 : -y;
2867 } else if ( ! params.virtualTranslate ) {
2868 $wrapperEl.transform( 'translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)' );
2869 }
2870
2871 swiper.previousTranslate = swiper.translate;
2872 swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress
2873
2874 var newProgress;
2875 var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2876
2877 if ( translatesDiff === 0 ) {
2878 newProgress = 0;
2879 } else {
2880 newProgress = ( translate - swiper.minTranslate() ) / translatesDiff;
2881 }
2882
2883 if ( newProgress !== progress ) {
2884 swiper.updateProgress( translate );
2885 }
2886
2887 swiper.emit( 'setTranslate', swiper.translate, byController );
2888 }
2889
2890 function minTranslate() {
2891 return -this.snapGrid[ 0 ];
2892 }
2893
2894 function maxTranslate() {
2895 return -this.snapGrid[ this.snapGrid.length - 1 ];
2896 }
2897
2898 function translateTo( translate, speed, runCallbacks, translateBounds, internal ) {
2899 if ( translate === void 0 ) {
2900 translate = 0;
2901 }
2902
2903 if ( speed === void 0 ) {
2904 speed = this.params.speed;
2905 }
2906
2907 if ( runCallbacks === void 0 ) {
2908 runCallbacks = true;
2909 }
2910
2911 if ( translateBounds === void 0 ) {
2912 translateBounds = true;
2913 }
2914
2915 var swiper = this;
2916 var params = swiper.params,
2917 wrapperEl = swiper.wrapperEl;
2918
2919 if ( swiper.animating && params.preventInteractionOnTransition ) {
2920 return false;
2921 }
2922
2923 var minTranslate = swiper.minTranslate();
2924 var maxTranslate = swiper.maxTranslate();
2925 var newTranslate;
2926 if ( translateBounds && translate > minTranslate ) newTranslate = minTranslate;
2927 else if ( translateBounds && translate < maxTranslate ) newTranslate = maxTranslate;
2928 else newTranslate = translate; // Update progress
2929
2930 swiper.updateProgress( newTranslate );
2931
2932 if ( params.cssMode ) {
2933 var isH = swiper.isHorizontal();
2934
2935 if ( speed === 0 ) {
2936 wrapperEl[ isH ? 'scrollLeft' : 'scrollTop' ] = -newTranslate;
2937 } else {
2938 // eslint-disable-next-line
2939 if ( wrapperEl.scrollTo ) {
2940 var _wrapperEl$scrollTo;
2941
2942 wrapperEl.scrollTo(
2943 ( ( _wrapperEl$scrollTo = {} ),
2944 ( _wrapperEl$scrollTo[ isH ? 'left' : 'top' ] = -newTranslate ),
2945 ( _wrapperEl$scrollTo.behavior = 'smooth' ),
2946 _wrapperEl$scrollTo )
2947 );
2948 } else {
2949 wrapperEl[ isH ? 'scrollLeft' : 'scrollTop' ] = -newTranslate;
2950 }
2951 }
2952
2953 return true;
2954 }
2955
2956 if ( speed === 0 ) {
2957 swiper.setTransition( 0 );
2958 swiper.setTranslate( newTranslate );
2959
2960 if ( runCallbacks ) {
2961 swiper.emit( 'beforeTransitionStart', speed, internal );
2962 swiper.emit( 'transitionEnd' );
2963 }
2964 } else {
2965 swiper.setTransition( speed );
2966 swiper.setTranslate( newTranslate );
2967
2968 if ( runCallbacks ) {
2969 swiper.emit( 'beforeTransitionStart', speed, internal );
2970 swiper.emit( 'transitionStart' );
2971 }
2972
2973 if ( ! swiper.animating ) {
2974 swiper.animating = true;
2975
2976 if ( ! swiper.onTranslateToWrapperTransitionEnd ) {
2977 swiper.onTranslateToWrapperTransitionEnd = function transitionEnd( e ) {
2978 if ( ! swiper || swiper.destroyed ) return;
2979 if ( e.target !== this ) return;
2980 swiper.$wrapperEl[ 0 ].removeEventListener(
2981 'transitionend',
2982 swiper.onTranslateToWrapperTransitionEnd
2983 );
2984 swiper.$wrapperEl[ 0 ].removeEventListener(
2985 'webkitTransitionEnd',
2986 swiper.onTranslateToWrapperTransitionEnd
2987 );
2988 swiper.onTranslateToWrapperTransitionEnd = null;
2989 delete swiper.onTranslateToWrapperTransitionEnd;
2990
2991 if ( runCallbacks ) {
2992 swiper.emit( 'transitionEnd' );
2993 }
2994 };
2995 }
2996
2997 swiper.$wrapperEl[ 0 ].addEventListener(
2998 'transitionend',
2999 swiper.onTranslateToWrapperTransitionEnd
3000 );
3001 swiper.$wrapperEl[ 0 ].addEventListener(
3002 'webkitTransitionEnd',
3003 swiper.onTranslateToWrapperTransitionEnd
3004 );
3005 }
3006 }
3007
3008 return true;
3009 }
3010
3011 var translate = {
3012 getTranslate: getSwiperTranslate,
3013 setTranslate: setTranslate,
3014 minTranslate: minTranslate,
3015 maxTranslate: maxTranslate,
3016 translateTo: translateTo,
3017 };
3018
3019 function setTransition( duration, byController ) {
3020 var swiper = this;
3021
3022 if ( ! swiper.params.cssMode ) {
3023 swiper.$wrapperEl.transition( duration );
3024 }
3025
3026 swiper.emit( 'setTransition', duration, byController );
3027 }
3028
3029 function transitionStart( runCallbacks, direction ) {
3030 if ( runCallbacks === void 0 ) {
3031 runCallbacks = true;
3032 }
3033
3034 var swiper = this;
3035 var activeIndex = swiper.activeIndex,
3036 params = swiper.params,
3037 previousIndex = swiper.previousIndex;
3038 if ( params.cssMode ) return;
3039
3040 if ( params.autoHeight ) {
3041 swiper.updateAutoHeight();
3042 }
3043
3044 var dir = direction;
3045
3046 if ( ! dir ) {
3047 if ( activeIndex > previousIndex ) dir = 'next';
3048 else if ( activeIndex < previousIndex ) dir = 'prev';
3049 else dir = 'reset';
3050 }
3051
3052 swiper.emit( 'transitionStart' );
3053
3054 if ( runCallbacks && activeIndex !== previousIndex ) {
3055 if ( dir === 'reset' ) {
3056 swiper.emit( 'slideResetTransitionStart' );
3057 return;
3058 }
3059
3060 swiper.emit( 'slideChangeTransitionStart' );
3061
3062 if ( dir === 'next' ) {
3063 swiper.emit( 'slideNextTransitionStart' );
3064 } else {
3065 swiper.emit( 'slidePrevTransitionStart' );
3066 }
3067 }
3068 }
3069
3070 function transitionEnd( runCallbacks, direction ) {
3071 if ( runCallbacks === void 0 ) {
3072 runCallbacks = true;
3073 }
3074
3075 var swiper = this;
3076 var activeIndex = swiper.activeIndex,
3077 previousIndex = swiper.previousIndex,
3078 params = swiper.params;
3079 swiper.animating = false;
3080 if ( params.cssMode ) return;
3081 swiper.setTransition( 0 );
3082 var dir = direction;
3083
3084 if ( ! dir ) {
3085 if ( activeIndex > previousIndex ) dir = 'next';
3086 else if ( activeIndex < previousIndex ) dir = 'prev';
3087 else dir = 'reset';
3088 }
3089
3090 swiper.emit( 'transitionEnd' );
3091
3092 if ( runCallbacks && activeIndex !== previousIndex ) {
3093 if ( dir === 'reset' ) {
3094 swiper.emit( 'slideResetTransitionEnd' );
3095 return;
3096 }
3097
3098 swiper.emit( 'slideChangeTransitionEnd' );
3099
3100 if ( dir === 'next' ) {
3101 swiper.emit( 'slideNextTransitionEnd' );
3102 } else {
3103 swiper.emit( 'slidePrevTransitionEnd' );
3104 }
3105 }
3106 }
3107
3108 var transition = {
3109 setTransition: setTransition,
3110 transitionStart: transitionStart,
3111 transitionEnd: transitionEnd,
3112 };
3113
3114 function slideTo( index, speed, runCallbacks, internal, initial ) {
3115 if ( index === void 0 ) {
3116 index = 0;
3117 }
3118
3119 if ( speed === void 0 ) {
3120 speed = this.params.speed;
3121 }
3122
3123 if ( runCallbacks === void 0 ) {
3124 runCallbacks = true;
3125 }
3126
3127 if ( typeof index !== 'number' && typeof index !== 'string' ) {
3128 throw new Error(
3129 "The 'index' argument cannot have type other than 'number' or 'string'. [" +
3130 typeof index +
3131 '] given.'
3132 );
3133 }
3134
3135 if ( typeof index === 'string' ) {
3136 /**
3137 * The `index` argument converted from `string` to `number`.
3138 * @type {number}
3139 */
3140 var indexAsNumber = parseInt( index, 10 );
3141 /**
3142 * Determines whether the `index` argument is a valid `number`
3143 * after being converted from the `string` type.
3144 * @type {boolean}
3145 */
3146
3147 var isValidNumber = isFinite( indexAsNumber );
3148
3149 if ( ! isValidNumber ) {
3150 throw new Error(
3151 "The passed-in 'index' (string) couldn't be converted to 'number'. [" + index + '] given.'
3152 );
3153 } // Knowing that the converted `index` is a valid number,
3154 // we can update the original argument's value.
3155
3156 index = indexAsNumber;
3157 }
3158
3159 var swiper = this;
3160 var slideIndex = index;
3161 if ( slideIndex < 0 ) slideIndex = 0;
3162 var params = swiper.params,
3163 snapGrid = swiper.snapGrid,
3164 slidesGrid = swiper.slidesGrid,
3165 previousIndex = swiper.previousIndex,
3166 activeIndex = swiper.activeIndex,
3167 rtl = swiper.rtlTranslate,
3168 wrapperEl = swiper.wrapperEl,
3169 enabled = swiper.enabled;
3170
3171 if (
3172 ( swiper.animating && params.preventInteractionOnTransition ) ||
3173 ( ! enabled && ! internal && ! initial )
3174 ) {
3175 return false;
3176 }
3177
3178 var skip = Math.min( swiper.params.slidesPerGroupSkip, slideIndex );
3179 var snapIndex = skip + Math.floor( ( slideIndex - skip ) / swiper.params.slidesPerGroup );
3180 if ( snapIndex >= snapGrid.length ) snapIndex = snapGrid.length - 1;
3181
3182 if ( ( activeIndex || params.initialSlide || 0 ) === ( previousIndex || 0 ) && runCallbacks ) {
3183 swiper.emit( 'beforeSlideChangeStart' );
3184 }
3185
3186 var translate = -snapGrid[ snapIndex ]; // Update progress
3187
3188 swiper.updateProgress( translate ); // Normalize slideIndex
3189
3190 if ( params.normalizeSlideIndex ) {
3191 for ( var i = 0; i < slidesGrid.length; i += 1 ) {
3192 var normalizedTranslate = -Math.floor( translate * 100 );
3193 var normalizedGird = Math.floor( slidesGrid[ i ] * 100 );
3194 var normalizedGridNext = Math.floor( slidesGrid[ i + 1 ] * 100 );
3195
3196 if ( typeof slidesGrid[ i + 1 ] !== 'undefined' ) {
3197 if (
3198 normalizedTranslate >= normalizedGird &&
3199 normalizedTranslate < normalizedGridNext - ( normalizedGridNext - normalizedGird ) / 2
3200 ) {
3201 slideIndex = i;
3202 } else if (
3203 normalizedTranslate >= normalizedGird &&
3204 normalizedTranslate < normalizedGridNext
3205 ) {
3206 slideIndex = i + 1;
3207 }
3208 } else if ( normalizedTranslate >= normalizedGird ) {
3209 slideIndex = i;
3210 }
3211 }
3212 } // Directions locks
3213
3214 if ( swiper.initialized && slideIndex !== activeIndex ) {
3215 if (
3216 ! swiper.allowSlideNext &&
3217 translate < swiper.translate &&
3218 translate < swiper.minTranslate()
3219 ) {
3220 return false;
3221 }
3222
3223 if (
3224 ! swiper.allowSlidePrev &&
3225 translate > swiper.translate &&
3226 translate > swiper.maxTranslate()
3227 ) {
3228 if ( ( activeIndex || 0 ) !== slideIndex ) return false;
3229 }
3230 }
3231
3232 var direction;
3233 if ( slideIndex > activeIndex ) direction = 'next';
3234 else if ( slideIndex < activeIndex ) direction = 'prev';
3235 else direction = 'reset'; // Update Index
3236
3237 if (
3238 ( rtl && -translate === swiper.translate ) ||
3239 ( ! rtl && translate === swiper.translate )
3240 ) {
3241 swiper.updateActiveIndex( slideIndex ); // Update Height
3242
3243 if ( params.autoHeight ) {
3244 swiper.updateAutoHeight();
3245 }
3246
3247 swiper.updateSlidesClasses();
3248
3249 if ( params.effect !== 'slide' ) {
3250 swiper.setTranslate( translate );
3251 }
3252
3253 if ( direction !== 'reset' ) {
3254 swiper.transitionStart( runCallbacks, direction );
3255 swiper.transitionEnd( runCallbacks, direction );
3256 }
3257
3258 return false;
3259 }
3260
3261 if ( params.cssMode ) {
3262 var isH = swiper.isHorizontal();
3263 var t = -translate;
3264
3265 if ( rtl ) {
3266 t = wrapperEl.scrollWidth - wrapperEl.offsetWidth - t;
3267 }
3268
3269 if ( speed === 0 ) {
3270 wrapperEl[ isH ? 'scrollLeft' : 'scrollTop' ] = t;
3271 } else {
3272 // eslint-disable-next-line
3273 if ( wrapperEl.scrollTo ) {
3274 var _wrapperEl$scrollTo;
3275
3276 wrapperEl.scrollTo(
3277 ( ( _wrapperEl$scrollTo = {} ),
3278 ( _wrapperEl$scrollTo[ isH ? 'left' : 'top' ] = t ),
3279 ( _wrapperEl$scrollTo.behavior = 'smooth' ),
3280 _wrapperEl$scrollTo )
3281 );
3282 } else {
3283 wrapperEl[ isH ? 'scrollLeft' : 'scrollTop' ] = t;
3284 }
3285 }
3286
3287 return true;
3288 }
3289
3290 if ( speed === 0 ) {
3291 swiper.setTransition( 0 );
3292 swiper.setTranslate( translate );
3293 swiper.updateActiveIndex( slideIndex );
3294 swiper.updateSlidesClasses();
3295 swiper.emit( 'beforeTransitionStart', speed, internal );
3296 swiper.transitionStart( runCallbacks, direction );
3297 swiper.transitionEnd( runCallbacks, direction );
3298 } else {
3299 swiper.setTransition( speed );
3300 swiper.setTranslate( translate );
3301 swiper.updateActiveIndex( slideIndex );
3302 swiper.updateSlidesClasses();
3303 swiper.emit( 'beforeTransitionStart', speed, internal );
3304 swiper.transitionStart( runCallbacks, direction );
3305
3306 if ( ! swiper.animating ) {
3307 swiper.animating = true;
3308
3309 if ( ! swiper.onSlideToWrapperTransitionEnd ) {
3310 swiper.onSlideToWrapperTransitionEnd = function transitionEnd( e ) {
3311 if ( ! swiper || swiper.destroyed ) return;
3312 if ( e.target !== this ) return;
3313 swiper.$wrapperEl[ 0 ].removeEventListener(
3314 'transitionend',
3315 swiper.onSlideToWrapperTransitionEnd
3316 );
3317 swiper.$wrapperEl[ 0 ].removeEventListener(
3318 'webkitTransitionEnd',
3319 swiper.onSlideToWrapperTransitionEnd
3320 );
3321 swiper.onSlideToWrapperTransitionEnd = null;
3322 delete swiper.onSlideToWrapperTransitionEnd;
3323 swiper.transitionEnd( runCallbacks, direction );
3324 };
3325 }
3326
3327 swiper.$wrapperEl[ 0 ].addEventListener(
3328 'transitionend',
3329 swiper.onSlideToWrapperTransitionEnd
3330 );
3331 swiper.$wrapperEl[ 0 ].addEventListener(
3332 'webkitTransitionEnd',
3333 swiper.onSlideToWrapperTransitionEnd
3334 );
3335 }
3336 }
3337
3338 return true;
3339 }
3340
3341 function slideToLoop( index, speed, runCallbacks, internal ) {
3342 if ( index === void 0 ) {
3343 index = 0;
3344 }
3345
3346 if ( speed === void 0 ) {
3347 speed = this.params.speed;
3348 }
3349
3350 if ( runCallbacks === void 0 ) {
3351 runCallbacks = true;
3352 }
3353
3354 var swiper = this;
3355 var newIndex = index;
3356
3357 if ( swiper.params.loop ) {
3358 newIndex += swiper.loopedSlides;
3359 }
3360
3361 return swiper.slideTo( newIndex, speed, runCallbacks, internal );
3362 }
3363
3364 /* eslint no-unused-vars: "off" */
3365 function slideNext( speed, runCallbacks, internal ) {
3366 if ( speed === void 0 ) {
3367 speed = this.params.speed;
3368 }
3369
3370 if ( runCallbacks === void 0 ) {
3371 runCallbacks = true;
3372 }
3373
3374 var swiper = this;
3375 var params = swiper.params,
3376 animating = swiper.animating,
3377 enabled = swiper.enabled;
3378 if ( ! enabled ) return swiper;
3379 var increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup;
3380
3381 if ( params.loop ) {
3382 if ( animating && params.loopPreventsSlide ) return false;
3383 swiper.loopFix(); // eslint-disable-next-line
3384
3385 swiper._clientLeft = swiper.$wrapperEl[ 0 ].clientLeft;
3386 }
3387
3388 return swiper.slideTo( swiper.activeIndex + increment, speed, runCallbacks, internal );
3389 }
3390
3391 /* eslint no-unused-vars: "off" */
3392 function slidePrev( speed, runCallbacks, internal ) {
3393 if ( speed === void 0 ) {
3394 speed = this.params.speed;
3395 }
3396
3397 if ( runCallbacks === void 0 ) {
3398 runCallbacks = true;
3399 }
3400
3401 var swiper = this;
3402 var params = swiper.params,
3403 animating = swiper.animating,
3404 snapGrid = swiper.snapGrid,
3405 slidesGrid = swiper.slidesGrid,
3406 rtlTranslate = swiper.rtlTranslate,
3407 enabled = swiper.enabled;
3408 if ( ! enabled ) return swiper;
3409
3410 if ( params.loop ) {
3411 if ( animating && params.loopPreventsSlide ) return false;
3412 swiper.loopFix(); // eslint-disable-next-line
3413
3414 swiper._clientLeft = swiper.$wrapperEl[ 0 ].clientLeft;
3415 }
3416
3417 var translate = rtlTranslate ? swiper.translate : -swiper.translate;
3418
3419 function normalize( val ) {
3420 if ( val < 0 ) return -Math.floor( Math.abs( val ) );
3421 return Math.floor( val );
3422 }
3423
3424 var normalizedTranslate = normalize( translate );
3425 var normalizedSnapGrid = snapGrid.map( function ( val ) {
3426 return normalize( val );
3427 } );
3428 var prevSnap = snapGrid[ normalizedSnapGrid.indexOf( normalizedTranslate ) - 1 ];
3429
3430 if ( typeof prevSnap === 'undefined' && params.cssMode ) {
3431 snapGrid.forEach( function ( snap ) {
3432 if ( ! prevSnap && normalizedTranslate >= snap ) prevSnap = snap;
3433 } );
3434 }
3435
3436 var prevIndex;
3437
3438 if ( typeof prevSnap !== 'undefined' ) {
3439 prevIndex = slidesGrid.indexOf( prevSnap );
3440 if ( prevIndex < 0 ) prevIndex = swiper.activeIndex - 1;
3441 }
3442
3443 return swiper.slideTo( prevIndex, speed, runCallbacks, internal );
3444 }
3445
3446 /* eslint no-unused-vars: "off" */
3447 function slideReset( speed, runCallbacks, internal ) {
3448 if ( speed === void 0 ) {
3449 speed = this.params.speed;
3450 }
3451
3452 if ( runCallbacks === void 0 ) {
3453 runCallbacks = true;
3454 }
3455
3456 var swiper = this;
3457 return swiper.slideTo( swiper.activeIndex, speed, runCallbacks, internal );
3458 }
3459
3460 /* eslint no-unused-vars: "off" */
3461 function slideToClosest( speed, runCallbacks, internal, threshold ) {
3462 if ( speed === void 0 ) {
3463 speed = this.params.speed;
3464 }
3465
3466 if ( runCallbacks === void 0 ) {
3467 runCallbacks = true;
3468 }
3469
3470 if ( threshold === void 0 ) {
3471 threshold = 0.5;
3472 }
3473
3474 var swiper = this;
3475 var index = swiper.activeIndex;
3476 var skip = Math.min( swiper.params.slidesPerGroupSkip, index );
3477 var snapIndex = skip + Math.floor( ( index - skip ) / swiper.params.slidesPerGroup );
3478 var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
3479
3480 if ( translate >= swiper.snapGrid[ snapIndex ] ) {
3481 // The current translate is on or after the current snap index, so the choice
3482 // is between the current index and the one after it.
3483 var currentSnap = swiper.snapGrid[ snapIndex ];
3484 var nextSnap = swiper.snapGrid[ snapIndex + 1 ];
3485
3486 if ( translate - currentSnap > ( nextSnap - currentSnap ) * threshold ) {
3487 index += swiper.params.slidesPerGroup;
3488 }
3489 } else {
3490 // The current translate is before the current snap index, so the choice
3491 // is between the current index and the one before it.
3492 var prevSnap = swiper.snapGrid[ snapIndex - 1 ];
3493 var _currentSnap = swiper.snapGrid[ snapIndex ];
3494
3495 if ( translate - prevSnap <= ( _currentSnap - prevSnap ) * threshold ) {
3496 index -= swiper.params.slidesPerGroup;
3497 }
3498 }
3499
3500 index = Math.max( index, 0 );
3501 index = Math.min( index, swiper.slidesGrid.length - 1 );
3502 return swiper.slideTo( index, speed, runCallbacks, internal );
3503 }
3504
3505 function slideToClickedSlide() {
3506 var swiper = this;
3507 var params = swiper.params,
3508 $wrapperEl = swiper.$wrapperEl;
3509 var slidesPerView =
3510 params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
3511 var slideToIndex = swiper.clickedIndex;
3512 var realIndex;
3513
3514 if ( params.loop ) {
3515 if ( swiper.animating ) return;
3516 realIndex = parseInt( $( swiper.clickedSlide ).attr( 'data-swiper-slide-index' ), 10 );
3517
3518 if ( params.centeredSlides ) {
3519 if (
3520 slideToIndex < swiper.loopedSlides - slidesPerView / 2 ||
3521 slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2
3522 ) {
3523 swiper.loopFix();
3524 slideToIndex = $wrapperEl
3525 .children(
3526 '.' +
3527 params.slideClass +
3528 '[data-swiper-slide-index="' +
3529 realIndex +
3530 '"]:not(.' +
3531 params.slideDuplicateClass +
3532 ')'
3533 )
3534 .eq( 0 )
3535 .index();
3536 nextTick( function () {
3537 swiper.slideTo( slideToIndex );
3538 } );
3539 } else {
3540 swiper.slideTo( slideToIndex );
3541 }
3542 } else if ( slideToIndex > swiper.slides.length - slidesPerView ) {
3543 swiper.loopFix();
3544 slideToIndex = $wrapperEl
3545 .children(
3546 '.' +
3547 params.slideClass +
3548 '[data-swiper-slide-index="' +
3549 realIndex +
3550 '"]:not(.' +
3551 params.slideDuplicateClass +
3552 ')'
3553 )
3554 .eq( 0 )
3555 .index();
3556 nextTick( function () {
3557 swiper.slideTo( slideToIndex );
3558 } );
3559 } else {
3560 swiper.slideTo( slideToIndex );
3561 }
3562 } else {
3563 swiper.slideTo( slideToIndex );
3564 }
3565 }
3566
3567 var slide = {
3568 slideTo: slideTo,
3569 slideToLoop: slideToLoop,
3570 slideNext: slideNext,
3571 slidePrev: slidePrev,
3572 slideReset: slideReset,
3573 slideToClosest: slideToClosest,
3574 slideToClickedSlide: slideToClickedSlide,
3575 };
3576
3577 function loopCreate() {
3578 var swiper = this;
3579 var document = getDocument();
3580 var params = swiper.params,
3581 $wrapperEl = swiper.$wrapperEl; // Remove duplicated slides
3582
3583 $wrapperEl.children( '.' + params.slideClass + '.' + params.slideDuplicateClass ).remove();
3584 var slides = $wrapperEl.children( '.' + params.slideClass );
3585
3586 if ( params.loopFillGroupWithBlank ) {
3587 var blankSlidesNum = params.slidesPerGroup - ( slides.length % params.slidesPerGroup );
3588
3589 if ( blankSlidesNum !== params.slidesPerGroup ) {
3590 for ( var i = 0; i < blankSlidesNum; i += 1 ) {
3591 var blankNode = $( document.createElement( 'div' ) ).addClass(
3592 params.slideClass + ' ' + params.slideBlankClass
3593 );
3594 $wrapperEl.append( blankNode );
3595 }
3596
3597 slides = $wrapperEl.children( '.' + params.slideClass );
3598 }
3599 }
3600
3601 if ( params.slidesPerView === 'auto' && ! params.loopedSlides )
3602 params.loopedSlides = slides.length;
3603 swiper.loopedSlides = Math.ceil(
3604 parseFloat( params.loopedSlides || params.slidesPerView, 10 )
3605 );
3606 swiper.loopedSlides += params.loopAdditionalSlides;
3607
3608 if ( swiper.loopedSlides > slides.length ) {
3609 swiper.loopedSlides = slides.length;
3610 }
3611
3612 var prependSlides = [];
3613 var appendSlides = [];
3614 slides.each( function ( el, index ) {
3615 var slide = $( el );
3616
3617 if ( index < swiper.loopedSlides ) {
3618 appendSlides.push( el );
3619 }
3620
3621 if ( index < slides.length && index >= slides.length - swiper.loopedSlides ) {
3622 prependSlides.push( el );
3623 }
3624
3625 slide.attr( 'data-swiper-slide-index', index );
3626 } );
3627
3628 for ( var _i = 0; _i < appendSlides.length; _i += 1 ) {
3629 $wrapperEl.append(
3630 $( appendSlides[ _i ].cloneNode( true ) ).addClass( params.slideDuplicateClass )
3631 );
3632 }
3633
3634 for ( var _i2 = prependSlides.length - 1; _i2 >= 0; _i2 -= 1 ) {
3635 $wrapperEl.prepend(
3636 $( prependSlides[ _i2 ].cloneNode( true ) ).addClass( params.slideDuplicateClass )
3637 );
3638 }
3639 }
3640
3641 function loopFix() {
3642 var swiper = this;
3643 swiper.emit( 'beforeLoopFix' );
3644 var activeIndex = swiper.activeIndex,
3645 slides = swiper.slides,
3646 loopedSlides = swiper.loopedSlides,
3647 allowSlidePrev = swiper.allowSlidePrev,
3648 allowSlideNext = swiper.allowSlideNext,
3649 snapGrid = swiper.snapGrid,
3650 rtl = swiper.rtlTranslate;
3651 var newIndex;
3652 swiper.allowSlidePrev = true;
3653 swiper.allowSlideNext = true;
3654 var snapTranslate = -snapGrid[ activeIndex ];
3655 var diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding
3656
3657 if ( activeIndex < loopedSlides ) {
3658 newIndex = slides.length - loopedSlides * 3 + activeIndex;
3659 newIndex += loopedSlides;
3660 var slideChanged = swiper.slideTo( newIndex, 0, false, true );
3661
3662 if ( slideChanged && diff !== 0 ) {
3663 swiper.setTranslate( ( rtl ? -swiper.translate : swiper.translate ) - diff );
3664 }
3665 } else if ( activeIndex >= slides.length - loopedSlides ) {
3666 // Fix For Positive Oversliding
3667 newIndex = -slides.length + activeIndex + loopedSlides;
3668 newIndex += loopedSlides;
3669
3670 var _slideChanged = swiper.slideTo( newIndex, 0, false, true );
3671
3672 if ( _slideChanged && diff !== 0 ) {
3673 swiper.setTranslate( ( rtl ? -swiper.translate : swiper.translate ) - diff );
3674 }
3675 }
3676
3677 swiper.allowSlidePrev = allowSlidePrev;
3678 swiper.allowSlideNext = allowSlideNext;
3679 swiper.emit( 'loopFix' );
3680 }
3681
3682 function loopDestroy() {
3683 var swiper = this;
3684 var $wrapperEl = swiper.$wrapperEl,
3685 params = swiper.params,
3686 slides = swiper.slides;
3687 $wrapperEl
3688 .children(
3689 '.' +
3690 params.slideClass +
3691 '.' +
3692 params.slideDuplicateClass +
3693 ',.' +
3694 params.slideClass +
3695 '.' +
3696 params.slideBlankClass
3697 )
3698 .remove();
3699 slides.removeAttr( 'data-swiper-slide-index' );
3700 }
3701
3702 var loop = {
3703 loopCreate: loopCreate,
3704 loopFix: loopFix,
3705 loopDestroy: loopDestroy,
3706 };
3707
3708 function setGrabCursor( moving ) {
3709 var swiper = this;
3710 if (
3711 swiper.support.touch ||
3712 ! swiper.params.simulateTouch ||
3713 ( swiper.params.watchOverflow && swiper.isLocked ) ||
3714 swiper.params.cssMode
3715 )
3716 return;
3717 var el = swiper.el;
3718 el.style.cursor = 'move';
3719 el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab';
3720 el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab';
3721 el.style.cursor = moving ? 'grabbing' : 'grab';
3722 }
3723
3724 function unsetGrabCursor() {
3725 var swiper = this;
3726
3727 if (
3728 swiper.support.touch ||
3729 ( swiper.params.watchOverflow && swiper.isLocked ) ||
3730 swiper.params.cssMode
3731 ) {
3732 return;
3733 }
3734
3735 swiper.el.style.cursor = '';
3736 }
3737
3738 var grabCursor = {
3739 setGrabCursor: setGrabCursor,
3740 unsetGrabCursor: unsetGrabCursor,
3741 };
3742
3743 function appendSlide( slides ) {
3744 var swiper = this;
3745 var $wrapperEl = swiper.$wrapperEl,
3746 params = swiper.params;
3747
3748 if ( params.loop ) {
3749 swiper.loopDestroy();
3750 }
3751
3752 if ( typeof slides === 'object' && 'length' in slides ) {
3753 for ( var i = 0; i < slides.length; i += 1 ) {
3754 if ( slides[ i ] ) $wrapperEl.append( slides[ i ] );
3755 }
3756 } else {
3757 $wrapperEl.append( slides );
3758 }
3759
3760 if ( params.loop ) {
3761 swiper.loopCreate();
3762 }
3763
3764 if ( ! ( params.observer && swiper.support.observer ) ) {
3765 swiper.update();
3766 }
3767 }
3768
3769 function prependSlide( slides ) {
3770 var swiper = this;
3771 var params = swiper.params,
3772 $wrapperEl = swiper.$wrapperEl,
3773 activeIndex = swiper.activeIndex;
3774
3775 if ( params.loop ) {
3776 swiper.loopDestroy();
3777 }
3778
3779 var newActiveIndex = activeIndex + 1;
3780
3781 if ( typeof slides === 'object' && 'length' in slides ) {
3782 for ( var i = 0; i < slides.length; i += 1 ) {
3783 if ( slides[ i ] ) $wrapperEl.prepend( slides[ i ] );
3784 }
3785
3786 newActiveIndex = activeIndex + slides.length;
3787 } else {
3788 $wrapperEl.prepend( slides );
3789 }
3790
3791 if ( params.loop ) {
3792 swiper.loopCreate();
3793 }
3794
3795 if ( ! ( params.observer && swiper.support.observer ) ) {
3796 swiper.update();
3797 }
3798
3799 swiper.slideTo( newActiveIndex, 0, false );
3800 }
3801
3802 function addSlide( index, slides ) {
3803 var swiper = this;
3804 var $wrapperEl = swiper.$wrapperEl,
3805 params = swiper.params,
3806 activeIndex = swiper.activeIndex;
3807 var activeIndexBuffer = activeIndex;
3808
3809 if ( params.loop ) {
3810 activeIndexBuffer -= swiper.loopedSlides;
3811 swiper.loopDestroy();
3812 swiper.slides = $wrapperEl.children( '.' + params.slideClass );
3813 }
3814
3815 var baseLength = swiper.slides.length;
3816
3817 if ( index <= 0 ) {
3818 swiper.prependSlide( slides );
3819 return;
3820 }
3821
3822 if ( index >= baseLength ) {
3823 swiper.appendSlide( slides );
3824 return;
3825 }
3826
3827 var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
3828 var slidesBuffer = [];
3829
3830 for ( var i = baseLength - 1; i >= index; i -= 1 ) {
3831 var currentSlide = swiper.slides.eq( i );
3832 currentSlide.remove();
3833 slidesBuffer.unshift( currentSlide );
3834 }
3835
3836 if ( typeof slides === 'object' && 'length' in slides ) {
3837 for ( var _i = 0; _i < slides.length; _i += 1 ) {
3838 if ( slides[ _i ] ) $wrapperEl.append( slides[ _i ] );
3839 }
3840
3841 newActiveIndex =
3842 activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
3843 } else {
3844 $wrapperEl.append( slides );
3845 }
3846
3847 for ( var _i2 = 0; _i2 < slidesBuffer.length; _i2 += 1 ) {
3848 $wrapperEl.append( slidesBuffer[ _i2 ] );
3849 }
3850
3851 if ( params.loop ) {
3852 swiper.loopCreate();
3853 }
3854
3855 if ( ! ( params.observer && swiper.support.observer ) ) {
3856 swiper.update();
3857 }
3858
3859 if ( params.loop ) {
3860 swiper.slideTo( newActiveIndex + swiper.loopedSlides, 0, false );
3861 } else {
3862 swiper.slideTo( newActiveIndex, 0, false );
3863 }
3864 }
3865
3866 function removeSlide( slidesIndexes ) {
3867 var swiper = this;
3868 var params = swiper.params,
3869 $wrapperEl = swiper.$wrapperEl,
3870 activeIndex = swiper.activeIndex;
3871 var activeIndexBuffer = activeIndex;
3872
3873 if ( params.loop ) {
3874 activeIndexBuffer -= swiper.loopedSlides;
3875 swiper.loopDestroy();
3876 swiper.slides = $wrapperEl.children( '.' + params.slideClass );
3877 }
3878
3879 var newActiveIndex = activeIndexBuffer;
3880 var indexToRemove;
3881
3882 if ( typeof slidesIndexes === 'object' && 'length' in slidesIndexes ) {
3883 for ( var i = 0; i < slidesIndexes.length; i += 1 ) {
3884 indexToRemove = slidesIndexes[ i ];
3885 if ( swiper.slides[ indexToRemove ] ) swiper.slides.eq( indexToRemove ).remove();
3886 if ( indexToRemove < newActiveIndex ) newActiveIndex -= 1;
3887 }
3888
3889 newActiveIndex = Math.max( newActiveIndex, 0 );
3890 } else {
3891 indexToRemove = slidesIndexes;
3892 if ( swiper.slides[ indexToRemove ] ) swiper.slides.eq( indexToRemove ).remove();
3893 if ( indexToRemove < newActiveIndex ) newActiveIndex -= 1;
3894 newActiveIndex = Math.max( newActiveIndex, 0 );
3895 }
3896
3897 if ( params.loop ) {
3898 swiper.loopCreate();
3899 }
3900
3901 if ( ! ( params.observer && swiper.support.observer ) ) {
3902 swiper.update();
3903 }
3904
3905 if ( params.loop ) {
3906 swiper.slideTo( newActiveIndex + swiper.loopedSlides, 0, false );
3907 } else {
3908 swiper.slideTo( newActiveIndex, 0, false );
3909 }
3910 }
3911
3912 function removeAllSlides() {
3913 var swiper = this;
3914 var slidesIndexes = [];
3915
3916 for ( var i = 0; i < swiper.slides.length; i += 1 ) {
3917 slidesIndexes.push( i );
3918 }
3919
3920 swiper.removeSlide( slidesIndexes );
3921 }
3922
3923 var manipulation = {
3924 appendSlide: appendSlide,
3925 prependSlide: prependSlide,
3926 addSlide: addSlide,
3927 removeSlide: removeSlide,
3928 removeAllSlides: removeAllSlides,
3929 };
3930
3931 function onTouchStart( event ) {
3932 var swiper = this;
3933 var document = getDocument();
3934 var window = getWindow();
3935 var data = swiper.touchEventsData;
3936 var params = swiper.params,
3937 touches = swiper.touches,
3938 enabled = swiper.enabled;
3939 if ( ! enabled ) return;
3940
3941 if ( swiper.animating && params.preventInteractionOnTransition ) {
3942 return;
3943 }
3944
3945 var e = event;
3946 if ( e.originalEvent ) e = e.originalEvent;
3947 var $targetEl = $( e.target );
3948
3949 if ( params.touchEventsTarget === 'wrapper' ) {
3950 if ( ! $targetEl.closest( swiper.wrapperEl ).length ) return;
3951 }
3952
3953 data.isTouchEvent = e.type === 'touchstart';
3954 if ( ! data.isTouchEvent && 'which' in e && e.which === 3 ) return;
3955 if ( ! data.isTouchEvent && 'button' in e && e.button > 0 ) return;
3956 if ( data.isTouched && data.isMoved ) return; // change target el for shadow root componenet
3957
3958 var swipingClassHasValue = !! params.noSwipingClass && params.noSwipingClass !== '';
3959
3960 if (
3961 swipingClassHasValue &&
3962 e.target &&
3963 e.target.shadowRoot &&
3964 event.path &&
3965 event.path[ 0 ]
3966 ) {
3967 $targetEl = $( event.path[ 0 ] );
3968 }
3969
3970 if (
3971 params.noSwiping &&
3972 $targetEl.closest(
3973 params.noSwipingSelector ? params.noSwipingSelector : '.' + params.noSwipingClass
3974 )[ 0 ]
3975 ) {
3976 swiper.allowClick = true;
3977 return;
3978 }
3979
3980 if ( params.swipeHandler ) {
3981 if ( ! $targetEl.closest( params.swipeHandler )[ 0 ] ) return;
3982 }
3983
3984 touches.currentX = e.type === 'touchstart' ? e.targetTouches[ 0 ].pageX : e.pageX;
3985 touches.currentY = e.type === 'touchstart' ? e.targetTouches[ 0 ].pageY : e.pageY;
3986 var startX = touches.currentX;
3987 var startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
3988
3989 var edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
3990 var edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
3991
3992 if (
3993 edgeSwipeDetection &&
3994 ( startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold )
3995 ) {
3996 if ( edgeSwipeDetection === 'prevent' ) {
3997 event.preventDefault();
3998 } else {
3999 return;
4000 }
4001 }
4002
4003 extend( data, {
4004 isTouched: true,
4005 isMoved: false,
4006 allowTouchCallbacks: true,
4007 isScrolling: undefined,
4008 startMoving: undefined,
4009 } );
4010 touches.startX = startX;
4011 touches.startY = startY;
4012 data.touchStartTime = now();
4013 swiper.allowClick = true;
4014 swiper.updateSize();
4015 swiper.swipeDirection = undefined;
4016 if ( params.threshold > 0 ) data.allowThresholdMove = false;
4017
4018 if ( e.type !== 'touchstart' ) {
4019 var preventDefault = true;
4020 if ( $targetEl.is( data.focusableElements ) ) preventDefault = false;
4021
4022 if (
4023 document.activeElement &&
4024 $( document.activeElement ).is( data.focusableElements ) &&
4025 document.activeElement !== $targetEl[ 0 ]
4026 ) {
4027 document.activeElement.blur();
4028 }
4029
4030 var shouldPreventDefault =
4031 preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
4032
4033 if (
4034 ( params.touchStartForcePreventDefault || shouldPreventDefault ) &&
4035 ! $targetEl[ 0 ].isContentEditable
4036 ) {
4037 e.preventDefault();
4038 }
4039 }
4040
4041 swiper.emit( 'touchStart', e );
4042 }
4043
4044 function onTouchMove( event ) {
4045 var document = getDocument();
4046 var swiper = this;
4047 var data = swiper.touchEventsData;
4048 var params = swiper.params,
4049 touches = swiper.touches,
4050 rtl = swiper.rtlTranslate,
4051 enabled = swiper.enabled;
4052 if ( ! enabled ) return;
4053 var e = event;
4054 if ( e.originalEvent ) e = e.originalEvent;
4055
4056 if ( ! data.isTouched ) {
4057 if ( data.startMoving && data.isScrolling ) {
4058 swiper.emit( 'touchMoveOpposite', e );
4059 }
4060
4061 return;
4062 }
4063
4064 if ( data.isTouchEvent && e.type !== 'touchmove' ) return;
4065 var targetTouch =
4066 e.type === 'touchmove' &&
4067 e.targetTouches &&
4068 ( e.targetTouches[ 0 ] || e.changedTouches[ 0 ] );
4069 var pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
4070 var pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
4071
4072 if ( e.preventedByNestedSwiper ) {
4073 touches.startX = pageX;
4074 touches.startY = pageY;
4075 return;
4076 }
4077
4078 if ( ! swiper.allowTouchMove ) {
4079 // isMoved = true;
4080 swiper.allowClick = false;
4081
4082 if ( data.isTouched ) {
4083 extend( touches, {
4084 startX: pageX,
4085 startY: pageY,
4086 currentX: pageX,
4087 currentY: pageY,
4088 } );
4089 data.touchStartTime = now();
4090 }
4091
4092 return;
4093 }
4094
4095 if ( data.isTouchEvent && params.touchReleaseOnEdges && ! params.loop ) {
4096 if ( swiper.isVertical() ) {
4097 // Vertical
4098 if (
4099 ( pageY < touches.startY && swiper.translate <= swiper.maxTranslate() ) ||
4100 ( pageY > touches.startY && swiper.translate >= swiper.minTranslate() )
4101 ) {
4102 data.isTouched = false;
4103 data.isMoved = false;
4104 return;
4105 }
4106 } else if (
4107 ( pageX < touches.startX && swiper.translate <= swiper.maxTranslate() ) ||
4108 ( pageX > touches.startX && swiper.translate >= swiper.minTranslate() )
4109 ) {
4110 return;
4111 }
4112 }
4113
4114 if ( data.isTouchEvent && document.activeElement ) {
4115 if ( e.target === document.activeElement && $( e.target ).is( data.focusableElements ) ) {
4116 data.isMoved = true;
4117 swiper.allowClick = false;
4118 return;
4119 }
4120 }
4121
4122 if ( data.allowTouchCallbacks ) {
4123 swiper.emit( 'touchMove', e );
4124 }
4125
4126 if ( e.targetTouches && e.targetTouches.length > 1 ) return;
4127 touches.currentX = pageX;
4128 touches.currentY = pageY;
4129 var diffX = touches.currentX - touches.startX;
4130 var diffY = touches.currentY - touches.startY;
4131 if (
4132 swiper.params.threshold &&
4133 Math.sqrt( Math.pow( diffX, 2 ) + Math.pow( diffY, 2 ) ) < swiper.params.threshold
4134 )
4135 return;
4136
4137 if ( typeof data.isScrolling === 'undefined' ) {
4138 var touchAngle;
4139
4140 if (
4141 ( swiper.isHorizontal() && touches.currentY === touches.startY ) ||
4142 ( swiper.isVertical() && touches.currentX === touches.startX )
4143 ) {
4144 data.isScrolling = false;
4145 } else {
4146 // eslint-disable-next-line
4147 if ( diffX * diffX + diffY * diffY >= 25 ) {
4148 touchAngle = ( Math.atan2( Math.abs( diffY ), Math.abs( diffX ) ) * 180 ) / Math.PI;
4149 data.isScrolling = swiper.isHorizontal()
4150 ? touchAngle > params.touchAngle
4151 : 90 - touchAngle > params.touchAngle;
4152 }
4153 }
4154 }
4155
4156 if ( data.isScrolling ) {
4157 swiper.emit( 'touchMoveOpposite', e );
4158 }
4159
4160 if ( typeof data.startMoving === 'undefined' ) {
4161 if ( touches.currentX !== touches.startX || touches.currentY !== touches.startY ) {
4162 data.startMoving = true;
4163 }
4164 }
4165
4166 if ( data.isScrolling ) {
4167 data.isTouched = false;
4168 return;
4169 }
4170
4171 if ( ! data.startMoving ) {
4172 return;
4173 }
4174
4175 swiper.allowClick = false;
4176
4177 if ( ! params.cssMode && e.cancelable ) {
4178 e.preventDefault();
4179 }
4180
4181 if ( params.touchMoveStopPropagation && ! params.nested ) {
4182 e.stopPropagation();
4183 }
4184
4185 if ( ! data.isMoved ) {
4186 if ( params.loop ) {
4187 swiper.loopFix();
4188 }
4189
4190 data.startTranslate = swiper.getTranslate();
4191 swiper.setTransition( 0 );
4192
4193 if ( swiper.animating ) {
4194 swiper.$wrapperEl.trigger( 'webkitTransitionEnd transitionend' );
4195 }
4196
4197 data.allowMomentumBounce = false; // Grab Cursor
4198
4199 if (
4200 params.grabCursor &&
4201 ( swiper.allowSlideNext === true || swiper.allowSlidePrev === true )
4202 ) {
4203 swiper.setGrabCursor( true );
4204 }
4205
4206 swiper.emit( 'sliderFirstMove', e );
4207 }
4208
4209 swiper.emit( 'sliderMove', e );
4210 data.isMoved = true;
4211 var diff = swiper.isHorizontal() ? diffX : diffY;
4212 touches.diff = diff;
4213 diff *= params.touchRatio;
4214 if ( rtl ) diff = -diff;
4215 swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
4216 data.currentTranslate = diff + data.startTranslate;
4217 var disableParentSwiper = true;
4218 var resistanceRatio = params.resistanceRatio;
4219
4220 if ( params.touchReleaseOnEdges ) {
4221 resistanceRatio = 0;
4222 }
4223
4224 if ( diff > 0 && data.currentTranslate > swiper.minTranslate() ) {
4225 disableParentSwiper = false;
4226 if ( params.resistance )
4227 data.currentTranslate =
4228 swiper.minTranslate() -
4229 1 +
4230 Math.pow( -swiper.minTranslate() + data.startTranslate + diff, resistanceRatio );
4231 } else if ( diff < 0 && data.currentTranslate < swiper.maxTranslate() ) {
4232 disableParentSwiper = false;
4233 if ( params.resistance )
4234 data.currentTranslate =
4235 swiper.maxTranslate() +
4236 1 -
4237 Math.pow( swiper.maxTranslate() - data.startTranslate - diff, resistanceRatio );
4238 }
4239
4240 if ( disableParentSwiper ) {
4241 e.preventedByNestedSwiper = true;
4242 } // Directions locks
4243
4244 if (
4245 ! swiper.allowSlideNext &&
4246 swiper.swipeDirection === 'next' &&
4247 data.currentTranslate < data.startTranslate
4248 ) {
4249 data.currentTranslate = data.startTranslate;
4250 }
4251
4252 if (
4253 ! swiper.allowSlidePrev &&
4254 swiper.swipeDirection === 'prev' &&
4255 data.currentTranslate > data.startTranslate
4256 ) {
4257 data.currentTranslate = data.startTranslate;
4258 }
4259
4260 if ( ! swiper.allowSlidePrev && ! swiper.allowSlideNext ) {
4261 data.currentTranslate = data.startTranslate;
4262 } // Threshold
4263
4264 if ( params.threshold > 0 ) {
4265 if ( Math.abs( diff ) > params.threshold || data.allowThresholdMove ) {
4266 if ( ! data.allowThresholdMove ) {
4267 data.allowThresholdMove = true;
4268 touches.startX = touches.currentX;
4269 touches.startY = touches.currentY;
4270 data.currentTranslate = data.startTranslate;
4271 touches.diff = swiper.isHorizontal()
4272 ? touches.currentX - touches.startX
4273 : touches.currentY - touches.startY;
4274 return;
4275 }
4276 } else {
4277 data.currentTranslate = data.startTranslate;
4278 return;
4279 }
4280 }
4281
4282 if ( ! params.followFinger || params.cssMode ) return; // Update active index in free mode
4283
4284 if ( params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility ) {
4285 swiper.updateActiveIndex();
4286 swiper.updateSlidesClasses();
4287 }
4288
4289 if ( params.freeMode ) {
4290 // Velocity
4291 if ( data.velocities.length === 0 ) {
4292 data.velocities.push( {
4293 position: touches[ swiper.isHorizontal() ? 'startX' : 'startY' ],
4294 time: data.touchStartTime,
4295 } );
4296 }
4297
4298 data.velocities.push( {
4299 position: touches[ swiper.isHorizontal() ? 'currentX' : 'currentY' ],
4300 time: now(),
4301 } );
4302 } // Update progress
4303
4304 swiper.updateProgress( data.currentTranslate ); // Update translate
4305
4306 swiper.setTranslate( data.currentTranslate );
4307 }
4308
4309 function onTouchEnd( event ) {
4310 var swiper = this;
4311 var data = swiper.touchEventsData;
4312 var params = swiper.params,
4313 touches = swiper.touches,
4314 rtl = swiper.rtlTranslate,
4315 $wrapperEl = swiper.$wrapperEl,
4316 slidesGrid = swiper.slidesGrid,
4317 snapGrid = swiper.snapGrid,
4318 enabled = swiper.enabled;
4319 if ( ! enabled ) return;
4320 var e = event;
4321 if ( e.originalEvent ) e = e.originalEvent;
4322
4323 if ( data.allowTouchCallbacks ) {
4324 swiper.emit( 'touchEnd', e );
4325 }
4326
4327 data.allowTouchCallbacks = false;
4328
4329 if ( ! data.isTouched ) {
4330 if ( data.isMoved && params.grabCursor ) {
4331 swiper.setGrabCursor( false );
4332 }
4333
4334 data.isMoved = false;
4335 data.startMoving = false;
4336 return;
4337 } // Return Grab Cursor
4338
4339 if (
4340 params.grabCursor &&
4341 data.isMoved &&
4342 data.isTouched &&
4343 ( swiper.allowSlideNext === true || swiper.allowSlidePrev === true )
4344 ) {
4345 swiper.setGrabCursor( false );
4346 } // Time diff
4347
4348 var touchEndTime = now();
4349 var timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click
4350
4351 if ( swiper.allowClick ) {
4352 swiper.updateClickedSlide( e );
4353 swiper.emit( 'tap click', e );
4354
4355 if ( timeDiff < 300 && touchEndTime - data.lastClickTime < 300 ) {
4356 swiper.emit( 'doubleTap doubleClick', e );
4357 }
4358 }
4359
4360 data.lastClickTime = now();
4361 nextTick( function () {
4362 if ( ! swiper.destroyed ) swiper.allowClick = true;
4363 } );
4364
4365 if (
4366 ! data.isTouched ||
4367 ! data.isMoved ||
4368 ! swiper.swipeDirection ||
4369 touches.diff === 0 ||
4370 data.currentTranslate === data.startTranslate
4371 ) {
4372 data.isTouched = false;
4373 data.isMoved = false;
4374 data.startMoving = false;
4375 return;
4376 }
4377
4378 data.isTouched = false;
4379 data.isMoved = false;
4380 data.startMoving = false;
4381 var currentPos;
4382
4383 if ( params.followFinger ) {
4384 currentPos = rtl ? swiper.translate : -swiper.translate;
4385 } else {
4386 currentPos = -data.currentTranslate;
4387 }
4388
4389 if ( params.cssMode ) {
4390 return;
4391 }
4392
4393 if ( params.freeMode ) {
4394 if ( currentPos < -swiper.minTranslate() ) {
4395 swiper.slideTo( swiper.activeIndex );
4396 return;
4397 }
4398
4399 if ( currentPos > -swiper.maxTranslate() ) {
4400 if ( swiper.slides.length < snapGrid.length ) {
4401 swiper.slideTo( snapGrid.length - 1 );
4402 } else {
4403 swiper.slideTo( swiper.slides.length - 1 );
4404 }
4405
4406 return;
4407 }
4408
4409 if ( params.freeModeMomentum ) {
4410 if ( data.velocities.length > 1 ) {
4411 var lastMoveEvent = data.velocities.pop();
4412 var velocityEvent = data.velocities.pop();
4413 var distance = lastMoveEvent.position - velocityEvent.position;
4414 var time = lastMoveEvent.time - velocityEvent.time;
4415 swiper.velocity = distance / time;
4416 swiper.velocity /= 2;
4417
4418 if ( Math.abs( swiper.velocity ) < params.freeModeMinimumVelocity ) {
4419 swiper.velocity = 0;
4420 } // this implies that the user stopped moving a finger then released.
4421 // There would be no events with distance zero, so the last event is stale.
4422
4423 if ( time > 150 || now() - lastMoveEvent.time > 300 ) {
4424 swiper.velocity = 0;
4425 }
4426 } else {
4427 swiper.velocity = 0;
4428 }
4429
4430 swiper.velocity *= params.freeModeMomentumVelocityRatio;
4431 data.velocities.length = 0;
4432 var momentumDuration = 1000 * params.freeModeMomentumRatio;
4433 var momentumDistance = swiper.velocity * momentumDuration;
4434 var newPosition = swiper.translate + momentumDistance;
4435 if ( rtl ) newPosition = -newPosition;
4436 var doBounce = false;
4437 var afterBouncePosition;
4438 var bounceAmount = Math.abs( swiper.velocity ) * 20 * params.freeModeMomentumBounceRatio;
4439 var needsLoopFix;
4440
4441 if ( newPosition < swiper.maxTranslate() ) {
4442 if ( params.freeModeMomentumBounce ) {
4443 if ( newPosition + swiper.maxTranslate() < -bounceAmount ) {
4444 newPosition = swiper.maxTranslate() - bounceAmount;
4445 }
4446
4447 afterBouncePosition = swiper.maxTranslate();
4448 doBounce = true;
4449 data.allowMomentumBounce = true;
4450 } else {
4451 newPosition = swiper.maxTranslate();
4452 }
4453
4454 if ( params.loop && params.centeredSlides ) needsLoopFix = true;
4455 } else if ( newPosition > swiper.minTranslate() ) {
4456 if ( params.freeModeMomentumBounce ) {
4457 if ( newPosition - swiper.minTranslate() > bounceAmount ) {
4458 newPosition = swiper.minTranslate() + bounceAmount;
4459 }
4460
4461 afterBouncePosition = swiper.minTranslate();
4462 doBounce = true;
4463 data.allowMomentumBounce = true;
4464 } else {
4465 newPosition = swiper.minTranslate();
4466 }
4467
4468 if ( params.loop && params.centeredSlides ) needsLoopFix = true;
4469 } else if ( params.freeModeSticky ) {
4470 var nextSlide;
4471
4472 for ( var j = 0; j < snapGrid.length; j += 1 ) {
4473 if ( snapGrid[ j ] > -newPosition ) {
4474 nextSlide = j;
4475 break;
4476 }
4477 }
4478
4479 if (
4480 Math.abs( snapGrid[ nextSlide ] - newPosition ) <
4481 Math.abs( snapGrid[ nextSlide - 1 ] - newPosition ) ||
4482 swiper.swipeDirection === 'next'
4483 ) {
4484 newPosition = snapGrid[ nextSlide ];
4485 } else {
4486 newPosition = snapGrid[ nextSlide - 1 ];
4487 }
4488
4489 newPosition = -newPosition;
4490 }
4491
4492 if ( needsLoopFix ) {
4493 swiper.once( 'transitionEnd', function () {
4494 swiper.loopFix();
4495 } );
4496 } // Fix duration
4497
4498 if ( swiper.velocity !== 0 ) {
4499 if ( rtl ) {
4500 momentumDuration = Math.abs( ( -newPosition - swiper.translate ) / swiper.velocity );
4501 } else {
4502 momentumDuration = Math.abs( ( newPosition - swiper.translate ) / swiper.velocity );
4503 }
4504
4505 if ( params.freeModeSticky ) {
4506 // If freeModeSticky is active and the user ends a swipe with a slow-velocity
4507 // event, then durations can be 20+ seconds to slide one (or zero!) slides.
4508 // It's easy to see this when simulating touch with mouse events. To fix this,
4509 // limit single-slide swipes to the default slide duration. This also has the
4510 // nice side effect of matching slide speed if the user stopped moving before
4511 // lifting finger or mouse vs. moving slowly before lifting the finger/mouse.
4512 // For faster swipes, also apply limits (albeit higher ones).
4513 var moveDistance = Math.abs( ( rtl ? -newPosition : newPosition ) - swiper.translate );
4514 var currentSlideSize = swiper.slidesSizesGrid[ swiper.activeIndex ];
4515
4516 if ( moveDistance < currentSlideSize ) {
4517 momentumDuration = params.speed;
4518 } else if ( moveDistance < 2 * currentSlideSize ) {
4519 momentumDuration = params.speed * 1.5;
4520 } else {
4521 momentumDuration = params.speed * 2.5;
4522 }
4523 }
4524 } else if ( params.freeModeSticky ) {
4525 swiper.slideToClosest();
4526 return;
4527 }
4528
4529 if ( params.freeModeMomentumBounce && doBounce ) {
4530 swiper.updateProgress( afterBouncePosition );
4531 swiper.setTransition( momentumDuration );
4532 swiper.setTranslate( newPosition );
4533 swiper.transitionStart( true, swiper.swipeDirection );
4534 swiper.animating = true;
4535 $wrapperEl.transitionEnd( function () {
4536 if ( ! swiper || swiper.destroyed || ! data.allowMomentumBounce ) return;
4537 swiper.emit( 'momentumBounce' );
4538 swiper.setTransition( params.speed );
4539 setTimeout( function () {
4540 swiper.setTranslate( afterBouncePosition );
4541 $wrapperEl.transitionEnd( function () {
4542 if ( ! swiper || swiper.destroyed ) return;
4543 swiper.transitionEnd();
4544 } );
4545 }, 0 );
4546 } );
4547 } else if ( swiper.velocity ) {
4548 swiper.updateProgress( newPosition );
4549 swiper.setTransition( momentumDuration );
4550 swiper.setTranslate( newPosition );
4551 swiper.transitionStart( true, swiper.swipeDirection );
4552
4553 if ( ! swiper.animating ) {
4554 swiper.animating = true;
4555 $wrapperEl.transitionEnd( function () {
4556 if ( ! swiper || swiper.destroyed ) return;
4557 swiper.transitionEnd();
4558 } );
4559 }
4560 } else {
4561 swiper.emit( '_freeModeNoMomentumRelease' );
4562 swiper.updateProgress( newPosition );
4563 }
4564
4565 swiper.updateActiveIndex();
4566 swiper.updateSlidesClasses();
4567 } else if ( params.freeModeSticky ) {
4568 swiper.slideToClosest();
4569 return;
4570 } else if ( params.freeMode ) {
4571 swiper.emit( '_freeModeNoMomentumRelease' );
4572 }
4573
4574 if ( ! params.freeModeMomentum || timeDiff >= params.longSwipesMs ) {
4575 swiper.updateProgress();
4576 swiper.updateActiveIndex();
4577 swiper.updateSlidesClasses();
4578 }
4579
4580 return;
4581 } // Find current slide
4582
4583 var stopIndex = 0;
4584 var groupSize = swiper.slidesSizesGrid[ 0 ];
4585
4586 for (
4587 var i = 0;
4588 i < slidesGrid.length;
4589 i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup
4590 ) {
4591 var _increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
4592
4593 if ( typeof slidesGrid[ i + _increment ] !== 'undefined' ) {
4594 if ( currentPos >= slidesGrid[ i ] && currentPos < slidesGrid[ i + _increment ] ) {
4595 stopIndex = i;
4596 groupSize = slidesGrid[ i + _increment ] - slidesGrid[ i ];
4597 }
4598 } else if ( currentPos >= slidesGrid[ i ] ) {
4599 stopIndex = i;
4600 groupSize = slidesGrid[ slidesGrid.length - 1 ] - slidesGrid[ slidesGrid.length - 2 ];
4601 }
4602 } // Find current slide size
4603
4604 var ratio = ( currentPos - slidesGrid[ stopIndex ] ) / groupSize;
4605 var increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
4606
4607 if ( timeDiff > params.longSwipesMs ) {
4608 // Long touches
4609 if ( ! params.longSwipes ) {
4610 swiper.slideTo( swiper.activeIndex );
4611 return;
4612 }
4613
4614 if ( swiper.swipeDirection === 'next' ) {
4615 if ( ratio >= params.longSwipesRatio ) swiper.slideTo( stopIndex + increment );
4616 else swiper.slideTo( stopIndex );
4617 }
4618
4619 if ( swiper.swipeDirection === 'prev' ) {
4620 if ( ratio > 1 - params.longSwipesRatio ) swiper.slideTo( stopIndex + increment );
4621 else swiper.slideTo( stopIndex );
4622 }
4623 } else {
4624 // Short swipes
4625 if ( ! params.shortSwipes ) {
4626 swiper.slideTo( swiper.activeIndex );
4627 return;
4628 }
4629
4630 var isNavButtonTarget =
4631 swiper.navigation &&
4632 ( e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl );
4633
4634 if ( ! isNavButtonTarget ) {
4635 if ( swiper.swipeDirection === 'next' ) {
4636 swiper.slideTo( stopIndex + increment );
4637 }
4638
4639 if ( swiper.swipeDirection === 'prev' ) {
4640 swiper.slideTo( stopIndex );
4641 }
4642 } else if ( e.target === swiper.navigation.nextEl ) {
4643 swiper.slideTo( stopIndex + increment );
4644 } else {
4645 swiper.slideTo( stopIndex );
4646 }
4647 }
4648 }
4649
4650 function onResize() {
4651 var swiper = this;
4652 var params = swiper.params,
4653 el = swiper.el;
4654 if ( el && el.offsetWidth === 0 ) return; // Breakpoints
4655
4656 if ( params.breakpoints ) {
4657 swiper.setBreakpoint();
4658 } // Save locks
4659
4660 var allowSlideNext = swiper.allowSlideNext,
4661 allowSlidePrev = swiper.allowSlidePrev,
4662 snapGrid = swiper.snapGrid; // Disable locks on resize
4663
4664 swiper.allowSlideNext = true;
4665 swiper.allowSlidePrev = true;
4666 swiper.updateSize();
4667 swiper.updateSlides();
4668 swiper.updateSlidesClasses();
4669
4670 if (
4671 ( params.slidesPerView === 'auto' || params.slidesPerView > 1 ) &&
4672 swiper.isEnd &&
4673 ! swiper.isBeginning &&
4674 ! swiper.params.centeredSlides
4675 ) {
4676 swiper.slideTo( swiper.slides.length - 1, 0, false, true );
4677 } else {
4678 swiper.slideTo( swiper.activeIndex, 0, false, true );
4679 }
4680
4681 if ( swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused ) {
4682 swiper.autoplay.run();
4683 } // Return locks after resize
4684
4685 swiper.allowSlidePrev = allowSlidePrev;
4686 swiper.allowSlideNext = allowSlideNext;
4687
4688 if ( swiper.params.watchOverflow && snapGrid !== swiper.snapGrid ) {
4689 swiper.checkOverflow();
4690 }
4691 }
4692
4693 function onClick( e ) {
4694 var swiper = this;
4695 if ( ! swiper.enabled ) return;
4696
4697 if ( ! swiper.allowClick ) {
4698 if ( swiper.params.preventClicks ) e.preventDefault();
4699
4700 if ( swiper.params.preventClicksPropagation && swiper.animating ) {
4701 e.stopPropagation();
4702 e.stopImmediatePropagation();
4703 }
4704 }
4705 }
4706
4707 function onScroll() {
4708 var swiper = this;
4709 var wrapperEl = swiper.wrapperEl,
4710 rtlTranslate = swiper.rtlTranslate,
4711 enabled = swiper.enabled;
4712 if ( ! enabled ) return;
4713 swiper.previousTranslate = swiper.translate;
4714
4715 if ( swiper.isHorizontal() ) {
4716 if ( rtlTranslate ) {
4717 swiper.translate = wrapperEl.scrollWidth - wrapperEl.offsetWidth - wrapperEl.scrollLeft;
4718 } else {
4719 swiper.translate = -wrapperEl.scrollLeft;
4720 }
4721 } else {
4722 swiper.translate = -wrapperEl.scrollTop;
4723 } // eslint-disable-next-line
4724
4725 if ( swiper.translate === -0 ) swiper.translate = 0;
4726 swiper.updateActiveIndex();
4727 swiper.updateSlidesClasses();
4728 var newProgress;
4729 var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
4730
4731 if ( translatesDiff === 0 ) {
4732 newProgress = 0;
4733 } else {
4734 newProgress = ( swiper.translate - swiper.minTranslate() ) / translatesDiff;
4735 }
4736
4737 if ( newProgress !== swiper.progress ) {
4738 swiper.updateProgress( rtlTranslate ? -swiper.translate : swiper.translate );
4739 }
4740
4741 swiper.emit( 'setTranslate', swiper.translate, false );
4742 }
4743
4744 var dummyEventAttached = false;
4745
4746 function dummyEventListener() {}
4747
4748 function attachEvents() {
4749 var swiper = this;
4750 var document = getDocument();
4751 var params = swiper.params,
4752 touchEvents = swiper.touchEvents,
4753 el = swiper.el,
4754 wrapperEl = swiper.wrapperEl,
4755 device = swiper.device,
4756 support = swiper.support;
4757 swiper.onTouchStart = onTouchStart.bind( swiper );
4758 swiper.onTouchMove = onTouchMove.bind( swiper );
4759 swiper.onTouchEnd = onTouchEnd.bind( swiper );
4760
4761 if ( params.cssMode ) {
4762 swiper.onScroll = onScroll.bind( swiper );
4763 }
4764
4765 swiper.onClick = onClick.bind( swiper );
4766 var capture = !! params.nested; // Touch Events
4767
4768 if ( ! support.touch && support.pointerEvents ) {
4769 el.addEventListener( touchEvents.start, swiper.onTouchStart, false );
4770 document.addEventListener( touchEvents.move, swiper.onTouchMove, capture );
4771 document.addEventListener( touchEvents.end, swiper.onTouchEnd, false );
4772 } else {
4773 if ( support.touch ) {
4774 var passiveListener =
4775 touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners
4776 ? {
4777 passive: true,
4778 capture: false,
4779 }
4780 : false;
4781 el.addEventListener( touchEvents.start, swiper.onTouchStart, passiveListener );
4782 el.addEventListener(
4783 touchEvents.move,
4784 swiper.onTouchMove,
4785 support.passiveListener
4786 ? {
4787 passive: false,
4788 capture: capture,
4789 }
4790 : capture
4791 );
4792 el.addEventListener( touchEvents.end, swiper.onTouchEnd, passiveListener );
4793
4794 if ( touchEvents.cancel ) {
4795 el.addEventListener( touchEvents.cancel, swiper.onTouchEnd, passiveListener );
4796 }
4797
4798 if ( ! dummyEventAttached ) {
4799 document.addEventListener( 'touchstart', dummyEventListener );
4800 dummyEventAttached = true;
4801 }
4802 }
4803
4804 if (
4805 ( params.simulateTouch && ! device.ios && ! device.android ) ||
4806 ( params.simulateTouch && ! support.touch && device.ios )
4807 ) {
4808 el.addEventListener( 'mousedown', swiper.onTouchStart, false );
4809 document.addEventListener( 'mousemove', swiper.onTouchMove, capture );
4810 document.addEventListener( 'mouseup', swiper.onTouchEnd, false );
4811 }
4812 } // Prevent Links Clicks
4813
4814 if ( params.preventClicks || params.preventClicksPropagation ) {
4815 el.addEventListener( 'click', swiper.onClick, true );
4816 }
4817
4818 if ( params.cssMode ) {
4819 wrapperEl.addEventListener( 'scroll', swiper.onScroll );
4820 } // Resize handler
4821
4822 if ( params.updateOnWindowResize ) {
4823 swiper.on(
4824 device.ios || device.android
4825 ? 'resize orientationchange observerUpdate'
4826 : 'resize observerUpdate',
4827 onResize,
4828 true
4829 );
4830 } else {
4831 swiper.on( 'observerUpdate', onResize, true );
4832 }
4833 }
4834
4835 function detachEvents() {
4836 var swiper = this;
4837 var document = getDocument();
4838 var params = swiper.params,
4839 touchEvents = swiper.touchEvents,
4840 el = swiper.el,
4841 wrapperEl = swiper.wrapperEl,
4842 device = swiper.device,
4843 support = swiper.support;
4844 var capture = !! params.nested; // Touch Events
4845
4846 if ( ! support.touch && support.pointerEvents ) {
4847 el.removeEventListener( touchEvents.start, swiper.onTouchStart, false );
4848 document.removeEventListener( touchEvents.move, swiper.onTouchMove, capture );
4849 document.removeEventListener( touchEvents.end, swiper.onTouchEnd, false );
4850 } else {
4851 if ( support.touch ) {
4852 var passiveListener =
4853 touchEvents.start === 'onTouchStart' && support.passiveListener && params.passiveListeners
4854 ? {
4855 passive: true,
4856 capture: false,
4857 }
4858 : false;
4859 el.removeEventListener( touchEvents.start, swiper.onTouchStart, passiveListener );
4860 el.removeEventListener( touchEvents.move, swiper.onTouchMove, capture );
4861 el.removeEventListener( touchEvents.end, swiper.onTouchEnd, passiveListener );
4862
4863 if ( touchEvents.cancel ) {
4864 el.removeEventListener( touchEvents.cancel, swiper.onTouchEnd, passiveListener );
4865 }
4866 }
4867
4868 if (
4869 ( params.simulateTouch && ! device.ios && ! device.android ) ||
4870 ( params.simulateTouch && ! support.touch && device.ios )
4871 ) {
4872 el.removeEventListener( 'mousedown', swiper.onTouchStart, false );
4873 document.removeEventListener( 'mousemove', swiper.onTouchMove, capture );
4874 document.removeEventListener( 'mouseup', swiper.onTouchEnd, false );
4875 }
4876 } // Prevent Links Clicks
4877
4878 if ( params.preventClicks || params.preventClicksPropagation ) {
4879 el.removeEventListener( 'click', swiper.onClick, true );
4880 }
4881
4882 if ( params.cssMode ) {
4883 wrapperEl.removeEventListener( 'scroll', swiper.onScroll );
4884 } // Resize handler
4885
4886 swiper.off(
4887 device.ios || device.android
4888 ? 'resize orientationchange observerUpdate'
4889 : 'resize observerUpdate',
4890 onResize
4891 );
4892 }
4893
4894 var events = {
4895 attachEvents: attachEvents,
4896 detachEvents: detachEvents,
4897 };
4898
4899 function setBreakpoint() {
4900 var swiper = this;
4901 var activeIndex = swiper.activeIndex,
4902 initialized = swiper.initialized,
4903 _swiper$loopedSlides = swiper.loopedSlides,
4904 loopedSlides = _swiper$loopedSlides === void 0 ? 0 : _swiper$loopedSlides,
4905 params = swiper.params,
4906 $el = swiper.$el;
4907 var breakpoints = params.breakpoints;
4908 if ( ! breakpoints || ( breakpoints && Object.keys( breakpoints ).length === 0 ) ) return; // Get breakpoint for window width and update parameters
4909
4910 var breakpoint = swiper.getBreakpoint( breakpoints, swiper.params.breakpointsBase, swiper.el );
4911 if ( ! breakpoint || swiper.currentBreakpoint === breakpoint ) return;
4912 var breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[ breakpoint ] : undefined;
4913
4914 if ( breakpointOnlyParams ) {
4915 [
4916 'slidesPerView',
4917 'spaceBetween',
4918 'slidesPerGroup',
4919 'slidesPerGroupSkip',
4920 'slidesPerColumn',
4921 ].forEach( function ( param ) {
4922 var paramValue = breakpointOnlyParams[ param ];
4923 if ( typeof paramValue === 'undefined' ) return;
4924
4925 if ( param === 'slidesPerView' && ( paramValue === 'AUTO' || paramValue === 'auto' ) ) {
4926 breakpointOnlyParams[ param ] = 'auto';
4927 } else if ( param === 'slidesPerView' ) {
4928 breakpointOnlyParams[ param ] = parseFloat( paramValue );
4929 } else {
4930 breakpointOnlyParams[ param ] = parseInt( paramValue, 10 );
4931 }
4932 } );
4933 }
4934
4935 var breakpointParams = breakpointOnlyParams || swiper.originalParams;
4936 var wasMultiRow = params.slidesPerColumn > 1;
4937 var isMultiRow = breakpointParams.slidesPerColumn > 1;
4938 var wasEnabled = params.enabled;
4939
4940 if ( wasMultiRow && ! isMultiRow ) {
4941 $el.removeClass(
4942 params.containerModifierClass +
4943 'multirow ' +
4944 params.containerModifierClass +
4945 'multirow-column'
4946 );
4947 swiper.emitContainerClasses();
4948 } else if ( ! wasMultiRow && isMultiRow ) {
4949 $el.addClass( params.containerModifierClass + 'multirow' );
4950
4951 if ( breakpointParams.slidesPerColumnFill === 'column' ) {
4952 $el.addClass( params.containerModifierClass + 'multirow-column' );
4953 }
4954
4955 swiper.emitContainerClasses();
4956 }
4957
4958 var directionChanged =
4959 breakpointParams.direction && breakpointParams.direction !== params.direction;
4960 var needsReLoop =
4961 params.loop &&
4962 ( breakpointParams.slidesPerView !== params.slidesPerView || directionChanged );
4963
4964 if ( directionChanged && initialized ) {
4965 swiper.changeDirection();
4966 }
4967
4968 extend( swiper.params, breakpointParams );
4969 var isEnabled = swiper.params.enabled;
4970 extend( swiper, {
4971 allowTouchMove: swiper.params.allowTouchMove,
4972 allowSlideNext: swiper.params.allowSlideNext,
4973 allowSlidePrev: swiper.params.allowSlidePrev,
4974 } );
4975
4976 if ( wasEnabled && ! isEnabled ) {
4977 swiper.disable();
4978 } else if ( ! wasEnabled && isEnabled ) {
4979 swiper.enable();
4980 }
4981
4982 swiper.currentBreakpoint = breakpoint;
4983 swiper.emit( '_beforeBreakpoint', breakpointParams );
4984
4985 if ( needsReLoop && initialized ) {
4986 swiper.loopDestroy();
4987 swiper.loopCreate();
4988 swiper.updateSlides();
4989 swiper.slideTo( activeIndex - loopedSlides + swiper.loopedSlides, 0, false );
4990 }
4991
4992 swiper.emit( 'breakpoint', breakpointParams );
4993 }
4994
4995 function getBreakpoint( breakpoints, base, containerEl ) {
4996 if ( base === void 0 ) {
4997 base = 'window';
4998 }
4999
5000 if ( ! breakpoints || ( base === 'container' && ! containerEl ) ) return undefined;
5001 var breakpoint = false;
5002 var window = getWindow();
5003 var currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
5004 var points = Object.keys( breakpoints ).map( function ( point ) {
5005 if ( typeof point === 'string' && point.indexOf( '@' ) === 0 ) {
5006 var minRatio = parseFloat( point.substr( 1 ) );
5007 var value = currentHeight * minRatio;
5008 return {
5009 value: value,
5010 point: point,
5011 };
5012 }
5013
5014 return {
5015 value: point,
5016 point: point,
5017 };
5018 } );
5019 points.sort( function ( a, b ) {
5020 return parseInt( a.value, 10 ) - parseInt( b.value, 10 );
5021 } );
5022
5023 for ( var i = 0; i < points.length; i += 1 ) {
5024 var _points$i = points[ i ],
5025 point = _points$i.point,
5026 value = _points$i.value;
5027
5028 if ( base === 'window' ) {
5029 if ( window.matchMedia( '(min-width: ' + value + 'px)' ).matches ) {
5030 breakpoint = point;
5031 }
5032 } else if ( value <= containerEl.clientWidth ) {
5033 breakpoint = point;
5034 }
5035 }
5036
5037 return breakpoint || 'max';
5038 }
5039
5040 var breakpoints = {
5041 setBreakpoint: setBreakpoint,
5042 getBreakpoint: getBreakpoint,
5043 };
5044
5045 function prepareClasses( entries, prefix ) {
5046 var resultClasses = [];
5047 entries.forEach( function ( item ) {
5048 if ( typeof item === 'object' ) {
5049 Object.keys( item ).forEach( function ( classNames ) {
5050 if ( item[ classNames ] ) {
5051 resultClasses.push( prefix + classNames );
5052 }
5053 } );
5054 } else if ( typeof item === 'string' ) {
5055 resultClasses.push( prefix + item );
5056 }
5057 } );
5058 return resultClasses;
5059 }
5060
5061 function addClasses() {
5062 var swiper = this;
5063 var classNames = swiper.classNames,
5064 params = swiper.params,
5065 rtl = swiper.rtl,
5066 $el = swiper.$el,
5067 device = swiper.device,
5068 support = swiper.support; // prettier-ignore
5069
5070 var suffixes = prepareClasses(
5071 [
5072 'initialized',
5073 params.direction,
5074 {
5075 'pointer-events': support.pointerEvents && ! support.touch,
5076 },
5077 {
5078 'free-mode': params.freeMode,
5079 },
5080 {
5081 autoheight: params.autoHeight,
5082 },
5083 {
5084 rtl: rtl,
5085 },
5086 {
5087 multirow: params.slidesPerColumn > 1,
5088 },
5089 {
5090 'multirow-column': params.slidesPerColumn > 1 && params.slidesPerColumnFill === 'column',
5091 },
5092 {
5093 android: device.android,
5094 },
5095 {
5096 ios: device.ios,
5097 },
5098 {
5099 'css-mode': params.cssMode,
5100 },
5101 ],
5102 params.containerModifierClass
5103 );
5104 classNames.push.apply( classNames, suffixes );
5105 $el.addClass( [].concat( classNames ).join( ' ' ) );
5106 swiper.emitContainerClasses();
5107 }
5108
5109 function removeClasses() {
5110 var swiper = this;
5111 var $el = swiper.$el,
5112 classNames = swiper.classNames;
5113 $el.removeClass( classNames.join( ' ' ) );
5114 swiper.emitContainerClasses();
5115 }
5116
5117 var classes = {
5118 addClasses: addClasses,
5119 removeClasses: removeClasses,
5120 };
5121
5122 function loadImage( imageEl, src, srcset, sizes, checkForComplete, callback ) {
5123 var window = getWindow();
5124 var image;
5125
5126 function onReady() {
5127 if ( callback ) callback();
5128 }
5129
5130 var isPicture = $( imageEl ).parent( 'picture' )[ 0 ];
5131
5132 if ( ! isPicture && ( ! imageEl.complete || ! checkForComplete ) ) {
5133 if ( src ) {
5134 image = new window.Image();
5135 image.onload = onReady;
5136 image.onerror = onReady;
5137
5138 if ( sizes ) {
5139 image.sizes = sizes;
5140 }
5141
5142 if ( srcset ) {
5143 image.srcset = srcset;
5144 }
5145
5146 if ( src ) {
5147 image.src = src;
5148 }
5149 } else {
5150 onReady();
5151 }
5152 } else {
5153 // image already loaded...
5154 onReady();
5155 }
5156 }
5157
5158 function preloadImages() {
5159 var swiper = this;
5160 swiper.imagesToLoad = swiper.$el.find( 'img' );
5161
5162 function onReady() {
5163 if ( typeof swiper === 'undefined' || swiper === null || ! swiper || swiper.destroyed )
5164 return;
5165 if ( swiper.imagesLoaded !== undefined ) swiper.imagesLoaded += 1;
5166
5167 if ( swiper.imagesLoaded === swiper.imagesToLoad.length ) {
5168 if ( swiper.params.updateOnImagesReady ) swiper.update();
5169 swiper.emit( 'imagesReady' );
5170 }
5171 }
5172
5173 for ( var i = 0; i < swiper.imagesToLoad.length; i += 1 ) {
5174 var imageEl = swiper.imagesToLoad[ i ];
5175 swiper.loadImage(
5176 imageEl,
5177 imageEl.currentSrc || imageEl.getAttribute( 'src' ),
5178 imageEl.srcset || imageEl.getAttribute( 'srcset' ),
5179 imageEl.sizes || imageEl.getAttribute( 'sizes' ),
5180 true,
5181 onReady
5182 );
5183 }
5184 }
5185
5186 var images = {
5187 loadImage: loadImage,
5188 preloadImages: preloadImages,
5189 };
5190
5191 function checkOverflow() {
5192 var swiper = this;
5193 var params = swiper.params;
5194 var wasLocked = swiper.isLocked;
5195 var lastSlidePosition =
5196 swiper.slides.length > 0 &&
5197 params.slidesOffsetBefore +
5198 params.spaceBetween * ( swiper.slides.length - 1 ) +
5199 swiper.slides[ 0 ].offsetWidth * swiper.slides.length;
5200
5201 if ( params.slidesOffsetBefore && params.slidesOffsetAfter && lastSlidePosition ) {
5202 swiper.isLocked = lastSlidePosition <= swiper.size;
5203 } else {
5204 swiper.isLocked = swiper.snapGrid.length === 1;
5205 }
5206
5207 swiper.allowSlideNext = ! swiper.isLocked;
5208 swiper.allowSlidePrev = ! swiper.isLocked; // events
5209
5210 if ( wasLocked !== swiper.isLocked ) swiper.emit( swiper.isLocked ? 'lock' : 'unlock' );
5211
5212 if ( wasLocked && wasLocked !== swiper.isLocked ) {
5213 swiper.isEnd = false;
5214 if ( swiper.navigation ) swiper.navigation.update();
5215 }
5216 }
5217
5218 var checkOverflow$1 = {
5219 checkOverflow: checkOverflow,
5220 };
5221
5222 var defaults = {
5223 init: true,
5224 direction: 'horizontal',
5225 touchEventsTarget: 'container',
5226 initialSlide: 0,
5227 speed: 300,
5228 cssMode: false,
5229 updateOnWindowResize: true,
5230 resizeObserver: false,
5231 nested: false,
5232 createElements: false,
5233 enabled: true,
5234 focusableElements: 'input, select, option, textarea, button, video, label',
5235 // Overrides
5236 width: null,
5237 height: null,
5238 //
5239 preventInteractionOnTransition: false,
5240 // ssr
5241 userAgent: null,
5242 url: null,
5243 // To support iOS's swipe-to-go-back gesture (when being used in-app).
5244 edgeSwipeDetection: false,
5245 edgeSwipeThreshold: 20,
5246 // Free mode
5247 freeMode: false,
5248 freeModeMomentum: true,
5249 freeModeMomentumRatio: 1,
5250 freeModeMomentumBounce: true,
5251 freeModeMomentumBounceRatio: 1,
5252 freeModeMomentumVelocityRatio: 1,
5253 freeModeSticky: false,
5254 freeModeMinimumVelocity: 0.02,
5255 // Autoheight
5256 autoHeight: false,
5257 // Set wrapper width
5258 setWrapperSize: false,
5259 // Virtual Translate
5260 virtualTranslate: false,
5261 // Effects
5262 effect: 'slide',
5263 // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
5264 // Breakpoints
5265 breakpoints: undefined,
5266 breakpointsBase: 'window',
5267 // Slides grid
5268 spaceBetween: 0,
5269 slidesPerView: 1,
5270 slidesPerColumn: 1,
5271 slidesPerColumnFill: 'column',
5272 slidesPerGroup: 1,
5273 slidesPerGroupSkip: 0,
5274 centeredSlides: false,
5275 centeredSlidesBounds: false,
5276 slidesOffsetBefore: 0,
5277 // in px
5278 slidesOffsetAfter: 0,
5279 // in px
5280 normalizeSlideIndex: true,
5281 centerInsufficientSlides: false,
5282 // Disable swiper and hide navigation when container not overflow
5283 watchOverflow: false,
5284 // Round length
5285 roundLengths: false,
5286 // Touches
5287 touchRatio: 1,
5288 touchAngle: 45,
5289 simulateTouch: true,
5290 shortSwipes: true,
5291 longSwipes: true,
5292 longSwipesRatio: 0.5,
5293 longSwipesMs: 300,
5294 followFinger: true,
5295 allowTouchMove: true,
5296 threshold: 0,
5297 touchMoveStopPropagation: false,
5298 touchStartPreventDefault: true,
5299 touchStartForcePreventDefault: false,
5300 touchReleaseOnEdges: false,
5301 // Unique Navigation Elements
5302 uniqueNavElements: true,
5303 // Resistance
5304 resistance: true,
5305 resistanceRatio: 0.85,
5306 // Progress
5307 watchSlidesProgress: false,
5308 watchSlidesVisibility: false,
5309 // Cursor
5310 grabCursor: false,
5311 // Clicks
5312 preventClicks: true,
5313 preventClicksPropagation: true,
5314 slideToClickedSlide: false,
5315 // Images
5316 preloadImages: true,
5317 updateOnImagesReady: true,
5318 // loop
5319 loop: false,
5320 loopAdditionalSlides: 0,
5321 loopedSlides: null,
5322 loopFillGroupWithBlank: false,
5323 loopPreventsSlide: true,
5324 // Swiping/no swiping
5325 allowSlidePrev: true,
5326 allowSlideNext: true,
5327 swipeHandler: null,
5328 // '.swipe-handler',
5329 noSwiping: true,
5330 noSwipingClass: 'swiper-no-swiping',
5331 noSwipingSelector: null,
5332 // Passive Listeners
5333 passiveListeners: true,
5334 // NS
5335 containerModifierClass: 'swiper-container-',
5336 // NEW
5337 slideClass: 'swiper-slide',
5338 slideBlankClass: 'swiper-slide-invisible-blank',
5339 slideActiveClass: 'swiper-slide-active',
5340 slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
5341 slideVisibleClass: 'swiper-slide-visible',
5342 slideDuplicateClass: 'swiper-slide-duplicate',
5343 slideNextClass: 'swiper-slide-next',
5344 slideDuplicateNextClass: 'swiper-slide-duplicate-next',
5345 slidePrevClass: 'swiper-slide-prev',
5346 slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
5347 wrapperClass: 'swiper-wrapper',
5348 // Callbacks
5349 runCallbacksOnInit: true,
5350 // Internals
5351 _emitClasses: false,
5352 };
5353
5354 var prototypes = {
5355 modular: modular,
5356 eventsEmitter: eventsEmitter,
5357 update: update,
5358 translate: translate,
5359 transition: transition,
5360 slide: slide,
5361 loop: loop,
5362 grabCursor: grabCursor,
5363 manipulation: manipulation,
5364 events: events,
5365 breakpoints: breakpoints,
5366 checkOverflow: checkOverflow$1,
5367 classes: classes,
5368 images: images,
5369 };
5370 var extendedDefaults = {};
5371
5372 var Swiper = /*#__PURE__*/ ( function () {
5373 function Swiper() {
5374 var el;
5375 var params;
5376
5377 for ( var _len = arguments.length, args = new Array( _len ), _key = 0; _key < _len; _key++ ) {
5378 args[ _key ] = arguments[ _key ];
5379 }
5380
5381 if (
5382 args.length === 1 &&
5383 args[ 0 ].constructor &&
5384 Object.prototype.toString.call( args[ 0 ] ).slice( 8, -1 ) === 'Object'
5385 ) {
5386 params = args[ 0 ];
5387 } else {
5388 el = args[ 0 ];
5389 params = args[ 1 ];
5390 }
5391
5392 if ( ! params ) params = {};
5393 params = extend( {}, params );
5394 if ( el && ! params.el ) params.el = el;
5395
5396 if ( params.el && $( params.el ).length > 1 ) {
5397 var swipers = [];
5398 $( params.el ).each( function ( containerEl ) {
5399 var newParams = extend( {}, params, {
5400 el: containerEl,
5401 } );
5402 swipers.push( new Swiper( newParams ) );
5403 } );
5404 return swipers;
5405 } // Swiper Instance
5406
5407 var swiper = this;
5408 swiper.__swiper__ = true;
5409 swiper.support = getSupport();
5410 swiper.device = getDevice( {
5411 userAgent: params.userAgent,
5412 } );
5413 swiper.browser = getBrowser();
5414 swiper.eventsListeners = {};
5415 swiper.eventsAnyListeners = [];
5416
5417 if ( typeof swiper.modules === 'undefined' ) {
5418 swiper.modules = {};
5419 }
5420
5421 Object.keys( swiper.modules ).forEach( function ( moduleName ) {
5422 var module = swiper.modules[ moduleName ];
5423
5424 if ( module.params ) {
5425 var moduleParamName = Object.keys( module.params )[ 0 ];
5426 var moduleParams = module.params[ moduleParamName ];
5427 if ( typeof moduleParams !== 'object' || moduleParams === null ) return;
5428
5429 if (
5430 [ 'navigation', 'pagination', 'scrollbar' ].indexOf( moduleParamName ) >= 0 &&
5431 params[ moduleParamName ] === true
5432 ) {
5433 params[ moduleParamName ] = {
5434 auto: true,
5435 };
5436 }
5437
5438 if ( ! ( moduleParamName in params && 'enabled' in moduleParams ) ) return;
5439
5440 if ( params[ moduleParamName ] === true ) {
5441 params[ moduleParamName ] = {
5442 enabled: true,
5443 };
5444 }
5445
5446 if (
5447 typeof params[ moduleParamName ] === 'object' &&
5448 ! ( 'enabled' in params[ moduleParamName ] )
5449 ) {
5450 params[ moduleParamName ].enabled = true;
5451 }
5452
5453 if ( ! params[ moduleParamName ] )
5454 params[ moduleParamName ] = {
5455 enabled: false,
5456 };
5457 }
5458 } ); // Extend defaults with modules params
5459
5460 var swiperParams = extend( {}, defaults );
5461 swiper.useParams( swiperParams ); // Extend defaults with passed params
5462
5463 swiper.params = extend( {}, swiperParams, extendedDefaults, params );
5464 swiper.originalParams = extend( {}, swiper.params );
5465 swiper.passedParams = extend( {}, params ); // add event listeners
5466
5467 if ( swiper.params && swiper.params.on ) {
5468 Object.keys( swiper.params.on ).forEach( function ( eventName ) {
5469 swiper.on( eventName, swiper.params.on[ eventName ] );
5470 } );
5471 }
5472
5473 if ( swiper.params && swiper.params.onAny ) {
5474 swiper.onAny( swiper.params.onAny );
5475 } // Save Dom lib
5476
5477 swiper.$ = $; // Extend Swiper
5478
5479 extend( swiper, {
5480 enabled: swiper.params.enabled,
5481 el: el,
5482 // Classes
5483 classNames: [],
5484 // Slides
5485 slides: $(),
5486 slidesGrid: [],
5487 snapGrid: [],
5488 slidesSizesGrid: [],
5489 // isDirection
5490 isHorizontal: function isHorizontal() {
5491 return swiper.params.direction === 'horizontal';
5492 },
5493 isVertical: function isVertical() {
5494 return swiper.params.direction === 'vertical';
5495 },
5496 // Indexes
5497 activeIndex: 0,
5498 realIndex: 0,
5499 //
5500 isBeginning: true,
5501 isEnd: false,
5502 // Props
5503 translate: 0,
5504 previousTranslate: 0,
5505 progress: 0,
5506 velocity: 0,
5507 animating: false,
5508 // Locks
5509 allowSlideNext: swiper.params.allowSlideNext,
5510 allowSlidePrev: swiper.params.allowSlidePrev,
5511 // Touch Events
5512 touchEvents: ( function touchEvents() {
5513 var touch = [ 'touchstart', 'touchmove', 'touchend', 'touchcancel' ];
5514 var desktop = [ 'mousedown', 'mousemove', 'mouseup' ];
5515
5516 if ( swiper.support.pointerEvents ) {
5517 desktop = [ 'pointerdown', 'pointermove', 'pointerup' ];
5518 }
5519
5520 swiper.touchEventsTouch = {
5521 start: touch[ 0 ],
5522 move: touch[ 1 ],
5523 end: touch[ 2 ],
5524 cancel: touch[ 3 ],
5525 };
5526 swiper.touchEventsDesktop = {
5527 start: desktop[ 0 ],
5528 move: desktop[ 1 ],
5529 end: desktop[ 2 ],
5530 };
5531 return swiper.support.touch || ! swiper.params.simulateTouch
5532 ? swiper.touchEventsTouch
5533 : swiper.touchEventsDesktop;
5534 } )(),
5535 touchEventsData: {
5536 isTouched: undefined,
5537 isMoved: undefined,
5538 allowTouchCallbacks: undefined,
5539 touchStartTime: undefined,
5540 isScrolling: undefined,
5541 currentTranslate: undefined,
5542 startTranslate: undefined,
5543 allowThresholdMove: undefined,
5544 // Form elements to match
5545 focusableElements: swiper.params.focusableElements,
5546 // Last click time
5547 lastClickTime: now(),
5548 clickTimeout: undefined,
5549 // Velocities
5550 velocities: [],
5551 allowMomentumBounce: undefined,
5552 isTouchEvent: undefined,
5553 startMoving: undefined,
5554 },
5555 // Clicks
5556 allowClick: true,
5557 // Touches
5558 allowTouchMove: swiper.params.allowTouchMove,
5559 touches: {
5560 startX: 0,
5561 startY: 0,
5562 currentX: 0,
5563 currentY: 0,
5564 diff: 0,
5565 },
5566 // Images
5567 imagesToLoad: [],
5568 imagesLoaded: 0,
5569 } ); // Install Modules
5570
5571 swiper.useModules();
5572 swiper.emit( '_swiper' ); // Init
5573
5574 if ( swiper.params.init ) {
5575 swiper.init();
5576 } // Return app instance
5577
5578 return swiper;
5579 }
5580
5581 var _proto = Swiper.prototype;
5582
5583 _proto.enable = function enable() {
5584 var swiper = this;
5585 if ( swiper.enabled ) return;
5586 swiper.enabled = true;
5587
5588 if ( swiper.params.grabCursor ) {
5589 swiper.setGrabCursor();
5590 }
5591
5592 swiper.emit( 'enable' );
5593 };
5594
5595 _proto.disable = function disable() {
5596 var swiper = this;
5597 if ( ! swiper.enabled ) return;
5598 swiper.enabled = false;
5599
5600 if ( swiper.params.grabCursor ) {
5601 swiper.unsetGrabCursor();
5602 }
5603
5604 swiper.emit( 'disable' );
5605 };
5606
5607 _proto.setProgress = function setProgress( progress, speed ) {
5608 var swiper = this;
5609 progress = Math.min( Math.max( progress, 0 ), 1 );
5610 var min = swiper.minTranslate();
5611 var max = swiper.maxTranslate();
5612 var current = ( max - min ) * progress + min;
5613 swiper.translateTo( current, typeof speed === 'undefined' ? 0 : speed );
5614 swiper.updateActiveIndex();
5615 swiper.updateSlidesClasses();
5616 };
5617
5618 _proto.emitContainerClasses = function emitContainerClasses() {
5619 var swiper = this;
5620 if ( ! swiper.params._emitClasses || ! swiper.el ) return;
5621 var classes = swiper.el.className.split( ' ' ).filter( function ( className ) {
5622 return (
5623 className.indexOf( 'swiper-container' ) === 0 ||
5624 className.indexOf( swiper.params.containerModifierClass ) === 0
5625 );
5626 } );
5627 swiper.emit( '_containerClasses', classes.join( ' ' ) );
5628 };
5629
5630 _proto.getSlideClasses = function getSlideClasses( slideEl ) {
5631 var swiper = this;
5632 return slideEl.className
5633 .split( ' ' )
5634 .filter( function ( className ) {
5635 return (
5636 className.indexOf( 'swiper-slide' ) === 0 ||
5637 className.indexOf( swiper.params.slideClass ) === 0
5638 );
5639 } )
5640 .join( ' ' );
5641 };
5642
5643 _proto.emitSlidesClasses = function emitSlidesClasses() {
5644 var swiper = this;
5645 if ( ! swiper.params._emitClasses || ! swiper.el ) return;
5646 var updates = [];
5647 swiper.slides.each( function ( slideEl ) {
5648 var classNames = swiper.getSlideClasses( slideEl );
5649 updates.push( {
5650 slideEl: slideEl,
5651 classNames: classNames,
5652 } );
5653 swiper.emit( '_slideClass', slideEl, classNames );
5654 } );
5655 swiper.emit( '_slideClasses', updates );
5656 };
5657
5658 _proto.slidesPerViewDynamic = function slidesPerViewDynamic() {
5659 var swiper = this;
5660 var params = swiper.params,
5661 slides = swiper.slides,
5662 slidesGrid = swiper.slidesGrid,
5663 swiperSize = swiper.size,
5664 activeIndex = swiper.activeIndex;
5665 var spv = 1;
5666
5667 if ( params.centeredSlides ) {
5668 var slideSize = slides[ activeIndex ].swiperSlideSize;
5669 var breakLoop;
5670
5671 for ( var i = activeIndex + 1; i < slides.length; i += 1 ) {
5672 if ( slides[ i ] && ! breakLoop ) {
5673 slideSize += slides[ i ].swiperSlideSize;
5674 spv += 1;
5675 if ( slideSize > swiperSize ) breakLoop = true;
5676 }
5677 }
5678
5679 for ( var _i = activeIndex - 1; _i >= 0; _i -= 1 ) {
5680 if ( slides[ _i ] && ! breakLoop ) {
5681 slideSize += slides[ _i ].swiperSlideSize;
5682 spv += 1;
5683 if ( slideSize > swiperSize ) breakLoop = true;
5684 }
5685 }
5686 } else {
5687 for ( var _i2 = activeIndex + 1; _i2 < slides.length; _i2 += 1 ) {
5688 if ( slidesGrid[ _i2 ] - slidesGrid[ activeIndex ] < swiperSize ) {
5689 spv += 1;
5690 }
5691 }
5692 }
5693
5694 return spv;
5695 };
5696
5697 _proto.update = function update() {
5698 var swiper = this;
5699 if ( ! swiper || swiper.destroyed ) return;
5700 var snapGrid = swiper.snapGrid,
5701 params = swiper.params; // Breakpoints
5702
5703 if ( params.breakpoints ) {
5704 swiper.setBreakpoint();
5705 }
5706
5707 swiper.updateSize();
5708 swiper.updateSlides();
5709 swiper.updateProgress();
5710 swiper.updateSlidesClasses();
5711
5712 function setTranslate() {
5713 var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
5714 var newTranslate = Math.min(
5715 Math.max( translateValue, swiper.maxTranslate() ),
5716 swiper.minTranslate()
5717 );
5718 swiper.setTranslate( newTranslate );
5719 swiper.updateActiveIndex();
5720 swiper.updateSlidesClasses();
5721 }
5722
5723 var translated;
5724
5725 if ( swiper.params.freeMode ) {
5726 setTranslate();
5727
5728 if ( swiper.params.autoHeight ) {
5729 swiper.updateAutoHeight();
5730 }
5731 } else {
5732 if (
5733 ( swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1 ) &&
5734 swiper.isEnd &&
5735 ! swiper.params.centeredSlides
5736 ) {
5737 translated = swiper.slideTo( swiper.slides.length - 1, 0, false, true );
5738 } else {
5739 translated = swiper.slideTo( swiper.activeIndex, 0, false, true );
5740 }
5741
5742 if ( ! translated ) {
5743 setTranslate();
5744 }
5745 }
5746
5747 if ( params.watchOverflow && snapGrid !== swiper.snapGrid ) {
5748 swiper.checkOverflow();
5749 }
5750
5751 swiper.emit( 'update' );
5752 };
5753
5754 _proto.changeDirection = function changeDirection( newDirection, needUpdate ) {
5755 if ( needUpdate === void 0 ) {
5756 needUpdate = true;
5757 }
5758
5759 var swiper = this;
5760 var currentDirection = swiper.params.direction;
5761
5762 if ( ! newDirection ) {
5763 // eslint-disable-next-line
5764 newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
5765 }
5766
5767 if (
5768 newDirection === currentDirection ||
5769 ( newDirection !== 'horizontal' && newDirection !== 'vertical' )
5770 ) {
5771 return swiper;
5772 }
5773
5774 swiper.$el
5775 .removeClass( '' + swiper.params.containerModifierClass + currentDirection )
5776 .addClass( '' + swiper.params.containerModifierClass + newDirection );
5777 swiper.emitContainerClasses();
5778 swiper.params.direction = newDirection;
5779 swiper.slides.each( function ( slideEl ) {
5780 if ( newDirection === 'vertical' ) {
5781 slideEl.style.width = '';
5782 } else {
5783 slideEl.style.height = '';
5784 }
5785 } );
5786 swiper.emit( 'changeDirection' );
5787 if ( needUpdate ) swiper.update();
5788 return swiper;
5789 };
5790
5791 _proto.mount = function mount( el ) {
5792 var swiper = this;
5793 if ( swiper.mounted ) return true; // Find el
5794
5795 var $el = $( el || swiper.params.el );
5796 el = $el[ 0 ];
5797
5798 if ( ! el ) {
5799 return false;
5800 }
5801
5802 el.swiper = swiper;
5803
5804 var getWrapperSelector = function getWrapperSelector() {
5805 return '.' + ( swiper.params.wrapperClass || '' ).trim().split( ' ' ).join( '.' );
5806 };
5807
5808 var getWrapper = function getWrapper() {
5809 if ( el && el.shadowRoot && el.shadowRoot.querySelector ) {
5810 var res = $( el.shadowRoot.querySelector( getWrapperSelector() ) ); // Children needs to return slot items
5811
5812 res.children = function ( options ) {
5813 return $el.children( options );
5814 };
5815
5816 return res;
5817 }
5818
5819 return $el.children( getWrapperSelector() );
5820 }; // Find Wrapper
5821
5822 var $wrapperEl = getWrapper();
5823
5824 if ( $wrapperEl.length === 0 && swiper.params.createElements ) {
5825 var document = getDocument();
5826 var wrapper = document.createElement( 'div' );
5827 $wrapperEl = $( wrapper );
5828 wrapper.className = swiper.params.wrapperClass;
5829 $el.append( wrapper );
5830 $el.children( '.' + swiper.params.slideClass ).each( function ( slideEl ) {
5831 $wrapperEl.append( slideEl );
5832 } );
5833 }
5834
5835 extend( swiper, {
5836 $el: $el,
5837 el: el,
5838 $wrapperEl: $wrapperEl,
5839 wrapperEl: $wrapperEl[ 0 ],
5840 mounted: true,
5841 // RTL
5842 rtl: el.dir.toLowerCase() === 'rtl' || $el.css( 'direction' ) === 'rtl',
5843 rtlTranslate:
5844 swiper.params.direction === 'horizontal' &&
5845 ( el.dir.toLowerCase() === 'rtl' || $el.css( 'direction' ) === 'rtl' ),
5846 wrongRTL: $wrapperEl.css( 'display' ) === '-webkit-box',
5847 } );
5848 return true;
5849 };
5850
5851 _proto.init = function init( el ) {
5852 var swiper = this;
5853 if ( swiper.initialized ) return swiper;
5854 var mounted = swiper.mount( el );
5855 if ( mounted === false ) return swiper;
5856 swiper.emit( 'beforeInit' ); // Set breakpoint
5857
5858 if ( swiper.params.breakpoints ) {
5859 swiper.setBreakpoint();
5860 } // Add Classes
5861
5862 swiper.addClasses(); // Create loop
5863
5864 if ( swiper.params.loop ) {
5865 swiper.loopCreate();
5866 } // Update size
5867
5868 swiper.updateSize(); // Update slides
5869
5870 swiper.updateSlides();
5871
5872 if ( swiper.params.watchOverflow ) {
5873 swiper.checkOverflow();
5874 } // Set Grab Cursor
5875
5876 if ( swiper.params.grabCursor && swiper.enabled ) {
5877 swiper.setGrabCursor();
5878 }
5879
5880 if ( swiper.params.preloadImages ) {
5881 swiper.preloadImages();
5882 } // Slide To Initial Slide
5883
5884 if ( swiper.params.loop ) {
5885 swiper.slideTo(
5886 swiper.params.initialSlide + swiper.loopedSlides,
5887 0,
5888 swiper.params.runCallbacksOnInit,
5889 false,
5890 true
5891 );
5892 } else {
5893 swiper.slideTo(
5894 swiper.params.initialSlide,
5895 0,
5896 swiper.params.runCallbacksOnInit,
5897 false,
5898 true
5899 );
5900 } // Attach events
5901
5902 swiper.attachEvents(); // Init Flag
5903
5904 swiper.initialized = true; // Emit
5905
5906 swiper.emit( 'init' );
5907 swiper.emit( 'afterInit' );
5908 return swiper;
5909 };
5910
5911 _proto.destroy = function destroy( deleteInstance, cleanStyles ) {
5912 if ( deleteInstance === void 0 ) {
5913 deleteInstance = true;
5914 }
5915
5916 if ( cleanStyles === void 0 ) {
5917 cleanStyles = true;
5918 }
5919
5920 var swiper = this;
5921 var params = swiper.params,
5922 $el = swiper.$el,
5923 $wrapperEl = swiper.$wrapperEl,
5924 slides = swiper.slides;
5925
5926 if ( typeof swiper.params === 'undefined' || swiper.destroyed ) {
5927 return null;
5928 }
5929
5930 swiper.emit( 'beforeDestroy' ); // Init Flag
5931
5932 swiper.initialized = false; // Detach events
5933
5934 swiper.detachEvents(); // Destroy loop
5935
5936 if ( params.loop ) {
5937 swiper.loopDestroy();
5938 } // Cleanup styles
5939
5940 if ( cleanStyles ) {
5941 swiper.removeClasses();
5942 $el.removeAttr( 'style' );
5943 $wrapperEl.removeAttr( 'style' );
5944
5945 if ( slides && slides.length ) {
5946 slides
5947 .removeClass(
5948 [
5949 params.slideVisibleClass,
5950 params.slideActiveClass,
5951 params.slideNextClass,
5952 params.slidePrevClass,
5953 ].join( ' ' )
5954 )
5955 .removeAttr( 'style' )
5956 .removeAttr( 'data-swiper-slide-index' );
5957 }
5958 }
5959
5960 swiper.emit( 'destroy' ); // Detach emitter events
5961
5962 Object.keys( swiper.eventsListeners ).forEach( function ( eventName ) {
5963 swiper.off( eventName );
5964 } );
5965
5966 if ( deleteInstance !== false ) {
5967 swiper.$el[ 0 ].swiper = null;
5968 deleteProps( swiper );
5969 }
5970
5971 swiper.destroyed = true;
5972 return null;
5973 };
5974
5975 Swiper.extendDefaults = function extendDefaults( newDefaults ) {
5976 extend( extendedDefaults, newDefaults );
5977 };
5978
5979 Swiper.installModule = function installModule( module ) {
5980 if ( ! Swiper.prototype.modules ) Swiper.prototype.modules = {};
5981 var name = module.name || Object.keys( Swiper.prototype.modules ).length + '_' + now();
5982 Swiper.prototype.modules[ name ] = module;
5983 };
5984
5985 Swiper.use = function use( module ) {
5986 if ( Array.isArray( module ) ) {
5987 module.forEach( function ( m ) {
5988 return Swiper.installModule( m );
5989 } );
5990 return Swiper;
5991 }
5992
5993 Swiper.installModule( module );
5994 return Swiper;
5995 };
5996
5997 _createClass( Swiper, null, [
5998 {
5999 key: 'extendedDefaults',
6000 get: function get() {
6001 return extendedDefaults;
6002 },
6003 },
6004 {
6005 key: 'defaults',
6006 get: function get() {
6007 return defaults;
6008 },
6009 },
6010 ] );
6011
6012 return Swiper;
6013 } )();
6014
6015 Object.keys( prototypes ).forEach( function ( prototypeGroup ) {
6016 Object.keys( prototypes[ prototypeGroup ] ).forEach( function ( protoMethod ) {
6017 Swiper.prototype[ protoMethod ] = prototypes[ prototypeGroup ][ protoMethod ];
6018 } );
6019 } );
6020 Swiper.use( [ Resize, Observer$1 ] );
6021
6022 var Navigation = {
6023 toggleEl: function toggleEl( $el, disabled ) {
6024 $el[ disabled ? 'addClass' : 'removeClass' ]( this.params.navigation.disabledClass );
6025 if ( $el[ 0 ] && $el[ 0 ].tagName === 'BUTTON' ) $el[ 0 ].disabled = disabled;
6026 },
6027 update: function update() {
6028 // Update Navigation Buttons
6029 var swiper = this;
6030 var params = swiper.params.navigation;
6031 var toggleEl = swiper.navigation.toggleEl;
6032 if ( swiper.params.loop ) return;
6033 var _swiper$navigation = swiper.navigation,
6034 $nextEl = _swiper$navigation.$nextEl,
6035 $prevEl = _swiper$navigation.$prevEl;
6036
6037 if ( $prevEl && $prevEl.length > 0 ) {
6038 if ( swiper.isBeginning ) {
6039 toggleEl( $prevEl, true );
6040 } else {
6041 toggleEl( $prevEl, false );
6042 }
6043
6044 if ( swiper.params.watchOverflow && swiper.enabled ) {
6045 $prevEl[ swiper.isLocked ? 'addClass' : 'removeClass' ]( params.lockClass );
6046 }
6047 }
6048
6049 if ( $nextEl && $nextEl.length > 0 ) {
6050 if ( swiper.isEnd ) {
6051 toggleEl( $nextEl, true );
6052 } else {
6053 toggleEl( $nextEl, false );
6054 }
6055
6056 if ( swiper.params.watchOverflow && swiper.enabled ) {
6057 $nextEl[ swiper.isLocked ? 'addClass' : 'removeClass' ]( params.lockClass );
6058 }
6059 }
6060 },
6061 onPrevClick: function onPrevClick( e ) {
6062 var swiper = this;
6063 e.preventDefault();
6064 if ( swiper.isBeginning && ! swiper.params.loop ) return;
6065 swiper.slidePrev();
6066 },
6067 onNextClick: function onNextClick( e ) {
6068 var swiper = this;
6069 e.preventDefault();
6070 if ( swiper.isEnd && ! swiper.params.loop ) return;
6071 swiper.slideNext();
6072 },
6073 init: function init() {
6074 var swiper = this;
6075 var params = swiper.params.navigation;
6076 swiper.params.navigation = createElementIfNotDefined(
6077 swiper.$el,
6078 swiper.params.navigation,
6079 swiper.params.createElements,
6080 {
6081 nextEl: 'swiper-button-next',
6082 prevEl: 'swiper-button-prev',
6083 }
6084 );
6085 if ( ! ( params.nextEl || params.prevEl ) ) return;
6086 var $nextEl;
6087 var $prevEl;
6088
6089 if ( params.nextEl ) {
6090 $nextEl = $( params.nextEl );
6091
6092 if (
6093 swiper.params.uniqueNavElements &&
6094 typeof params.nextEl === 'string' &&
6095 $nextEl.length > 1 &&
6096 swiper.$el.find( params.nextEl ).length === 1
6097 ) {
6098 $nextEl = swiper.$el.find( params.nextEl );
6099 }
6100 }
6101
6102 if ( params.prevEl ) {
6103 $prevEl = $( params.prevEl );
6104
6105 if (
6106 swiper.params.uniqueNavElements &&
6107 typeof params.prevEl === 'string' &&
6108 $prevEl.length > 1 &&
6109 swiper.$el.find( params.prevEl ).length === 1
6110 ) {
6111 $prevEl = swiper.$el.find( params.prevEl );
6112 }
6113 }
6114
6115 if ( $nextEl && $nextEl.length > 0 ) {
6116 $nextEl.on( 'click', swiper.navigation.onNextClick );
6117 }
6118
6119 if ( $prevEl && $prevEl.length > 0 ) {
6120 $prevEl.on( 'click', swiper.navigation.onPrevClick );
6121 }
6122
6123 extend( swiper.navigation, {
6124 $nextEl: $nextEl,
6125 nextEl: $nextEl && $nextEl[ 0 ],
6126 $prevEl: $prevEl,
6127 prevEl: $prevEl && $prevEl[ 0 ],
6128 } );
6129
6130 if ( ! swiper.enabled ) {
6131 if ( $nextEl ) $nextEl.addClass( params.lockClass );
6132 if ( $prevEl ) $prevEl.addClass( params.lockClass );
6133 }
6134 },
6135 destroy: function destroy() {
6136 var swiper = this;
6137 var _swiper$navigation2 = swiper.navigation,
6138 $nextEl = _swiper$navigation2.$nextEl,
6139 $prevEl = _swiper$navigation2.$prevEl;
6140
6141 if ( $nextEl && $nextEl.length ) {
6142 $nextEl.off( 'click', swiper.navigation.onNextClick );
6143 $nextEl.removeClass( swiper.params.navigation.disabledClass );
6144 }
6145
6146 if ( $prevEl && $prevEl.length ) {
6147 $prevEl.off( 'click', swiper.navigation.onPrevClick );
6148 $prevEl.removeClass( swiper.params.navigation.disabledClass );
6149 }
6150 },
6151 };
6152 var Navigation$1 = {
6153 name: 'navigation',
6154 params: {
6155 navigation: {
6156 nextEl: null,
6157 prevEl: null,
6158 hideOnClick: false,
6159 disabledClass: 'swiper-button-disabled',
6160 hiddenClass: 'swiper-button-hidden',
6161 lockClass: 'swiper-button-lock',
6162 },
6163 },
6164 create: function create() {
6165 var swiper = this;
6166 bindModuleMethods( swiper, {
6167 navigation: _extends( {}, Navigation ),
6168 } );
6169 },
6170 on: {
6171 init: function init( swiper ) {
6172 swiper.navigation.init();
6173 swiper.navigation.update();
6174 },
6175 toEdge: function toEdge( swiper ) {
6176 swiper.navigation.update();
6177 },
6178 fromEdge: function fromEdge( swiper ) {
6179 swiper.navigation.update();
6180 },
6181 destroy: function destroy( swiper ) {
6182 swiper.navigation.destroy();
6183 },
6184 'enable disable': function enableDisable( swiper ) {
6185 var _swiper$navigation3 = swiper.navigation,
6186 $nextEl = _swiper$navigation3.$nextEl,
6187 $prevEl = _swiper$navigation3.$prevEl;
6188
6189 if ( $nextEl ) {
6190 $nextEl[ swiper.enabled ? 'removeClass' : 'addClass' ](
6191 swiper.params.navigation.lockClass
6192 );
6193 }
6194
6195 if ( $prevEl ) {
6196 $prevEl[ swiper.enabled ? 'removeClass' : 'addClass' ](
6197 swiper.params.navigation.lockClass
6198 );
6199 }
6200 },
6201 click: function click( swiper, e ) {
6202 var _swiper$navigation4 = swiper.navigation,
6203 $nextEl = _swiper$navigation4.$nextEl,
6204 $prevEl = _swiper$navigation4.$prevEl;
6205 var targetEl = e.target;
6206
6207 if (
6208 swiper.params.navigation.hideOnClick &&
6209 ! $( targetEl ).is( $prevEl ) &&
6210 ! $( targetEl ).is( $nextEl )
6211 ) {
6212 if (
6213 swiper.pagination &&
6214 swiper.params.pagination &&
6215 swiper.params.pagination.clickable &&
6216 ( swiper.pagination.el === targetEl || swiper.pagination.el.contains( targetEl ) )
6217 )
6218 return;
6219 var isHidden;
6220
6221 if ( $nextEl ) {
6222 isHidden = $nextEl.hasClass( swiper.params.navigation.hiddenClass );
6223 } else if ( $prevEl ) {
6224 isHidden = $prevEl.hasClass( swiper.params.navigation.hiddenClass );
6225 }
6226
6227 if ( isHidden === true ) {
6228 swiper.emit( 'navigationShow' );
6229 } else {
6230 swiper.emit( 'navigationHide' );
6231 }
6232
6233 if ( $nextEl ) {
6234 $nextEl.toggleClass( swiper.params.navigation.hiddenClass );
6235 }
6236
6237 if ( $prevEl ) {
6238 $prevEl.toggleClass( swiper.params.navigation.hiddenClass );
6239 }
6240 }
6241 },
6242 },
6243 };
6244
6245 var Pagination = {
6246 update: function update() {
6247 // Render || Update Pagination bullets/items
6248 var swiper = this;
6249 var rtl = swiper.rtl;
6250 var params = swiper.params.pagination;
6251 if (
6252 ! params.el ||
6253 ! swiper.pagination.el ||
6254 ! swiper.pagination.$el ||
6255 swiper.pagination.$el.length === 0
6256 )
6257 return;
6258 var slidesLength =
6259 swiper.virtual && swiper.params.virtual.enabled
6260 ? swiper.virtual.slides.length
6261 : swiper.slides.length;
6262 var $el = swiper.pagination.$el; // Current/Total
6263
6264 var current;
6265 var total = swiper.params.loop
6266 ? Math.ceil( ( slidesLength - swiper.loopedSlides * 2 ) / swiper.params.slidesPerGroup )
6267 : swiper.snapGrid.length;
6268
6269 if ( swiper.params.loop ) {
6270 current = Math.ceil(
6271 ( swiper.activeIndex - swiper.loopedSlides ) / swiper.params.slidesPerGroup
6272 );
6273
6274 if ( current > slidesLength - 1 - swiper.loopedSlides * 2 ) {
6275 current -= slidesLength - swiper.loopedSlides * 2;
6276 }
6277
6278 if ( current > total - 1 ) current -= total;
6279 if ( current < 0 && swiper.params.paginationType !== 'bullets' ) current = total + current;
6280 } else if ( typeof swiper.snapIndex !== 'undefined' ) {
6281 current = swiper.snapIndex;
6282 } else {
6283 current = swiper.activeIndex || 0;
6284 } // Types
6285
6286 if (
6287 params.type === 'bullets' &&
6288 swiper.pagination.bullets &&
6289 swiper.pagination.bullets.length > 0
6290 ) {
6291 var bullets = swiper.pagination.bullets;
6292 var firstIndex;
6293 var lastIndex;
6294 var midIndex;
6295
6296 if ( params.dynamicBullets ) {
6297 swiper.pagination.bulletSize = bullets
6298 .eq( 0 )
6299 [ swiper.isHorizontal() ? 'outerWidth' : 'outerHeight' ]( true );
6300 $el.css(
6301 swiper.isHorizontal() ? 'width' : 'height',
6302 swiper.pagination.bulletSize * ( params.dynamicMainBullets + 4 ) + 'px'
6303 );
6304
6305 if ( params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined ) {
6306 swiper.pagination.dynamicBulletIndex += current - swiper.previousIndex;
6307
6308 if ( swiper.pagination.dynamicBulletIndex > params.dynamicMainBullets - 1 ) {
6309 swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1;
6310 } else if ( swiper.pagination.dynamicBulletIndex < 0 ) {
6311 swiper.pagination.dynamicBulletIndex = 0;
6312 }
6313 }
6314
6315 firstIndex = current - swiper.pagination.dynamicBulletIndex;
6316 lastIndex = firstIndex + ( Math.min( bullets.length, params.dynamicMainBullets ) - 1 );
6317 midIndex = ( lastIndex + firstIndex ) / 2;
6318 }
6319
6320 bullets.removeClass(
6321 params.bulletActiveClass +
6322 ' ' +
6323 params.bulletActiveClass +
6324 '-next ' +
6325 params.bulletActiveClass +
6326 '-next-next ' +
6327 params.bulletActiveClass +
6328 '-prev ' +
6329 params.bulletActiveClass +
6330 '-prev-prev ' +
6331 params.bulletActiveClass +
6332 '-main'
6333 );
6334
6335 if ( $el.length > 1 ) {
6336 bullets.each( function ( bullet ) {
6337 var $bullet = $( bullet );
6338 var bulletIndex = $bullet.index();
6339
6340 if ( bulletIndex === current ) {
6341 $bullet.addClass( params.bulletActiveClass );
6342 }
6343
6344 if ( params.dynamicBullets ) {
6345 if ( bulletIndex >= firstIndex && bulletIndex <= lastIndex ) {
6346 $bullet.addClass( params.bulletActiveClass + '-main' );
6347 }
6348
6349 if ( bulletIndex === firstIndex ) {
6350 $bullet
6351 .prev()
6352 .addClass( params.bulletActiveClass + '-prev' )
6353 .prev()
6354 .addClass( params.bulletActiveClass + '-prev-prev' );
6355 }
6356
6357 if ( bulletIndex === lastIndex ) {
6358 $bullet
6359 .next()
6360 .addClass( params.bulletActiveClass + '-next' )
6361 .next()
6362 .addClass( params.bulletActiveClass + '-next-next' );
6363 }
6364 }
6365 } );
6366 } else {
6367 var $bullet = bullets.eq( current );
6368 var bulletIndex = $bullet.index();
6369 $bullet.addClass( params.bulletActiveClass );
6370
6371 if ( params.dynamicBullets ) {
6372 var $firstDisplayedBullet = bullets.eq( firstIndex );
6373 var $lastDisplayedBullet = bullets.eq( lastIndex );
6374
6375 for ( var i = firstIndex; i <= lastIndex; i += 1 ) {
6376 bullets.eq( i ).addClass( params.bulletActiveClass + '-main' );
6377 }
6378
6379 if ( swiper.params.loop ) {
6380 if ( bulletIndex >= bullets.length - params.dynamicMainBullets ) {
6381 for ( var _i = params.dynamicMainBullets; _i >= 0; _i -= 1 ) {
6382 bullets.eq( bullets.length - _i ).addClass( params.bulletActiveClass + '-main' );
6383 }
6384
6385 bullets
6386 .eq( bullets.length - params.dynamicMainBullets - 1 )
6387 .addClass( params.bulletActiveClass + '-prev' );
6388 } else {
6389 $firstDisplayedBullet
6390 .prev()
6391 .addClass( params.bulletActiveClass + '-prev' )
6392 .prev()
6393 .addClass( params.bulletActiveClass + '-prev-prev' );
6394 $lastDisplayedBullet
6395 .next()
6396 .addClass( params.bulletActiveClass + '-next' )
6397 .next()
6398 .addClass( params.bulletActiveClass + '-next-next' );
6399 }
6400 } else {
6401 $firstDisplayedBullet
6402 .prev()
6403 .addClass( params.bulletActiveClass + '-prev' )
6404 .prev()
6405 .addClass( params.bulletActiveClass + '-prev-prev' );
6406 $lastDisplayedBullet
6407 .next()
6408 .addClass( params.bulletActiveClass + '-next' )
6409 .next()
6410 .addClass( params.bulletActiveClass + '-next-next' );
6411 }
6412 }
6413 }
6414
6415 if ( params.dynamicBullets ) {
6416 var dynamicBulletsLength = Math.min( bullets.length, params.dynamicMainBullets + 4 );
6417 var bulletsOffset =
6418 ( swiper.pagination.bulletSize * dynamicBulletsLength - swiper.pagination.bulletSize ) /
6419 2 -
6420 midIndex * swiper.pagination.bulletSize;
6421 var offsetProp = rtl ? 'right' : 'left';
6422 bullets.css( swiper.isHorizontal() ? offsetProp : 'top', bulletsOffset + 'px' );
6423 }
6424 }
6425
6426 if ( params.type === 'fraction' ) {
6427 $el
6428 .find( classesToSelector( params.currentClass ) )
6429 .text( params.formatFractionCurrent( current + 1 ) );
6430 $el
6431 .find( classesToSelector( params.totalClass ) )
6432 .text( params.formatFractionTotal( total ) );
6433 }
6434
6435 if ( params.type === 'progressbar' ) {
6436 var progressbarDirection;
6437
6438 if ( params.progressbarOpposite ) {
6439 progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
6440 } else {
6441 progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
6442 }
6443
6444 var scale = ( current + 1 ) / total;
6445 var scaleX = 1;
6446 var scaleY = 1;
6447
6448 if ( progressbarDirection === 'horizontal' ) {
6449 scaleX = scale;
6450 } else {
6451 scaleY = scale;
6452 }
6453
6454 $el
6455 .find( classesToSelector( params.progressbarFillClass ) )
6456 .transform( 'translate3d(0,0,0) scaleX(' + scaleX + ') scaleY(' + scaleY + ')' )
6457 .transition( swiper.params.speed );
6458 }
6459
6460 if ( params.type === 'custom' && params.renderCustom ) {
6461 $el.html( params.renderCustom( swiper, current + 1, total ) );
6462 swiper.emit( 'paginationRender', $el[ 0 ] );
6463 } else {
6464 swiper.emit( 'paginationUpdate', $el[ 0 ] );
6465 }
6466
6467 if ( swiper.params.watchOverflow && swiper.enabled ) {
6468 $el[ swiper.isLocked ? 'addClass' : 'removeClass' ]( params.lockClass );
6469 }
6470 },
6471 render: function render() {
6472 // Render Container
6473 var swiper = this;
6474 var params = swiper.params.pagination;
6475 if (
6476 ! params.el ||
6477 ! swiper.pagination.el ||
6478 ! swiper.pagination.$el ||
6479 swiper.pagination.$el.length === 0
6480 )
6481 return;
6482 var slidesLength =
6483 swiper.virtual && swiper.params.virtual.enabled
6484 ? swiper.virtual.slides.length
6485 : swiper.slides.length;
6486 var $el = swiper.pagination.$el;
6487 var paginationHTML = '';
6488
6489 if ( params.type === 'bullets' ) {
6490 var numberOfBullets = swiper.params.loop
6491 ? Math.ceil( ( slidesLength - swiper.loopedSlides * 2 ) / swiper.params.slidesPerGroup )
6492 : swiper.snapGrid.length;
6493
6494 if ( swiper.params.freeMode && ! swiper.params.loop && numberOfBullets > slidesLength ) {
6495 numberOfBullets = slidesLength;
6496 }
6497
6498 for ( var i = 0; i < numberOfBullets; i += 1 ) {
6499 if ( params.renderBullet ) {
6500 paginationHTML += params.renderBullet.call( swiper, i, params.bulletClass );
6501 } else {
6502 paginationHTML +=
6503 '<' +
6504 params.bulletElement +
6505 ' class="' +
6506 params.bulletClass +
6507 '"></' +
6508 params.bulletElement +
6509 '>';
6510 }
6511 }
6512
6513 $el.html( paginationHTML );
6514 swiper.pagination.bullets = $el.find( classesToSelector( params.bulletClass ) );
6515 }
6516
6517 if ( params.type === 'fraction' ) {
6518 if ( params.renderFraction ) {
6519 paginationHTML = params.renderFraction.call(
6520 swiper,
6521 params.currentClass,
6522 params.totalClass
6523 );
6524 } else {
6525 paginationHTML =
6526 '<span class="' +
6527 params.currentClass +
6528 '"></span>' +
6529 ' / ' +
6530 ( '<span class="' + params.totalClass + '"></span>' );
6531 }
6532
6533 $el.html( paginationHTML );
6534 }
6535
6536 if ( params.type === 'progressbar' ) {
6537 if ( params.renderProgressbar ) {
6538 paginationHTML = params.renderProgressbar.call( swiper, params.progressbarFillClass );
6539 } else {
6540 paginationHTML = '<span class="' + params.progressbarFillClass + '"></span>';
6541 }
6542
6543 $el.html( paginationHTML );
6544 }
6545
6546 if ( params.type !== 'custom' ) {
6547 swiper.emit( 'paginationRender', swiper.pagination.$el[ 0 ] );
6548 }
6549 },
6550 init: function init() {
6551 var swiper = this;
6552 swiper.params.pagination = createElementIfNotDefined(
6553 swiper.$el,
6554 swiper.params.pagination,
6555 swiper.params.createElements,
6556 {
6557 el: 'swiper-pagination',
6558 }
6559 );
6560 var params = swiper.params.pagination;
6561 if ( ! params.el ) return;
6562 var $el = $( params.el );
6563 if ( $el.length === 0 ) return;
6564
6565 if ( swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 ) {
6566 $el = swiper.$el.find( params.el );
6567 }
6568
6569 if ( params.type === 'bullets' && params.clickable ) {
6570 $el.addClass( params.clickableClass );
6571 }
6572
6573 $el.addClass( params.modifierClass + params.type );
6574
6575 if ( params.type === 'bullets' && params.dynamicBullets ) {
6576 $el.addClass( '' + params.modifierClass + params.type + '-dynamic' );
6577 swiper.pagination.dynamicBulletIndex = 0;
6578
6579 if ( params.dynamicMainBullets < 1 ) {
6580 params.dynamicMainBullets = 1;
6581 }
6582 }
6583
6584 if ( params.type === 'progressbar' && params.progressbarOpposite ) {
6585 $el.addClass( params.progressbarOppositeClass );
6586 }
6587
6588 if ( params.clickable ) {
6589 $el.on( 'click', classesToSelector( params.bulletClass ), function onClick( e ) {
6590 e.preventDefault();
6591 var index = $( this ).index() * swiper.params.slidesPerGroup;
6592 if ( swiper.params.loop ) index += swiper.loopedSlides;
6593 swiper.slideTo( index );
6594 } );
6595 }
6596
6597 extend( swiper.pagination, {
6598 $el: $el,
6599 el: $el[ 0 ],
6600 } );
6601
6602 if ( ! swiper.enabled ) {
6603 $el.addClass( params.lockClass );
6604 }
6605 },
6606 destroy: function destroy() {
6607 var swiper = this;
6608 var params = swiper.params.pagination;
6609 if (
6610 ! params.el ||
6611 ! swiper.pagination.el ||
6612 ! swiper.pagination.$el ||
6613 swiper.pagination.$el.length === 0
6614 )
6615 return;
6616 var $el = swiper.pagination.$el;
6617 $el.removeClass( params.hiddenClass );
6618 $el.removeClass( params.modifierClass + params.type );
6619 if ( swiper.pagination.bullets )
6620 swiper.pagination.bullets.removeClass( params.bulletActiveClass );
6621
6622 if ( params.clickable ) {
6623 $el.off( 'click', classesToSelector( params.bulletClass ) );
6624 }
6625 },
6626 };
6627 var Pagination$1 = {
6628 name: 'pagination',
6629 params: {
6630 pagination: {
6631 el: null,
6632 bulletElement: 'span',
6633 clickable: false,
6634 hideOnClick: false,
6635 renderBullet: null,
6636 renderProgressbar: null,
6637 renderFraction: null,
6638 renderCustom: null,
6639 progressbarOpposite: false,
6640 type: 'bullets',
6641 // 'bullets' or 'progressbar' or 'fraction' or 'custom'
6642 dynamicBullets: false,
6643 dynamicMainBullets: 1,
6644 formatFractionCurrent: function formatFractionCurrent( number ) {
6645 return number;
6646 },
6647 formatFractionTotal: function formatFractionTotal( number ) {
6648 return number;
6649 },
6650 bulletClass: 'swiper-pagination-bullet',
6651 bulletActiveClass: 'swiper-pagination-bullet-active',
6652 modifierClass: 'swiper-pagination-',
6653 // NEW
6654 currentClass: 'swiper-pagination-current',
6655 totalClass: 'swiper-pagination-total',
6656 hiddenClass: 'swiper-pagination-hidden',
6657 progressbarFillClass: 'swiper-pagination-progressbar-fill',
6658 progressbarOppositeClass: 'swiper-pagination-progressbar-opposite',
6659 clickableClass: 'swiper-pagination-clickable',
6660 // NEW
6661 lockClass: 'swiper-pagination-lock',
6662 },
6663 },
6664 create: function create() {
6665 var swiper = this;
6666 bindModuleMethods( swiper, {
6667 pagination: _extends(
6668 {
6669 dynamicBulletIndex: 0,
6670 },
6671 Pagination
6672 ),
6673 } );
6674 },
6675 on: {
6676 init: function init( swiper ) {
6677 swiper.pagination.init();
6678 swiper.pagination.render();
6679 swiper.pagination.update();
6680 },
6681 activeIndexChange: function activeIndexChange( swiper ) {
6682 if ( swiper.params.loop ) {
6683 swiper.pagination.update();
6684 } else if ( typeof swiper.snapIndex === 'undefined' ) {
6685 swiper.pagination.update();
6686 }
6687 },
6688 snapIndexChange: function snapIndexChange( swiper ) {
6689 if ( ! swiper.params.loop ) {
6690 swiper.pagination.update();
6691 }
6692 },
6693 slidesLengthChange: function slidesLengthChange( swiper ) {
6694 if ( swiper.params.loop ) {
6695 swiper.pagination.render();
6696 swiper.pagination.update();
6697 }
6698 },
6699 snapGridLengthChange: function snapGridLengthChange( swiper ) {
6700 if ( ! swiper.params.loop ) {
6701 swiper.pagination.render();
6702 swiper.pagination.update();
6703 }
6704 },
6705 destroy: function destroy( swiper ) {
6706 swiper.pagination.destroy();
6707 },
6708 'enable disable': function enableDisable( swiper ) {
6709 var $el = swiper.pagination.$el;
6710
6711 if ( $el ) {
6712 $el[ swiper.enabled ? 'removeClass' : 'addClass' ]( swiper.params.pagination.lockClass );
6713 }
6714 },
6715 click: function click( swiper, e ) {
6716 var targetEl = e.target;
6717
6718 if (
6719 swiper.params.pagination.el &&
6720 swiper.params.pagination.hideOnClick &&
6721 swiper.pagination.$el.length > 0 &&
6722 ! $( targetEl ).hasClass( swiper.params.pagination.bulletClass )
6723 ) {
6724 if (
6725 swiper.navigation &&
6726 ( ( swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl ) ||
6727 ( swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl ) )
6728 )
6729 return;
6730 var isHidden = swiper.pagination.$el.hasClass( swiper.params.pagination.hiddenClass );
6731
6732 if ( isHidden === true ) {
6733 swiper.emit( 'paginationShow' );
6734 } else {
6735 swiper.emit( 'paginationHide' );
6736 }
6737
6738 swiper.pagination.$el.toggleClass( swiper.params.pagination.hiddenClass );
6739 }
6740 },
6741 },
6742 };
6743
6744 var Zoom = {
6745 // Calc Scale From Multi-touches
6746 getDistanceBetweenTouches: function getDistanceBetweenTouches( e ) {
6747 if ( e.targetTouches.length < 2 ) return 1;
6748 var x1 = e.targetTouches[ 0 ].pageX;
6749 var y1 = e.targetTouches[ 0 ].pageY;
6750 var x2 = e.targetTouches[ 1 ].pageX;
6751 var y2 = e.targetTouches[ 1 ].pageY;
6752 var distance = Math.sqrt( Math.pow( x2 - x1, 2 ) + Math.pow( y2 - y1, 2 ) );
6753 return distance;
6754 },
6755 // Events
6756 onGestureStart: function onGestureStart( e ) {
6757 var swiper = this;
6758 var support = swiper.support;
6759 var params = swiper.params.zoom;
6760 var zoom = swiper.zoom;
6761 var gesture = zoom.gesture;
6762 zoom.fakeGestureTouched = false;
6763 zoom.fakeGestureMoved = false;
6764
6765 if ( ! support.gestures ) {
6766 if (
6767 e.type !== 'touchstart' ||
6768 ( e.type === 'touchstart' && e.targetTouches.length < 2 )
6769 ) {
6770 return;
6771 }
6772
6773 zoom.fakeGestureTouched = true;
6774 gesture.scaleStart = Zoom.getDistanceBetweenTouches( e );
6775 }
6776
6777 if ( ! gesture.$slideEl || ! gesture.$slideEl.length ) {
6778 gesture.$slideEl = $( e.target ).closest( '.' + swiper.params.slideClass );
6779 if ( gesture.$slideEl.length === 0 )
6780 gesture.$slideEl = swiper.slides.eq( swiper.activeIndex );
6781 gesture.$imageEl = gesture.$slideEl.find(
6782 'img, svg, canvas, picture, .swiper-zoom-target'
6783 );
6784 gesture.$imageWrapEl = gesture.$imageEl.parent( '.' + params.containerClass );
6785 gesture.maxRatio = gesture.$imageWrapEl.attr( 'data-swiper-zoom' ) || params.maxRatio;
6786
6787 if ( gesture.$imageWrapEl.length === 0 ) {
6788 gesture.$imageEl = undefined;
6789 return;
6790 }
6791 }
6792
6793 if ( gesture.$imageEl ) {
6794 gesture.$imageEl.transition( 0 );
6795 }
6796
6797 swiper.zoom.isScaling = true;
6798 },
6799 onGestureChange: function onGestureChange( e ) {
6800 var swiper = this;
6801 var support = swiper.support;
6802 var params = swiper.params.zoom;
6803 var zoom = swiper.zoom;
6804 var gesture = zoom.gesture;
6805
6806 if ( ! support.gestures ) {
6807 if ( e.type !== 'touchmove' || ( e.type === 'touchmove' && e.targetTouches.length < 2 ) ) {
6808 return;
6809 }
6810
6811 zoom.fakeGestureMoved = true;
6812 gesture.scaleMove = Zoom.getDistanceBetweenTouches( e );
6813 }
6814
6815 if ( ! gesture.$imageEl || gesture.$imageEl.length === 0 ) {
6816 if ( e.type === 'gesturechange' ) zoom.onGestureStart( e );
6817 return;
6818 }
6819
6820 if ( support.gestures ) {
6821 zoom.scale = e.scale * zoom.currentScale;
6822 } else {
6823 zoom.scale = ( gesture.scaleMove / gesture.scaleStart ) * zoom.currentScale;
6824 }
6825
6826 if ( zoom.scale > gesture.maxRatio ) {
6827 zoom.scale = gesture.maxRatio - 1 + Math.pow( zoom.scale - gesture.maxRatio + 1, 0.5 );
6828 }
6829
6830 if ( zoom.scale < params.minRatio ) {
6831 zoom.scale = params.minRatio + 1 - Math.pow( params.minRatio - zoom.scale + 1, 0.5 );
6832 }
6833
6834 gesture.$imageEl.transform( 'translate3d(0,0,0) scale(' + zoom.scale + ')' );
6835 },
6836 onGestureEnd: function onGestureEnd( e ) {
6837 var swiper = this;
6838 var device = swiper.device;
6839 var support = swiper.support;
6840 var params = swiper.params.zoom;
6841 var zoom = swiper.zoom;
6842 var gesture = zoom.gesture;
6843
6844 if ( ! support.gestures ) {
6845 if ( ! zoom.fakeGestureTouched || ! zoom.fakeGestureMoved ) {
6846 return;
6847 }
6848
6849 if (
6850 e.type !== 'touchend' ||
6851 ( e.type === 'touchend' && e.changedTouches.length < 2 && ! device.android )
6852 ) {
6853 return;
6854 }
6855
6856 zoom.fakeGestureTouched = false;
6857 zoom.fakeGestureMoved = false;
6858 }
6859
6860 if ( ! gesture.$imageEl || gesture.$imageEl.length === 0 ) return;
6861 zoom.scale = Math.max( Math.min( zoom.scale, gesture.maxRatio ), params.minRatio );
6862 gesture.$imageEl
6863 .transition( swiper.params.speed )
6864 .transform( 'translate3d(0,0,0) scale(' + zoom.scale + ')' );
6865 zoom.currentScale = zoom.scale;
6866 zoom.isScaling = false;
6867 if ( zoom.scale === 1 ) gesture.$slideEl = undefined;
6868 },
6869 onTouchStart: function onTouchStart( e ) {
6870 var swiper = this;
6871 var device = swiper.device;
6872 var zoom = swiper.zoom;
6873 var gesture = zoom.gesture,
6874 image = zoom.image;
6875 if ( ! gesture.$imageEl || gesture.$imageEl.length === 0 ) return;
6876 if ( image.isTouched ) return;
6877 if ( device.android && e.cancelable ) e.preventDefault();
6878 image.isTouched = true;
6879 image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[ 0 ].pageX : e.pageX;
6880 image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[ 0 ].pageY : e.pageY;
6881 },
6882 onTouchMove: function onTouchMove( e ) {
6883 var swiper = this;
6884 var zoom = swiper.zoom;
6885 var gesture = zoom.gesture,
6886 image = zoom.image,
6887 velocity = zoom.velocity;
6888 if ( ! gesture.$imageEl || gesture.$imageEl.length === 0 ) return;
6889 swiper.allowClick = false;
6890 if ( ! image.isTouched || ! gesture.$slideEl ) return;
6891
6892 if ( ! image.isMoved ) {
6893 image.width = gesture.$imageEl[ 0 ].offsetWidth;
6894 image.height = gesture.$imageEl[ 0 ].offsetHeight;
6895 image.startX = getTranslate( gesture.$imageWrapEl[ 0 ], 'x' ) || 0;
6896 image.startY = getTranslate( gesture.$imageWrapEl[ 0 ], 'y' ) || 0;
6897 gesture.slideWidth = gesture.$slideEl[ 0 ].offsetWidth;
6898 gesture.slideHeight = gesture.$slideEl[ 0 ].offsetHeight;
6899 gesture.$imageWrapEl.transition( 0 );
6900
6901 if ( swiper.rtl ) {
6902 image.startX = -image.startX;
6903 image.startY = -image.startY;
6904 }
6905 } // Define if we need image drag
6906
6907 var scaledWidth = image.width * zoom.scale;
6908 var scaledHeight = image.height * zoom.scale;
6909 if ( scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight ) return;
6910 image.minX = Math.min( gesture.slideWidth / 2 - scaledWidth / 2, 0 );
6911 image.maxX = -image.minX;
6912 image.minY = Math.min( gesture.slideHeight / 2 - scaledHeight / 2, 0 );
6913 image.maxY = -image.minY;
6914 image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[ 0 ].pageX : e.pageX;
6915 image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[ 0 ].pageY : e.pageY;
6916
6917 if ( ! image.isMoved && ! zoom.isScaling ) {
6918 if (
6919 swiper.isHorizontal() &&
6920 ( ( Math.floor( image.minX ) === Math.floor( image.startX ) &&
6921 image.touchesCurrent.x < image.touchesStart.x ) ||
6922 ( Math.floor( image.maxX ) === Math.floor( image.startX ) &&
6923 image.touchesCurrent.x > image.touchesStart.x ) )
6924 ) {
6925 image.isTouched = false;
6926 return;
6927 }
6928
6929 if (
6930 ! swiper.isHorizontal() &&
6931 ( ( Math.floor( image.minY ) === Math.floor( image.startY ) &&
6932 image.touchesCurrent.y < image.touchesStart.y ) ||
6933 ( Math.floor( image.maxY ) === Math.floor( image.startY ) &&
6934 image.touchesCurrent.y > image.touchesStart.y ) )
6935 ) {
6936 image.isTouched = false;
6937 return;
6938 }
6939 }
6940
6941 if ( e.cancelable ) {
6942 e.preventDefault();
6943 }
6944
6945 e.stopPropagation();
6946 image.isMoved = true;
6947 image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX;
6948 image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY;
6949
6950 if ( image.currentX < image.minX ) {
6951 image.currentX = image.minX + 1 - Math.pow( image.minX - image.currentX + 1, 0.8 );
6952 }
6953
6954 if ( image.currentX > image.maxX ) {
6955 image.currentX = image.maxX - 1 + Math.pow( image.currentX - image.maxX + 1, 0.8 );
6956 }
6957
6958 if ( image.currentY < image.minY ) {
6959 image.currentY = image.minY + 1 - Math.pow( image.minY - image.currentY + 1, 0.8 );
6960 }
6961
6962 if ( image.currentY > image.maxY ) {
6963 image.currentY = image.maxY - 1 + Math.pow( image.currentY - image.maxY + 1, 0.8 );
6964 } // Velocity
6965
6966 if ( ! velocity.prevPositionX ) velocity.prevPositionX = image.touchesCurrent.x;
6967 if ( ! velocity.prevPositionY ) velocity.prevPositionY = image.touchesCurrent.y;
6968 if ( ! velocity.prevTime ) velocity.prevTime = Date.now();
6969 velocity.x =
6970 ( image.touchesCurrent.x - velocity.prevPositionX ) /
6971 ( Date.now() - velocity.prevTime ) /
6972 2;
6973 velocity.y =
6974 ( image.touchesCurrent.y - velocity.prevPositionY ) /
6975 ( Date.now() - velocity.prevTime ) /
6976 2;
6977 if ( Math.abs( image.touchesCurrent.x - velocity.prevPositionX ) < 2 ) velocity.x = 0;
6978 if ( Math.abs( image.touchesCurrent.y - velocity.prevPositionY ) < 2 ) velocity.y = 0;
6979 velocity.prevPositionX = image.touchesCurrent.x;
6980 velocity.prevPositionY = image.touchesCurrent.y;
6981 velocity.prevTime = Date.now();
6982 gesture.$imageWrapEl.transform(
6983 'translate3d(' + image.currentX + 'px, ' + image.currentY + 'px,0)'
6984 );
6985 },
6986 onTouchEnd: function onTouchEnd() {
6987 var swiper = this;
6988 var zoom = swiper.zoom;
6989 var gesture = zoom.gesture,
6990 image = zoom.image,
6991 velocity = zoom.velocity;
6992 if ( ! gesture.$imageEl || gesture.$imageEl.length === 0 ) return;
6993
6994 if ( ! image.isTouched || ! image.isMoved ) {
6995 image.isTouched = false;
6996 image.isMoved = false;
6997 return;
6998 }
6999
7000 image.isTouched = false;
7001 image.isMoved = false;
7002 var momentumDurationX = 300;
7003 var momentumDurationY = 300;
7004 var momentumDistanceX = velocity.x * momentumDurationX;
7005 var newPositionX = image.currentX + momentumDistanceX;
7006 var momentumDistanceY = velocity.y * momentumDurationY;
7007 var newPositionY = image.currentY + momentumDistanceY; // Fix duration
7008
7009 if ( velocity.x !== 0 )
7010 momentumDurationX = Math.abs( ( newPositionX - image.currentX ) / velocity.x );
7011 if ( velocity.y !== 0 )
7012 momentumDurationY = Math.abs( ( newPositionY - image.currentY ) / velocity.y );
7013 var momentumDuration = Math.max( momentumDurationX, momentumDurationY );
7014 image.currentX = newPositionX;
7015 image.currentY = newPositionY; // Define if we need image drag
7016
7017 var scaledWidth = image.width * zoom.scale;
7018 var scaledHeight = image.height * zoom.scale;
7019 image.minX = Math.min( gesture.slideWidth / 2 - scaledWidth / 2, 0 );
7020 image.maxX = -image.minX;
7021 image.minY = Math.min( gesture.slideHeight / 2 - scaledHeight / 2, 0 );
7022 image.maxY = -image.minY;
7023 image.currentX = Math.max( Math.min( image.currentX, image.maxX ), image.minX );
7024 image.currentY = Math.max( Math.min( image.currentY, image.maxY ), image.minY );
7025 gesture.$imageWrapEl
7026 .transition( momentumDuration )
7027 .transform( 'translate3d(' + image.currentX + 'px, ' + image.currentY + 'px,0)' );
7028 },
7029 onTransitionEnd: function onTransitionEnd() {
7030 var swiper = this;
7031 var zoom = swiper.zoom;
7032 var gesture = zoom.gesture;
7033
7034 if ( gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex ) {
7035 if ( gesture.$imageEl ) {
7036 gesture.$imageEl.transform( 'translate3d(0,0,0) scale(1)' );
7037 }
7038
7039 if ( gesture.$imageWrapEl ) {
7040 gesture.$imageWrapEl.transform( 'translate3d(0,0,0)' );
7041 }
7042
7043 zoom.scale = 1;
7044 zoom.currentScale = 1;
7045 gesture.$slideEl = undefined;
7046 gesture.$imageEl = undefined;
7047 gesture.$imageWrapEl = undefined;
7048 }
7049 },
7050 // Toggle Zoom
7051 toggle: function toggle( e ) {
7052 var swiper = this;
7053 var zoom = swiper.zoom;
7054
7055 if ( zoom.scale && zoom.scale !== 1 ) {
7056 // Zoom Out
7057 zoom.out();
7058 } else {
7059 // Zoom In
7060 zoom.in( e );
7061 }
7062 },
7063 in: function _in( e ) {
7064 var swiper = this;
7065 var window = getWindow();
7066 var zoom = swiper.zoom;
7067 var params = swiper.params.zoom;
7068 var gesture = zoom.gesture,
7069 image = zoom.image;
7070
7071 if ( ! gesture.$slideEl ) {
7072 if ( swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ) {
7073 gesture.$slideEl = swiper.$wrapperEl.children( '.' + swiper.params.slideActiveClass );
7074 } else {
7075 gesture.$slideEl = swiper.slides.eq( swiper.activeIndex );
7076 }
7077
7078 gesture.$imageEl = gesture.$slideEl.find(
7079 'img, svg, canvas, picture, .swiper-zoom-target'
7080 );
7081 gesture.$imageWrapEl = gesture.$imageEl.parent( '.' + params.containerClass );
7082 }
7083
7084 if (
7085 ! gesture.$imageEl ||
7086 gesture.$imageEl.length === 0 ||
7087 ! gesture.$imageWrapEl ||
7088 gesture.$imageWrapEl.length === 0
7089 )
7090 return;
7091 gesture.$slideEl.addClass( '' + params.zoomedSlideClass );
7092 var touchX;
7093 var touchY;
7094 var offsetX;
7095 var offsetY;
7096 var diffX;
7097 var diffY;
7098 var translateX;
7099 var translateY;
7100 var imageWidth;
7101 var imageHeight;
7102 var scaledWidth;
7103 var scaledHeight;
7104 var translateMinX;
7105 var translateMinY;
7106 var translateMaxX;
7107 var translateMaxY;
7108 var slideWidth;
7109 var slideHeight;
7110
7111 if ( typeof image.touchesStart.x === 'undefined' && e ) {
7112 touchX = e.type === 'touchend' ? e.changedTouches[ 0 ].pageX : e.pageX;
7113 touchY = e.type === 'touchend' ? e.changedTouches[ 0 ].pageY : e.pageY;
7114 } else {
7115 touchX = image.touchesStart.x;
7116 touchY = image.touchesStart.y;
7117 }
7118
7119 zoom.scale = gesture.$imageWrapEl.attr( 'data-swiper-zoom' ) || params.maxRatio;
7120 zoom.currentScale = gesture.$imageWrapEl.attr( 'data-swiper-zoom' ) || params.maxRatio;
7121
7122 if ( e ) {
7123 slideWidth = gesture.$slideEl[ 0 ].offsetWidth;
7124 slideHeight = gesture.$slideEl[ 0 ].offsetHeight;
7125 offsetX = gesture.$slideEl.offset().left + window.scrollX;
7126 offsetY = gesture.$slideEl.offset().top + window.scrollY;
7127 diffX = offsetX + slideWidth / 2 - touchX;
7128 diffY = offsetY + slideHeight / 2 - touchY;
7129 imageWidth = gesture.$imageEl[ 0 ].offsetWidth;
7130 imageHeight = gesture.$imageEl[ 0 ].offsetHeight;
7131 scaledWidth = imageWidth * zoom.scale;
7132 scaledHeight = imageHeight * zoom.scale;
7133 translateMinX = Math.min( slideWidth / 2 - scaledWidth / 2, 0 );
7134 translateMinY = Math.min( slideHeight / 2 - scaledHeight / 2, 0 );
7135 translateMaxX = -translateMinX;
7136 translateMaxY = -translateMinY;
7137 translateX = diffX * zoom.scale;
7138 translateY = diffY * zoom.scale;
7139
7140 if ( translateX < translateMinX ) {
7141 translateX = translateMinX;
7142 }
7143
7144 if ( translateX > translateMaxX ) {
7145 translateX = translateMaxX;
7146 }
7147
7148 if ( translateY < translateMinY ) {
7149 translateY = translateMinY;
7150 }
7151
7152 if ( translateY > translateMaxY ) {
7153 translateY = translateMaxY;
7154 }
7155 } else {
7156 translateX = 0;
7157 translateY = 0;
7158 }
7159
7160 gesture.$imageWrapEl
7161 .transition( 300 )
7162 .transform( 'translate3d(' + translateX + 'px, ' + translateY + 'px,0)' );
7163 gesture.$imageEl
7164 .transition( 300 )
7165 .transform( 'translate3d(0,0,0) scale(' + zoom.scale + ')' );
7166 },
7167 out: function out() {
7168 var swiper = this;
7169 var zoom = swiper.zoom;
7170 var params = swiper.params.zoom;
7171 var gesture = zoom.gesture;
7172
7173 if ( ! gesture.$slideEl ) {
7174 if ( swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ) {
7175 gesture.$slideEl = swiper.$wrapperEl.children( '.' + swiper.params.slideActiveClass );
7176 } else {
7177 gesture.$slideEl = swiper.slides.eq( swiper.activeIndex );
7178 }
7179
7180 gesture.$imageEl = gesture.$slideEl.find(
7181 'img, svg, canvas, picture, .swiper-zoom-target'
7182 );
7183 gesture.$imageWrapEl = gesture.$imageEl.parent( '.' + params.containerClass );
7184 }
7185
7186 if (
7187 ! gesture.$imageEl ||
7188 gesture.$imageEl.length === 0 ||
7189 ! gesture.$imageWrapEl ||
7190 gesture.$imageWrapEl.length === 0
7191 )
7192 return;
7193 zoom.scale = 1;
7194 zoom.currentScale = 1;
7195 gesture.$imageWrapEl.transition( 300 ).transform( 'translate3d(0,0,0)' );
7196 gesture.$imageEl.transition( 300 ).transform( 'translate3d(0,0,0) scale(1)' );
7197 gesture.$slideEl.removeClass( '' + params.zoomedSlideClass );
7198 gesture.$slideEl = undefined;
7199 },
7200 toggleGestures: function toggleGestures( method ) {
7201 var swiper = this;
7202 var zoom = swiper.zoom;
7203 var selector = zoom.slideSelector,
7204 passive = zoom.passiveListener;
7205 swiper.$wrapperEl[ method ]( 'gesturestart', selector, zoom.onGestureStart, passive );
7206 swiper.$wrapperEl[ method ]( 'gesturechange', selector, zoom.onGestureChange, passive );
7207 swiper.$wrapperEl[ method ]( 'gestureend', selector, zoom.onGestureEnd, passive );
7208 },
7209 enableGestures: function enableGestures() {
7210 if ( this.zoom.gesturesEnabled ) return;
7211 this.zoom.gesturesEnabled = true;
7212 this.zoom.toggleGestures( 'on' );
7213 },
7214 disableGestures: function disableGestures() {
7215 if ( ! this.zoom.gesturesEnabled ) return;
7216 this.zoom.gesturesEnabled = false;
7217 this.zoom.toggleGestures( 'off' );
7218 },
7219 // Attach/Detach Events
7220 enable: function enable() {
7221 var swiper = this;
7222 var support = swiper.support;
7223 var zoom = swiper.zoom;
7224 if ( zoom.enabled ) return;
7225 zoom.enabled = true;
7226 var passiveListener =
7227 swiper.touchEvents.start === 'touchstart' &&
7228 support.passiveListener &&
7229 swiper.params.passiveListeners
7230 ? {
7231 passive: true,
7232 capture: false,
7233 }
7234 : false;
7235 var activeListenerWithCapture = support.passiveListener
7236 ? {
7237 passive: false,
7238 capture: true,
7239 }
7240 : true;
7241 var slideSelector = '.' + swiper.params.slideClass;
7242 swiper.zoom.passiveListener = passiveListener;
7243 swiper.zoom.slideSelector = slideSelector; // Scale image
7244
7245 if ( support.gestures ) {
7246 swiper.$wrapperEl.on(
7247 swiper.touchEvents.start,
7248 swiper.zoom.enableGestures,
7249 passiveListener
7250 );
7251 swiper.$wrapperEl.on(
7252 swiper.touchEvents.end,
7253 swiper.zoom.disableGestures,
7254 passiveListener
7255 );
7256 } else if ( swiper.touchEvents.start === 'touchstart' ) {
7257 swiper.$wrapperEl.on(
7258 swiper.touchEvents.start,
7259 slideSelector,
7260 zoom.onGestureStart,
7261 passiveListener
7262 );
7263 swiper.$wrapperEl.on(
7264 swiper.touchEvents.move,
7265 slideSelector,
7266 zoom.onGestureChange,
7267 activeListenerWithCapture
7268 );
7269 swiper.$wrapperEl.on(
7270 swiper.touchEvents.end,
7271 slideSelector,
7272 zoom.onGestureEnd,
7273 passiveListener
7274 );
7275
7276 if ( swiper.touchEvents.cancel ) {
7277 swiper.$wrapperEl.on(
7278 swiper.touchEvents.cancel,
7279 slideSelector,
7280 zoom.onGestureEnd,
7281 passiveListener
7282 );
7283 }
7284 } // Move image
7285
7286 swiper.$wrapperEl.on(
7287 swiper.touchEvents.move,
7288 '.' + swiper.params.zoom.containerClass,
7289 zoom.onTouchMove,
7290 activeListenerWithCapture
7291 );
7292 },
7293 disable: function disable() {
7294 var swiper = this;
7295 var zoom = swiper.zoom;
7296 if ( ! zoom.enabled ) return;
7297 var support = swiper.support;
7298 swiper.zoom.enabled = false;
7299 var passiveListener =
7300 swiper.touchEvents.start === 'touchstart' &&
7301 support.passiveListener &&
7302 swiper.params.passiveListeners
7303 ? {
7304 passive: true,
7305 capture: false,
7306 }
7307 : false;
7308 var activeListenerWithCapture = support.passiveListener
7309 ? {
7310 passive: false,
7311 capture: true,
7312 }
7313 : true;
7314 var slideSelector = '.' + swiper.params.slideClass; // Scale image
7315
7316 if ( support.gestures ) {
7317 swiper.$wrapperEl.off(
7318 swiper.touchEvents.start,
7319 swiper.zoom.enableGestures,
7320 passiveListener
7321 );
7322 swiper.$wrapperEl.off(
7323 swiper.touchEvents.end,
7324 swiper.zoom.disableGestures,
7325 passiveListener
7326 );
7327 } else if ( swiper.touchEvents.start === 'touchstart' ) {
7328 swiper.$wrapperEl.off(
7329 swiper.touchEvents.start,
7330 slideSelector,
7331 zoom.onGestureStart,
7332 passiveListener
7333 );
7334 swiper.$wrapperEl.off(
7335 swiper.touchEvents.move,
7336 slideSelector,
7337 zoom.onGestureChange,
7338 activeListenerWithCapture
7339 );
7340 swiper.$wrapperEl.off(
7341 swiper.touchEvents.end,
7342 slideSelector,
7343 zoom.onGestureEnd,
7344 passiveListener
7345 );
7346
7347 if ( swiper.touchEvents.cancel ) {
7348 swiper.$wrapperEl.off(
7349 swiper.touchEvents.cancel,
7350 slideSelector,
7351 zoom.onGestureEnd,
7352 passiveListener
7353 );
7354 }
7355 } // Move image
7356
7357 swiper.$wrapperEl.off(
7358 swiper.touchEvents.move,
7359 '.' + swiper.params.zoom.containerClass,
7360 zoom.onTouchMove,
7361 activeListenerWithCapture
7362 );
7363 },
7364 };
7365 var Zoom$1 = {
7366 name: 'zoom',
7367 params: {
7368 zoom: {
7369 enabled: false,
7370 maxRatio: 3,
7371 minRatio: 1,
7372 toggle: true,
7373 containerClass: 'swiper-zoom-container',
7374 zoomedSlideClass: 'swiper-slide-zoomed',
7375 },
7376 },
7377 create: function create() {
7378 var swiper = this;
7379 bindModuleMethods( swiper, {
7380 zoom: _extends(
7381 {
7382 enabled: false,
7383 scale: 1,
7384 currentScale: 1,
7385 isScaling: false,
7386 gesture: {
7387 $slideEl: undefined,
7388 slideWidth: undefined,
7389 slideHeight: undefined,
7390 $imageEl: undefined,
7391 $imageWrapEl: undefined,
7392 maxRatio: 3,
7393 },
7394 image: {
7395 isTouched: undefined,
7396 isMoved: undefined,
7397 currentX: undefined,
7398 currentY: undefined,
7399 minX: undefined,
7400 minY: undefined,
7401 maxX: undefined,
7402 maxY: undefined,
7403 width: undefined,
7404 height: undefined,
7405 startX: undefined,
7406 startY: undefined,
7407 touchesStart: {},
7408 touchesCurrent: {},
7409 },
7410 velocity: {
7411 x: undefined,
7412 y: undefined,
7413 prevPositionX: undefined,
7414 prevPositionY: undefined,
7415 prevTime: undefined,
7416 },
7417 },
7418 Zoom
7419 ),
7420 } );
7421 var scale = 1;
7422 Object.defineProperty( swiper.zoom, 'scale', {
7423 get: function get() {
7424 return scale;
7425 },
7426 set: function set( value ) {
7427 if ( scale !== value ) {
7428 var imageEl = swiper.zoom.gesture.$imageEl
7429 ? swiper.zoom.gesture.$imageEl[ 0 ]
7430 : undefined;
7431 var slideEl = swiper.zoom.gesture.$slideEl
7432 ? swiper.zoom.gesture.$slideEl[ 0 ]
7433 : undefined;
7434 swiper.emit( 'zoomChange', value, imageEl, slideEl );
7435 }
7436
7437 scale = value;
7438 },
7439 } );
7440 },
7441 on: {
7442 init: function init( swiper ) {
7443 if ( swiper.params.zoom.enabled ) {
7444 swiper.zoom.enable();
7445 }
7446 },
7447 destroy: function destroy( swiper ) {
7448 swiper.zoom.disable();
7449 },
7450 touchStart: function touchStart( swiper, e ) {
7451 if ( ! swiper.zoom.enabled ) return;
7452 swiper.zoom.onTouchStart( e );
7453 },
7454 touchEnd: function touchEnd( swiper, e ) {
7455 if ( ! swiper.zoom.enabled ) return;
7456 swiper.zoom.onTouchEnd( e );
7457 },
7458 doubleTap: function doubleTap( swiper, e ) {
7459 if (
7460 ! swiper.animating &&
7461 swiper.params.zoom.enabled &&
7462 swiper.zoom.enabled &&
7463 swiper.params.zoom.toggle
7464 ) {
7465 swiper.zoom.toggle( e );
7466 }
7467 },
7468 transitionEnd: function transitionEnd( swiper ) {
7469 if ( swiper.zoom.enabled && swiper.params.zoom.enabled ) {
7470 swiper.zoom.onTransitionEnd();
7471 }
7472 },
7473 slideChange: function slideChange( swiper ) {
7474 if ( swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode ) {
7475 swiper.zoom.onTransitionEnd();
7476 }
7477 },
7478 },
7479 };
7480
7481 var A11y = {
7482 getRandomNumber: function getRandomNumber( size ) {
7483 if ( size === void 0 ) {
7484 size = 16;
7485 }
7486
7487 var randomChar = function randomChar() {
7488 return Math.round( 16 * Math.random() ).toString( 16 );
7489 };
7490
7491 return 'x'.repeat( size ).replace( /x/g, randomChar );
7492 },
7493 makeElFocusable: function makeElFocusable( $el ) {
7494 $el.attr( 'tabIndex', '0' );
7495 return $el;
7496 },
7497 makeElNotFocusable: function makeElNotFocusable( $el ) {
7498 $el.attr( 'tabIndex', '-1' );
7499 return $el;
7500 },
7501 addElRole: function addElRole( $el, role ) {
7502 $el.attr( 'role', role );
7503 return $el;
7504 },
7505 addElRoleDescription: function addElRoleDescription( $el, description ) {
7506 $el.attr( 'aria-roledescription', description );
7507 return $el;
7508 },
7509 addElControls: function addElControls( $el, controls ) {
7510 $el.attr( 'aria-controls', controls );
7511 return $el;
7512 },
7513 addElLabel: function addElLabel( $el, label ) {
7514 $el.attr( 'aria-label', label );
7515 return $el;
7516 },
7517 addElId: function addElId( $el, id ) {
7518 $el.attr( 'id', id );
7519 return $el;
7520 },
7521 addElLive: function addElLive( $el, live ) {
7522 $el.attr( 'aria-live', live );
7523 return $el;
7524 },
7525 disableEl: function disableEl( $el ) {
7526 $el.attr( 'aria-disabled', true );
7527 return $el;
7528 },
7529 enableEl: function enableEl( $el ) {
7530 $el.attr( 'aria-disabled', false );
7531 return $el;
7532 },
7533 onEnterOrSpaceKey: function onEnterOrSpaceKey( e ) {
7534 if ( e.keyCode !== 13 && e.keyCode !== 32 ) return;
7535 var swiper = this;
7536 var params = swiper.params.a11y;
7537 var $targetEl = $( e.target );
7538
7539 if (
7540 swiper.navigation &&
7541 swiper.navigation.$nextEl &&
7542 $targetEl.is( swiper.navigation.$nextEl )
7543 ) {
7544 if ( ! ( swiper.isEnd && ! swiper.params.loop ) ) {
7545 swiper.slideNext();
7546 }
7547
7548 if ( swiper.isEnd ) {
7549 swiper.a11y.notify( params.lastSlideMessage );
7550 } else {
7551 swiper.a11y.notify( params.nextSlideMessage );
7552 }
7553 }
7554
7555 if (
7556 swiper.navigation &&
7557 swiper.navigation.$prevEl &&
7558 $targetEl.is( swiper.navigation.$prevEl )
7559 ) {
7560 if ( ! ( swiper.isBeginning && ! swiper.params.loop ) ) {
7561 swiper.slidePrev();
7562 }
7563
7564 if ( swiper.isBeginning ) {
7565 swiper.a11y.notify( params.firstSlideMessage );
7566 } else {
7567 swiper.a11y.notify( params.prevSlideMessage );
7568 }
7569 }
7570
7571 if (
7572 swiper.pagination &&
7573 $targetEl.is( classesToSelector( swiper.params.pagination.bulletClass ) )
7574 ) {
7575 $targetEl[ 0 ].click();
7576 }
7577 },
7578 notify: function notify( message ) {
7579 var swiper = this;
7580 var notification = swiper.a11y.liveRegion;
7581 if ( notification.length === 0 ) return;
7582 notification.html( '' );
7583 notification.html( message );
7584 },
7585 updateNavigation: function updateNavigation() {
7586 var swiper = this;
7587 if ( swiper.params.loop || ! swiper.navigation ) return;
7588 var _swiper$navigation = swiper.navigation,
7589 $nextEl = _swiper$navigation.$nextEl,
7590 $prevEl = _swiper$navigation.$prevEl;
7591
7592 if ( $prevEl && $prevEl.length > 0 ) {
7593 if ( swiper.isBeginning ) {
7594 swiper.a11y.disableEl( $prevEl );
7595 swiper.a11y.makeElNotFocusable( $prevEl );
7596 } else {
7597 swiper.a11y.enableEl( $prevEl );
7598 swiper.a11y.makeElFocusable( $prevEl );
7599 }
7600 }
7601
7602 if ( $nextEl && $nextEl.length > 0 ) {
7603 if ( swiper.isEnd ) {
7604 swiper.a11y.disableEl( $nextEl );
7605 swiper.a11y.makeElNotFocusable( $nextEl );
7606 } else {
7607 swiper.a11y.enableEl( $nextEl );
7608 swiper.a11y.makeElFocusable( $nextEl );
7609 }
7610 }
7611 },
7612 updatePagination: function updatePagination() {
7613 var swiper = this;
7614 var params = swiper.params.a11y;
7615
7616 if (
7617 swiper.pagination &&
7618 swiper.params.pagination.clickable &&
7619 swiper.pagination.bullets &&
7620 swiper.pagination.bullets.length
7621 ) {
7622 swiper.pagination.bullets.each( function ( bulletEl ) {
7623 var $bulletEl = $( bulletEl );
7624 swiper.a11y.makeElFocusable( $bulletEl );
7625
7626 if ( ! swiper.params.pagination.renderBullet ) {
7627 swiper.a11y.addElRole( $bulletEl, 'button' );
7628 swiper.a11y.addElLabel(
7629 $bulletEl,
7630 params.paginationBulletMessage.replace( /\{\{index\}\}/, $bulletEl.index() + 1 )
7631 );
7632 }
7633 } );
7634 }
7635 },
7636 init: function init() {
7637 var swiper = this;
7638 var params = swiper.params.a11y;
7639 swiper.$el.append( swiper.a11y.liveRegion ); // Container
7640
7641 var $containerEl = swiper.$el;
7642
7643 if ( params.containerRoleDescriptionMessage ) {
7644 swiper.a11y.addElRoleDescription( $containerEl, params.containerRoleDescriptionMessage );
7645 }
7646
7647 if ( params.containerMessage ) {
7648 swiper.a11y.addElLabel( $containerEl, params.containerMessage );
7649 } // Wrapper
7650
7651 var $wrapperEl = swiper.$wrapperEl;
7652 var wrapperId =
7653 $wrapperEl.attr( 'id' ) || 'swiper-wrapper-' + swiper.a11y.getRandomNumber( 16 );
7654 var live = swiper.params.autoplay && swiper.params.autoplay.enabled ? 'off' : 'polite';
7655 swiper.a11y.addElId( $wrapperEl, wrapperId );
7656 swiper.a11y.addElLive( $wrapperEl, live ); // Slide
7657
7658 if ( params.itemRoleDescriptionMessage ) {
7659 swiper.a11y.addElRoleDescription( $( swiper.slides ), params.itemRoleDescriptionMessage );
7660 }
7661
7662 swiper.a11y.addElRole( $( swiper.slides ), params.slideRole );
7663 swiper.slides.each( function ( slideEl ) {
7664 var $slideEl = $( slideEl );
7665 var ariaLabelMessage = params.slideLabelMessage
7666 .replace( /\{\{index\}\}/, $slideEl.index() + 1 )
7667 .replace( /\{\{slidesLength\}\}/, swiper.slides.length );
7668 swiper.a11y.addElLabel( $slideEl, ariaLabelMessage );
7669 } ); // Navigation
7670
7671 var $nextEl;
7672 var $prevEl;
7673
7674 if ( swiper.navigation && swiper.navigation.$nextEl ) {
7675 $nextEl = swiper.navigation.$nextEl;
7676 }
7677
7678 if ( swiper.navigation && swiper.navigation.$prevEl ) {
7679 $prevEl = swiper.navigation.$prevEl;
7680 }
7681
7682 if ( $nextEl && $nextEl.length ) {
7683 swiper.a11y.makeElFocusable( $nextEl );
7684
7685 if ( $nextEl[ 0 ].tagName !== 'BUTTON' ) {
7686 swiper.a11y.addElRole( $nextEl, 'button' );
7687 $nextEl.on( 'keydown', swiper.a11y.onEnterOrSpaceKey );
7688 }
7689
7690 swiper.a11y.addElLabel( $nextEl, params.nextSlideMessage );
7691 swiper.a11y.addElControls( $nextEl, wrapperId );
7692 }
7693
7694 if ( $prevEl && $prevEl.length ) {
7695 swiper.a11y.makeElFocusable( $prevEl );
7696
7697 if ( $prevEl[ 0 ].tagName !== 'BUTTON' ) {
7698 swiper.a11y.addElRole( $prevEl, 'button' );
7699 $prevEl.on( 'keydown', swiper.a11y.onEnterOrSpaceKey );
7700 }
7701
7702 swiper.a11y.addElLabel( $prevEl, params.prevSlideMessage );
7703 swiper.a11y.addElControls( $prevEl, wrapperId );
7704 } // Pagination
7705
7706 if (
7707 swiper.pagination &&
7708 swiper.params.pagination.clickable &&
7709 swiper.pagination.bullets &&
7710 swiper.pagination.bullets.length
7711 ) {
7712 swiper.pagination.$el.on(
7713 'keydown',
7714 classesToSelector( swiper.params.pagination.bulletClass ),
7715 swiper.a11y.onEnterOrSpaceKey
7716 );
7717 }
7718 },
7719 destroy: function destroy() {
7720 var swiper = this;
7721 if ( swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0 )
7722 swiper.a11y.liveRegion.remove();
7723 var $nextEl;
7724 var $prevEl;
7725
7726 if ( swiper.navigation && swiper.navigation.$nextEl ) {
7727 $nextEl = swiper.navigation.$nextEl;
7728 }
7729
7730 if ( swiper.navigation && swiper.navigation.$prevEl ) {
7731 $prevEl = swiper.navigation.$prevEl;
7732 }
7733
7734 if ( $nextEl ) {
7735 $nextEl.off( 'keydown', swiper.a11y.onEnterOrSpaceKey );
7736 }
7737
7738 if ( $prevEl ) {
7739 $prevEl.off( 'keydown', swiper.a11y.onEnterOrSpaceKey );
7740 } // Pagination
7741
7742 if (
7743 swiper.pagination &&
7744 swiper.params.pagination.clickable &&
7745 swiper.pagination.bullets &&
7746 swiper.pagination.bullets.length
7747 ) {
7748 swiper.pagination.$el.off(
7749 'keydown',
7750 classesToSelector( swiper.params.pagination.bulletClass ),
7751 swiper.a11y.onEnterOrSpaceKey
7752 );
7753 }
7754 },
7755 };
7756 var A11y$1 = {
7757 name: 'a11y',
7758 params: {
7759 a11y: {
7760 enabled: true,
7761 notificationClass: 'swiper-notification',
7762 prevSlideMessage: 'Previous slide',
7763 nextSlideMessage: 'Next slide',
7764 firstSlideMessage: 'This is the first slide',
7765 lastSlideMessage: 'This is the last slide',
7766 paginationBulletMessage: 'Go to slide {{index}}',
7767 slideLabelMessage: '{{index}} / {{slidesLength}}',
7768 containerMessage: null,
7769 containerRoleDescriptionMessage: null,
7770 itemRoleDescriptionMessage: null,
7771 slideRole: 'group',
7772 },
7773 },
7774 create: function create() {
7775 var swiper = this;
7776 bindModuleMethods( swiper, {
7777 a11y: _extends( {}, A11y, {
7778 liveRegion: $(
7779 '<span class="' +
7780 swiper.params.a11y.notificationClass +
7781 '" aria-live="assertive" aria-atomic="true"></span>'
7782 ),
7783 } ),
7784 } );
7785 },
7786 on: {
7787 afterInit: function afterInit( swiper ) {
7788 if ( ! swiper.params.a11y.enabled ) return;
7789 swiper.a11y.init();
7790 swiper.a11y.updateNavigation();
7791 },
7792 toEdge: function toEdge( swiper ) {
7793 if ( ! swiper.params.a11y.enabled ) return;
7794 swiper.a11y.updateNavigation();
7795 },
7796 fromEdge: function fromEdge( swiper ) {
7797 if ( ! swiper.params.a11y.enabled ) return;
7798 swiper.a11y.updateNavigation();
7799 },
7800 paginationUpdate: function paginationUpdate( swiper ) {
7801 if ( ! swiper.params.a11y.enabled ) return;
7802 swiper.a11y.updatePagination();
7803 },
7804 destroy: function destroy( swiper ) {
7805 if ( ! swiper.params.a11y.enabled ) return;
7806 swiper.a11y.destroy();
7807 },
7808 },
7809 };
7810
7811 // Swiper Class
7812 var components = [ Navigation$1, Pagination$1, Zoom$1, A11y$1 ];
7813 Swiper.use( components );
7814
7815 return Swiper;
7816 } );
7817 //# sourceMappingURL=swiper-bundle.js.map
7818