@salla.sa/twilight-components 2.9.49 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/cjs/{index-7b85482c.js → app-globals-a24e299c.js} +31 -2
  2. package/dist/cjs/index-1d2b3370.js +0 -4
  3. package/dist/cjs/loader.cjs.js +3 -2
  4. package/dist/cjs/salla-add-product-button.cjs.entry.js +7 -3
  5. package/dist/cjs/salla-button_35.cjs.entry.js +591 -1906
  6. package/dist/cjs/twilight.cjs.js +3 -2
  7. package/dist/collection/collection-manifest.json +0 -1
  8. package/dist/collection/components/salla-add-product-button/salla-add-product-button.js +9 -5
  9. package/dist/collection/components/salla-button/salla-button.js +5 -1
  10. package/dist/collection/components/salla-file-upload/salla-file-upload.js +9 -8
  11. package/dist/collection/components/salla-gifting/salla-gifting.js +18 -14
  12. package/dist/collection/components/salla-loyalty/salla-loyalty.js +5 -3
  13. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +6 -5
  14. package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +14 -10
  15. package/dist/collection/components/salla-slider/salla-slider.css +242 -0
  16. package/dist/collection/components/salla-slider/salla-slider.js +403 -110
  17. package/dist/collection/global/app-dev.js +2 -1
  18. package/dist/collection/global/app.js +15 -0
  19. package/dist/components/index.d.ts +0 -1
  20. package/dist/components/index.js +31 -3
  21. package/dist/components/salla-add-product-button.js +7 -3
  22. package/dist/components/salla-button2.js +5 -1
  23. package/dist/components/salla-file-upload2.js +249 -3
  24. package/dist/components/salla-gifting.js +26 -16
  25. package/dist/components/salla-loyalty.js +3 -3
  26. package/dist/components/salla-offer-modal.js +5 -4
  27. package/dist/components/salla-rating-stars2.js +8 -4
  28. package/dist/components/salla-slider2.js +229 -1806
  29. package/dist/esm/{index-adc28dc8.js → app-globals-1619c0de.js} +31 -2
  30. package/dist/esm/index-f1d446ac.js +0 -4
  31. package/dist/esm/loader.js +3 -2
  32. package/dist/esm/salla-add-product-button.entry.js +7 -3
  33. package/dist/esm/salla-button_35.entry.js +590 -1905
  34. package/dist/esm/twilight.js +3 -2
  35. package/dist/esm-es5/{index-adc28dc8.js → app-globals-1619c0de.js} +2 -2
  36. package/dist/esm-es5/index-f1d446ac.js +2 -2
  37. package/dist/esm-es5/loader.js +1 -1
  38. package/dist/esm-es5/salla-add-product-button.entry.js +1 -1
  39. package/dist/esm-es5/salla-button_35.entry.js +11 -5
  40. package/dist/esm-es5/twilight.js +1 -1
  41. package/dist/twilight/p-0f839b43.system.js +4 -0
  42. package/dist/twilight/p-3420f00c.entry.js +30 -0
  43. package/dist/twilight/p-5207a10c.system.js +24 -0
  44. package/dist/twilight/{p-486ce499.system.entry.js → p-5a1197bb.system.entry.js} +1 -1
  45. package/dist/twilight/p-5b30b649.system.entry.js +47 -0
  46. package/dist/twilight/p-97614f6d.js +24 -0
  47. package/dist/twilight/{p-6f41faf8.entry.js → p-dbb379ce.entry.js} +1 -1
  48. package/dist/twilight/twilight.esm.js +1 -1
  49. package/dist/twilight/twilight.js +1 -1
  50. package/dist/types/components/salla-slider/salla-slider.d.ts +73 -14
  51. package/dist/types/components.d.ts +83 -60
  52. package/dist/types/global/app-dev.d.ts +0 -1
  53. package/package.json +6 -4
  54. package/dist/cjs/core-c7a9fb22.js +0 -4982
  55. package/dist/cjs/salla-swiper.cjs.entry.js +0 -62
  56. package/dist/collection/components/salla-swiper/salla-swiper.css +0 -177
  57. package/dist/collection/components/salla-swiper/salla-swiper.js +0 -152
  58. package/dist/components/arrow-left.js +0 -11
  59. package/dist/components/core.js +0 -4959
  60. package/dist/components/salla-swiper.d.ts +0 -11
  61. package/dist/components/salla-swiper.js +0 -92
  62. package/dist/esm/core-572aabd0.js +0 -4973
  63. package/dist/esm/salla-swiper.entry.js +0 -58
  64. package/dist/esm-es5/core-572aabd0.js +0 -4
  65. package/dist/esm-es5/salla-swiper.entry.js +0 -4
  66. package/dist/twilight/p-00e66d1a.system.js +0 -4
  67. package/dist/twilight/p-684a004a.system.entry.js +0 -4
  68. package/dist/twilight/p-6ed7d3a2.js +0 -4
  69. package/dist/twilight/p-7234a2a2.entry.js +0 -30
  70. package/dist/twilight/p-a84812f4.system.js +0 -4
  71. package/dist/twilight/p-d3daf7a7.system.entry.js +0 -41
  72. package/dist/twilight/p-e55e8d3d.js +0 -24
  73. package/dist/twilight/p-e8c3c209.entry.js +0 -4
  74. package/dist/twilight/p-ea021b56.system.js +0 -24
  75. package/dist/types/components/salla-swiper/salla-swiper.d.ts +0 -31
  76. package/dist/types/index.d.ts +0 -7
@@ -1,4982 +0,0 @@
1
- /*!
2
- * Crafted with ❤ by Salla
3
- */
4
- 'use strict';
5
-
6
- const ArrowRightIcon = `<!-- Generated by IcoMoon.io -->
7
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
8
- <title>arrow-right</title>
9
- <path d="M29.217 15.465c-0.019-0.044-0.056-0.077-0.080-0.119-0.067-0.116-0.139-0.227-0.236-0.317-0.011-0.009-0.013-0.024-0.024-0.033l-10.667-9.333c-0.553-0.484-1.396-0.429-1.881 0.125-0.484 0.555-0.428 1.396 0.127 1.881l7.996 6.997h-20.452c-0.737 0-1.333 0.597-1.333 1.333s0.596 1.333 1.333 1.333h20.452l-7.996 6.997c-0.555 0.485-0.611 1.327-0.127 1.881 0.264 0.3 0.633 0.455 1.004 0.455 0.312 0 0.625-0.109 0.877-0.331l10.667-9.333c0.011-0.009 0.015-0.024 0.024-0.033 0.097-0.091 0.169-0.201 0.236-0.317 0.024-0.041 0.060-0.075 0.080-0.119 0.073-0.163 0.116-0.343 0.116-0.533s-0.043-0.371-0.116-0.535z"></path>
10
- </svg>
11
- `;
12
-
13
- const ArrowLeftIcon = `<!-- Generated by IcoMoon.io -->
14
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
15
- <title>arrow-left</title>
16
- <path d="M28 14.667h-20.452l7.996-6.997c0.555-0.485 0.611-1.327 0.125-1.881-0.485-0.553-1.327-0.611-1.881-0.125l-10.667 9.333c-0.011 0.009-0.015 0.024-0.025 0.033-0.096 0.089-0.167 0.199-0.232 0.313-0.025 0.043-0.063 0.076-0.081 0.121-0.073 0.165-0.116 0.345-0.116 0.536s0.043 0.371 0.116 0.535c0.020 0.045 0.057 0.079 0.081 0.121 0.067 0.115 0.136 0.224 0.232 0.313 0.011 0.009 0.015 0.024 0.025 0.033l10.667 9.333c0.253 0.221 0.567 0.331 0.879 0.331 0.371 0 0.74-0.155 1.004-0.455 0.485-0.555 0.429-1.396-0.125-1.881l-7.997-6.997h20.452c0.736 0 1.333-0.597 1.333-1.333s-0.597-1.333-1.333-1.333z"></path>
17
- </svg>
18
- `;
19
-
20
- /**
21
- * SSR Window 4.0.2
22
- * Better handling for window object in SSR environment
23
- * https://github.com/nolimits4web/ssr-window
24
- *
25
- * Copyright 2021, Vladimir Kharlampidi
26
- *
27
- * Licensed under MIT
28
- *
29
- * Released on: December 13, 2021
30
- */
31
- /* eslint-disable no-param-reassign */
32
- function isObject$1(obj) {
33
- return (obj !== null &&
34
- typeof obj === 'object' &&
35
- 'constructor' in obj &&
36
- obj.constructor === Object);
37
- }
38
- function extend$1(target = {}, src = {}) {
39
- Object.keys(src).forEach((key) => {
40
- if (typeof target[key] === 'undefined')
41
- target[key] = src[key];
42
- else if (isObject$1(src[key]) &&
43
- isObject$1(target[key]) &&
44
- Object.keys(src[key]).length > 0) {
45
- extend$1(target[key], src[key]);
46
- }
47
- });
48
- }
49
-
50
- const ssrDocument = {
51
- body: {},
52
- addEventListener() { },
53
- removeEventListener() { },
54
- activeElement: {
55
- blur() { },
56
- nodeName: '',
57
- },
58
- querySelector() {
59
- return null;
60
- },
61
- querySelectorAll() {
62
- return [];
63
- },
64
- getElementById() {
65
- return null;
66
- },
67
- createEvent() {
68
- return {
69
- initEvent() { },
70
- };
71
- },
72
- createElement() {
73
- return {
74
- children: [],
75
- childNodes: [],
76
- style: {},
77
- setAttribute() { },
78
- getElementsByTagName() {
79
- return [];
80
- },
81
- };
82
- },
83
- createElementNS() {
84
- return {};
85
- },
86
- importNode() {
87
- return null;
88
- },
89
- location: {
90
- hash: '',
91
- host: '',
92
- hostname: '',
93
- href: '',
94
- origin: '',
95
- pathname: '',
96
- protocol: '',
97
- search: '',
98
- },
99
- };
100
- function getDocument() {
101
- const doc = typeof document !== 'undefined' ? document : {};
102
- extend$1(doc, ssrDocument);
103
- return doc;
104
- }
105
-
106
- const ssrWindow = {
107
- document: ssrDocument,
108
- navigator: {
109
- userAgent: '',
110
- },
111
- location: {
112
- hash: '',
113
- host: '',
114
- hostname: '',
115
- href: '',
116
- origin: '',
117
- pathname: '',
118
- protocol: '',
119
- search: '',
120
- },
121
- history: {
122
- replaceState() { },
123
- pushState() { },
124
- go() { },
125
- back() { },
126
- },
127
- CustomEvent: function CustomEvent() {
128
- return this;
129
- },
130
- addEventListener() { },
131
- removeEventListener() { },
132
- getComputedStyle() {
133
- return {
134
- getPropertyValue() {
135
- return '';
136
- },
137
- };
138
- },
139
- Image() { },
140
- Date() { },
141
- screen: {},
142
- setTimeout() { },
143
- clearTimeout() { },
144
- matchMedia() {
145
- return {};
146
- },
147
- requestAnimationFrame(callback) {
148
- if (typeof setTimeout === 'undefined') {
149
- callback();
150
- return null;
151
- }
152
- return setTimeout(callback, 0);
153
- },
154
- cancelAnimationFrame(id) {
155
- if (typeof setTimeout === 'undefined') {
156
- return;
157
- }
158
- clearTimeout(id);
159
- },
160
- };
161
- function getWindow() {
162
- const win = typeof window !== 'undefined' ? window : {};
163
- extend$1(win, ssrWindow);
164
- return win;
165
- }
166
-
167
- /**
168
- * Dom7 4.0.4
169
- * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
170
- * https://framework7.io/docs/dom7.html
171
- *
172
- * Copyright 2022, Vladimir Kharlampidi
173
- *
174
- * Licensed under MIT
175
- *
176
- * Released on: January 11, 2022
177
- */
178
-
179
- /* eslint-disable no-proto */
180
- function makeReactive(obj) {
181
- const proto = obj.__proto__;
182
- Object.defineProperty(obj, '__proto__', {
183
- get() {
184
- return proto;
185
- },
186
-
187
- set(value) {
188
- proto.__proto__ = value;
189
- }
190
-
191
- });
192
- }
193
-
194
- class Dom7 extends Array {
195
- constructor(items) {
196
- if (typeof items === 'number') {
197
- super(items);
198
- } else {
199
- super(...(items || []));
200
- makeReactive(this);
201
- }
202
- }
203
-
204
- }
205
-
206
- function arrayFlat(arr = []) {
207
- const res = [];
208
- arr.forEach(el => {
209
- if (Array.isArray(el)) {
210
- res.push(...arrayFlat(el));
211
- } else {
212
- res.push(el);
213
- }
214
- });
215
- return res;
216
- }
217
- function arrayFilter(arr, callback) {
218
- return Array.prototype.filter.call(arr, callback);
219
- }
220
- function arrayUnique(arr) {
221
- const uniqueArray = [];
222
-
223
- for (let i = 0; i < arr.length; i += 1) {
224
- if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
225
- }
226
-
227
- return uniqueArray;
228
- }
229
-
230
- // eslint-disable-next-line
231
-
232
- function qsa(selector, context) {
233
- if (typeof selector !== 'string') {
234
- return [selector];
235
- }
236
-
237
- const a = [];
238
- const res = context.querySelectorAll(selector);
239
-
240
- for (let i = 0; i < res.length; i += 1) {
241
- a.push(res[i]);
242
- }
243
-
244
- return a;
245
- }
246
-
247
- function $(selector, context) {
248
- const window = getWindow();
249
- const document = getDocument();
250
- let arr = [];
251
-
252
- if (!context && selector instanceof Dom7) {
253
- return selector;
254
- }
255
-
256
- if (!selector) {
257
- return new Dom7(arr);
258
- }
259
-
260
- if (typeof selector === 'string') {
261
- const html = selector.trim();
262
-
263
- if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
264
- let toCreate = 'div';
265
- if (html.indexOf('<li') === 0) toCreate = 'ul';
266
- if (html.indexOf('<tr') === 0) toCreate = 'tbody';
267
- if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
268
- if (html.indexOf('<tbody') === 0) toCreate = 'table';
269
- if (html.indexOf('<option') === 0) toCreate = 'select';
270
- const tempParent = document.createElement(toCreate);
271
- tempParent.innerHTML = html;
272
-
273
- for (let i = 0; i < tempParent.childNodes.length; i += 1) {
274
- arr.push(tempParent.childNodes[i]);
275
- }
276
- } else {
277
- arr = qsa(selector.trim(), context || document);
278
- } // arr = qsa(selector, document);
279
-
280
- } else if (selector.nodeType || selector === window || selector === document) {
281
- arr.push(selector);
282
- } else if (Array.isArray(selector)) {
283
- if (selector instanceof Dom7) return selector;
284
- arr = selector;
285
- }
286
-
287
- return new Dom7(arrayUnique(arr));
288
- }
289
-
290
- $.fn = Dom7.prototype;
291
-
292
- // eslint-disable-next-line
293
-
294
- function addClass(...classes) {
295
- const classNames = arrayFlat(classes.map(c => c.split(' ')));
296
- this.forEach(el => {
297
- el.classList.add(...classNames);
298
- });
299
- return this;
300
- }
301
-
302
- function removeClass(...classes) {
303
- const classNames = arrayFlat(classes.map(c => c.split(' ')));
304
- this.forEach(el => {
305
- el.classList.remove(...classNames);
306
- });
307
- return this;
308
- }
309
-
310
- function toggleClass(...classes) {
311
- const classNames = arrayFlat(classes.map(c => c.split(' ')));
312
- this.forEach(el => {
313
- classNames.forEach(className => {
314
- el.classList.toggle(className);
315
- });
316
- });
317
- }
318
-
319
- function hasClass(...classes) {
320
- const classNames = arrayFlat(classes.map(c => c.split(' ')));
321
- return arrayFilter(this, el => {
322
- return classNames.filter(className => el.classList.contains(className)).length > 0;
323
- }).length > 0;
324
- }
325
-
326
- function attr(attrs, value) {
327
- if (arguments.length === 1 && typeof attrs === 'string') {
328
- // Get attr
329
- if (this[0]) return this[0].getAttribute(attrs);
330
- return undefined;
331
- } // Set attrs
332
-
333
-
334
- for (let i = 0; i < this.length; i += 1) {
335
- if (arguments.length === 2) {
336
- // String
337
- this[i].setAttribute(attrs, value);
338
- } else {
339
- // Object
340
- for (const attrName in attrs) {
341
- this[i][attrName] = attrs[attrName];
342
- this[i].setAttribute(attrName, attrs[attrName]);
343
- }
344
- }
345
- }
346
-
347
- return this;
348
- }
349
-
350
- function removeAttr(attr) {
351
- for (let i = 0; i < this.length; i += 1) {
352
- this[i].removeAttribute(attr);
353
- }
354
-
355
- return this;
356
- }
357
-
358
- function transform(transform) {
359
- for (let i = 0; i < this.length; i += 1) {
360
- this[i].style.transform = transform;
361
- }
362
-
363
- return this;
364
- }
365
-
366
- function transition$1(duration) {
367
- for (let i = 0; i < this.length; i += 1) {
368
- this[i].style.transitionDuration = typeof duration !== 'string' ? `${duration}ms` : duration;
369
- }
370
-
371
- return this;
372
- }
373
-
374
- function on(...args) {
375
- let [eventType, targetSelector, listener, capture] = args;
376
-
377
- if (typeof args[1] === 'function') {
378
- [eventType, listener, capture] = args;
379
- targetSelector = undefined;
380
- }
381
-
382
- if (!capture) capture = false;
383
-
384
- function handleLiveEvent(e) {
385
- const target = e.target;
386
- if (!target) return;
387
- const eventData = e.target.dom7EventData || [];
388
-
389
- if (eventData.indexOf(e) < 0) {
390
- eventData.unshift(e);
391
- }
392
-
393
- if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
394
- const parents = $(target).parents(); // eslint-disable-line
395
-
396
- for (let k = 0; k < parents.length; k += 1) {
397
- if ($(parents[k]).is(targetSelector)) listener.apply(parents[k], eventData);
398
- }
399
- }
400
- }
401
-
402
- function handleEvent(e) {
403
- const eventData = e && e.target ? e.target.dom7EventData || [] : [];
404
-
405
- if (eventData.indexOf(e) < 0) {
406
- eventData.unshift(e);
407
- }
408
-
409
- listener.apply(this, eventData);
410
- }
411
-
412
- const events = eventType.split(' ');
413
- let j;
414
-
415
- for (let i = 0; i < this.length; i += 1) {
416
- const el = this[i];
417
-
418
- if (!targetSelector) {
419
- for (j = 0; j < events.length; j += 1) {
420
- const event = events[j];
421
- if (!el.dom7Listeners) el.dom7Listeners = {};
422
- if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
423
- el.dom7Listeners[event].push({
424
- listener,
425
- proxyListener: handleEvent
426
- });
427
- el.addEventListener(event, handleEvent, capture);
428
- }
429
- } else {
430
- // Live events
431
- for (j = 0; j < events.length; j += 1) {
432
- const event = events[j];
433
- if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
434
- if (!el.dom7LiveListeners[event]) el.dom7LiveListeners[event] = [];
435
- el.dom7LiveListeners[event].push({
436
- listener,
437
- proxyListener: handleLiveEvent
438
- });
439
- el.addEventListener(event, handleLiveEvent, capture);
440
- }
441
- }
442
- }
443
-
444
- return this;
445
- }
446
-
447
- function off(...args) {
448
- let [eventType, targetSelector, listener, capture] = args;
449
-
450
- if (typeof args[1] === 'function') {
451
- [eventType, listener, capture] = args;
452
- targetSelector = undefined;
453
- }
454
-
455
- if (!capture) capture = false;
456
- const events = eventType.split(' ');
457
-
458
- for (let i = 0; i < events.length; i += 1) {
459
- const event = events[i];
460
-
461
- for (let j = 0; j < this.length; j += 1) {
462
- const el = this[j];
463
- let handlers;
464
-
465
- if (!targetSelector && el.dom7Listeners) {
466
- handlers = el.dom7Listeners[event];
467
- } else if (targetSelector && el.dom7LiveListeners) {
468
- handlers = el.dom7LiveListeners[event];
469
- }
470
-
471
- if (handlers && handlers.length) {
472
- for (let k = handlers.length - 1; k >= 0; k -= 1) {
473
- const handler = handlers[k];
474
-
475
- if (listener && handler.listener === listener) {
476
- el.removeEventListener(event, handler.proxyListener, capture);
477
- handlers.splice(k, 1);
478
- } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
479
- el.removeEventListener(event, handler.proxyListener, capture);
480
- handlers.splice(k, 1);
481
- } else if (!listener) {
482
- el.removeEventListener(event, handler.proxyListener, capture);
483
- handlers.splice(k, 1);
484
- }
485
- }
486
- }
487
- }
488
- }
489
-
490
- return this;
491
- }
492
-
493
- function trigger(...args) {
494
- const window = getWindow();
495
- const events = args[0].split(' ');
496
- const eventData = args[1];
497
-
498
- for (let i = 0; i < events.length; i += 1) {
499
- const event = events[i];
500
-
501
- for (let j = 0; j < this.length; j += 1) {
502
- const el = this[j];
503
-
504
- if (window.CustomEvent) {
505
- const evt = new window.CustomEvent(event, {
506
- detail: eventData,
507
- bubbles: true,
508
- cancelable: true
509
- });
510
- el.dom7EventData = args.filter((data, dataIndex) => dataIndex > 0);
511
- el.dispatchEvent(evt);
512
- el.dom7EventData = [];
513
- delete el.dom7EventData;
514
- }
515
- }
516
- }
517
-
518
- return this;
519
- }
520
-
521
- function transitionEnd$1(callback) {
522
- const dom = this;
523
-
524
- function fireCallBack(e) {
525
- if (e.target !== this) return;
526
- callback.call(this, e);
527
- dom.off('transitionend', fireCallBack);
528
- }
529
-
530
- if (callback) {
531
- dom.on('transitionend', fireCallBack);
532
- }
533
-
534
- return this;
535
- }
536
-
537
- function outerWidth(includeMargins) {
538
- if (this.length > 0) {
539
- if (includeMargins) {
540
- const styles = this.styles();
541
- return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left'));
542
- }
543
-
544
- return this[0].offsetWidth;
545
- }
546
-
547
- return null;
548
- }
549
-
550
- function outerHeight(includeMargins) {
551
- if (this.length > 0) {
552
- if (includeMargins) {
553
- const styles = this.styles();
554
- return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom'));
555
- }
556
-
557
- return this[0].offsetHeight;
558
- }
559
-
560
- return null;
561
- }
562
-
563
- function offset() {
564
- if (this.length > 0) {
565
- const window = getWindow();
566
- const document = getDocument();
567
- const el = this[0];
568
- const box = el.getBoundingClientRect();
569
- const body = document.body;
570
- const clientTop = el.clientTop || body.clientTop || 0;
571
- const clientLeft = el.clientLeft || body.clientLeft || 0;
572
- const scrollTop = el === window ? window.scrollY : el.scrollTop;
573
- const scrollLeft = el === window ? window.scrollX : el.scrollLeft;
574
- return {
575
- top: box.top + scrollTop - clientTop,
576
- left: box.left + scrollLeft - clientLeft
577
- };
578
- }
579
-
580
- return null;
581
- }
582
-
583
- function styles() {
584
- const window = getWindow();
585
- if (this[0]) return window.getComputedStyle(this[0], null);
586
- return {};
587
- }
588
-
589
- function css(props, value) {
590
- const window = getWindow();
591
- let i;
592
-
593
- if (arguments.length === 1) {
594
- if (typeof props === 'string') {
595
- // .css('width')
596
- if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
597
- } else {
598
- // .css({ width: '100px' })
599
- for (i = 0; i < this.length; i += 1) {
600
- for (const prop in props) {
601
- this[i].style[prop] = props[prop];
602
- }
603
- }
604
-
605
- return this;
606
- }
607
- }
608
-
609
- if (arguments.length === 2 && typeof props === 'string') {
610
- // .css('width', '100px')
611
- for (i = 0; i < this.length; i += 1) {
612
- this[i].style[props] = value;
613
- }
614
-
615
- return this;
616
- }
617
-
618
- return this;
619
- }
620
-
621
- function each(callback) {
622
- if (!callback) return this;
623
- this.forEach((el, index) => {
624
- callback.apply(el, [el, index]);
625
- });
626
- return this;
627
- }
628
-
629
- function filter(callback) {
630
- const result = arrayFilter(this, callback);
631
- return $(result);
632
- }
633
-
634
- function html(html) {
635
- if (typeof html === 'undefined') {
636
- return this[0] ? this[0].innerHTML : null;
637
- }
638
-
639
- for (let i = 0; i < this.length; i += 1) {
640
- this[i].innerHTML = html;
641
- }
642
-
643
- return this;
644
- }
645
-
646
- function text(text) {
647
- if (typeof text === 'undefined') {
648
- return this[0] ? this[0].textContent.trim() : null;
649
- }
650
-
651
- for (let i = 0; i < this.length; i += 1) {
652
- this[i].textContent = text;
653
- }
654
-
655
- return this;
656
- }
657
-
658
- function is(selector) {
659
- const window = getWindow();
660
- const document = getDocument();
661
- const el = this[0];
662
- let compareWith;
663
- let i;
664
- if (!el || typeof selector === 'undefined') return false;
665
-
666
- if (typeof selector === 'string') {
667
- if (el.matches) return el.matches(selector);
668
- if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
669
- if (el.msMatchesSelector) return el.msMatchesSelector(selector);
670
- compareWith = $(selector);
671
-
672
- for (i = 0; i < compareWith.length; i += 1) {
673
- if (compareWith[i] === el) return true;
674
- }
675
-
676
- return false;
677
- }
678
-
679
- if (selector === document) {
680
- return el === document;
681
- }
682
-
683
- if (selector === window) {
684
- return el === window;
685
- }
686
-
687
- if (selector.nodeType || selector instanceof Dom7) {
688
- compareWith = selector.nodeType ? [selector] : selector;
689
-
690
- for (i = 0; i < compareWith.length; i += 1) {
691
- if (compareWith[i] === el) return true;
692
- }
693
-
694
- return false;
695
- }
696
-
697
- return false;
698
- }
699
-
700
- function index() {
701
- let child = this[0];
702
- let i;
703
-
704
- if (child) {
705
- i = 0; // eslint-disable-next-line
706
-
707
- while ((child = child.previousSibling) !== null) {
708
- if (child.nodeType === 1) i += 1;
709
- }
710
-
711
- return i;
712
- }
713
-
714
- return undefined;
715
- }
716
-
717
- function eq(index) {
718
- if (typeof index === 'undefined') return this;
719
- const length = this.length;
720
-
721
- if (index > length - 1) {
722
- return $([]);
723
- }
724
-
725
- if (index < 0) {
726
- const returnIndex = length + index;
727
- if (returnIndex < 0) return $([]);
728
- return $([this[returnIndex]]);
729
- }
730
-
731
- return $([this[index]]);
732
- }
733
-
734
- function append(...els) {
735
- let newChild;
736
- const document = getDocument();
737
-
738
- for (let k = 0; k < els.length; k += 1) {
739
- newChild = els[k];
740
-
741
- for (let i = 0; i < this.length; i += 1) {
742
- if (typeof newChild === 'string') {
743
- const tempDiv = document.createElement('div');
744
- tempDiv.innerHTML = newChild;
745
-
746
- while (tempDiv.firstChild) {
747
- this[i].appendChild(tempDiv.firstChild);
748
- }
749
- } else if (newChild instanceof Dom7) {
750
- for (let j = 0; j < newChild.length; j += 1) {
751
- this[i].appendChild(newChild[j]);
752
- }
753
- } else {
754
- this[i].appendChild(newChild);
755
- }
756
- }
757
- }
758
-
759
- return this;
760
- }
761
-
762
- function prepend(newChild) {
763
- const document = getDocument();
764
- let i;
765
- let j;
766
-
767
- for (i = 0; i < this.length; i += 1) {
768
- if (typeof newChild === 'string') {
769
- const tempDiv = document.createElement('div');
770
- tempDiv.innerHTML = newChild;
771
-
772
- for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
773
- this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
774
- }
775
- } else if (newChild instanceof Dom7) {
776
- for (j = 0; j < newChild.length; j += 1) {
777
- this[i].insertBefore(newChild[j], this[i].childNodes[0]);
778
- }
779
- } else {
780
- this[i].insertBefore(newChild, this[i].childNodes[0]);
781
- }
782
- }
783
-
784
- return this;
785
- }
786
-
787
- function next(selector) {
788
- if (this.length > 0) {
789
- if (selector) {
790
- if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
791
- return $([this[0].nextElementSibling]);
792
- }
793
-
794
- return $([]);
795
- }
796
-
797
- if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);
798
- return $([]);
799
- }
800
-
801
- return $([]);
802
- }
803
-
804
- function nextAll(selector) {
805
- const nextEls = [];
806
- let el = this[0];
807
- if (!el) return $([]);
808
-
809
- while (el.nextElementSibling) {
810
- const next = el.nextElementSibling; // eslint-disable-line
811
-
812
- if (selector) {
813
- if ($(next).is(selector)) nextEls.push(next);
814
- } else nextEls.push(next);
815
-
816
- el = next;
817
- }
818
-
819
- return $(nextEls);
820
- }
821
-
822
- function prev(selector) {
823
- if (this.length > 0) {
824
- const el = this[0];
825
-
826
- if (selector) {
827
- if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
828
- return $([el.previousElementSibling]);
829
- }
830
-
831
- return $([]);
832
- }
833
-
834
- if (el.previousElementSibling) return $([el.previousElementSibling]);
835
- return $([]);
836
- }
837
-
838
- return $([]);
839
- }
840
-
841
- function prevAll(selector) {
842
- const prevEls = [];
843
- let el = this[0];
844
- if (!el) return $([]);
845
-
846
- while (el.previousElementSibling) {
847
- const prev = el.previousElementSibling; // eslint-disable-line
848
-
849
- if (selector) {
850
- if ($(prev).is(selector)) prevEls.push(prev);
851
- } else prevEls.push(prev);
852
-
853
- el = prev;
854
- }
855
-
856
- return $(prevEls);
857
- }
858
-
859
- function parent(selector) {
860
- const parents = []; // eslint-disable-line
861
-
862
- for (let i = 0; i < this.length; i += 1) {
863
- if (this[i].parentNode !== null) {
864
- if (selector) {
865
- if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
866
- } else {
867
- parents.push(this[i].parentNode);
868
- }
869
- }
870
- }
871
-
872
- return $(parents);
873
- }
874
-
875
- function parents(selector) {
876
- const parents = []; // eslint-disable-line
877
-
878
- for (let i = 0; i < this.length; i += 1) {
879
- let parent = this[i].parentNode; // eslint-disable-line
880
-
881
- while (parent) {
882
- if (selector) {
883
- if ($(parent).is(selector)) parents.push(parent);
884
- } else {
885
- parents.push(parent);
886
- }
887
-
888
- parent = parent.parentNode;
889
- }
890
- }
891
-
892
- return $(parents);
893
- }
894
-
895
- function closest(selector) {
896
- let closest = this; // eslint-disable-line
897
-
898
- if (typeof selector === 'undefined') {
899
- return $([]);
900
- }
901
-
902
- if (!closest.is(selector)) {
903
- closest = closest.parents(selector).eq(0);
904
- }
905
-
906
- return closest;
907
- }
908
-
909
- function find(selector) {
910
- const foundElements = [];
911
-
912
- for (let i = 0; i < this.length; i += 1) {
913
- const found = this[i].querySelectorAll(selector);
914
-
915
- for (let j = 0; j < found.length; j += 1) {
916
- foundElements.push(found[j]);
917
- }
918
- }
919
-
920
- return $(foundElements);
921
- }
922
-
923
- function children(selector) {
924
- const children = []; // eslint-disable-line
925
-
926
- for (let i = 0; i < this.length; i += 1) {
927
- const childNodes = this[i].children;
928
-
929
- for (let j = 0; j < childNodes.length; j += 1) {
930
- if (!selector || $(childNodes[j]).is(selector)) {
931
- children.push(childNodes[j]);
932
- }
933
- }
934
- }
935
-
936
- return $(children);
937
- }
938
-
939
- function remove() {
940
- for (let i = 0; i < this.length; i += 1) {
941
- if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
942
- }
943
-
944
- return this;
945
- }
946
-
947
- const Methods = {
948
- addClass,
949
- removeClass,
950
- hasClass,
951
- toggleClass,
952
- attr,
953
- removeAttr,
954
- transform,
955
- transition: transition$1,
956
- on,
957
- off,
958
- trigger,
959
- transitionEnd: transitionEnd$1,
960
- outerWidth,
961
- outerHeight,
962
- styles,
963
- offset,
964
- css,
965
- each,
966
- html,
967
- text,
968
- is,
969
- index,
970
- eq,
971
- append,
972
- prepend,
973
- next,
974
- nextAll,
975
- prev,
976
- prevAll,
977
- parent,
978
- parents,
979
- closest,
980
- find,
981
- children,
982
- filter,
983
- remove
984
- };
985
- Object.keys(Methods).forEach(methodName => {
986
- Object.defineProperty($.fn, methodName, {
987
- value: Methods[methodName],
988
- writable: true
989
- });
990
- });
991
-
992
- function deleteProps(obj) {
993
- const object = obj;
994
- Object.keys(object).forEach(key => {
995
- try {
996
- object[key] = null;
997
- } catch (e) {// no getter for object
998
- }
999
-
1000
- try {
1001
- delete object[key];
1002
- } catch (e) {// something got wrong
1003
- }
1004
- });
1005
- }
1006
-
1007
- function nextTick(callback, delay) {
1008
- if (delay === void 0) {
1009
- delay = 0;
1010
- }
1011
-
1012
- return setTimeout(callback, delay);
1013
- }
1014
-
1015
- function now() {
1016
- return Date.now();
1017
- }
1018
-
1019
- function getComputedStyle$1(el) {
1020
- const window = getWindow();
1021
- let style;
1022
-
1023
- if (window.getComputedStyle) {
1024
- style = window.getComputedStyle(el, null);
1025
- }
1026
-
1027
- if (!style && el.currentStyle) {
1028
- style = el.currentStyle;
1029
- }
1030
-
1031
- if (!style) {
1032
- style = el.style;
1033
- }
1034
-
1035
- return style;
1036
- }
1037
-
1038
- function getTranslate(el, axis) {
1039
- if (axis === void 0) {
1040
- axis = 'x';
1041
- }
1042
-
1043
- const window = getWindow();
1044
- let matrix;
1045
- let curTransform;
1046
- let transformMatrix;
1047
- const curStyle = getComputedStyle$1(el);
1048
-
1049
- if (window.WebKitCSSMatrix) {
1050
- curTransform = curStyle.transform || curStyle.webkitTransform;
1051
-
1052
- if (curTransform.split(',').length > 6) {
1053
- curTransform = curTransform.split(', ').map(a => a.replace(',', '.')).join(', ');
1054
- } // Some old versions of Webkit choke when 'none' is passed; pass
1055
- // empty string instead in this case
1056
-
1057
-
1058
- transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
1059
- } else {
1060
- transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
1061
- matrix = transformMatrix.toString().split(',');
1062
- }
1063
-
1064
- if (axis === 'x') {
1065
- // Latest Chrome and webkits Fix
1066
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix
1067
- else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers
1068
- else curTransform = parseFloat(matrix[4]);
1069
- }
1070
-
1071
- if (axis === 'y') {
1072
- // Latest Chrome and webkits Fix
1073
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix
1074
- else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers
1075
- else curTransform = parseFloat(matrix[5]);
1076
- }
1077
-
1078
- return curTransform || 0;
1079
- }
1080
-
1081
- function isObject(o) {
1082
- return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
1083
- }
1084
-
1085
- function isNode(node) {
1086
- // eslint-disable-next-line
1087
- if (typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined') {
1088
- return node instanceof HTMLElement;
1089
- }
1090
-
1091
- return node && (node.nodeType === 1 || node.nodeType === 11);
1092
- }
1093
-
1094
- function extend() {
1095
- const to = Object(arguments.length <= 0 ? undefined : arguments[0]);
1096
- const noExtend = ['__proto__', 'constructor', 'prototype'];
1097
-
1098
- for (let i = 1; i < arguments.length; i += 1) {
1099
- const nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
1100
-
1101
- if (nextSource !== undefined && nextSource !== null && !isNode(nextSource)) {
1102
- const keysArray = Object.keys(Object(nextSource)).filter(key => noExtend.indexOf(key) < 0);
1103
-
1104
- for (let nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
1105
- const nextKey = keysArray[nextIndex];
1106
- const desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
1107
-
1108
- if (desc !== undefined && desc.enumerable) {
1109
- if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
1110
- if (nextSource[nextKey].__swiper__) {
1111
- to[nextKey] = nextSource[nextKey];
1112
- } else {
1113
- extend(to[nextKey], nextSource[nextKey]);
1114
- }
1115
- } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
1116
- to[nextKey] = {};
1117
-
1118
- if (nextSource[nextKey].__swiper__) {
1119
- to[nextKey] = nextSource[nextKey];
1120
- } else {
1121
- extend(to[nextKey], nextSource[nextKey]);
1122
- }
1123
- } else {
1124
- to[nextKey] = nextSource[nextKey];
1125
- }
1126
- }
1127
- }
1128
- }
1129
- }
1130
-
1131
- return to;
1132
- }
1133
-
1134
- function setCSSProperty(el, varName, varValue) {
1135
- el.style.setProperty(varName, varValue);
1136
- }
1137
-
1138
- function animateCSSModeScroll(_ref) {
1139
- let {
1140
- swiper,
1141
- targetPosition,
1142
- side
1143
- } = _ref;
1144
- const window = getWindow();
1145
- const startPosition = -swiper.translate;
1146
- let startTime = null;
1147
- let time;
1148
- const duration = swiper.params.speed;
1149
- swiper.wrapperEl.style.scrollSnapType = 'none';
1150
- window.cancelAnimationFrame(swiper.cssModeFrameID);
1151
- const dir = targetPosition > startPosition ? 'next' : 'prev';
1152
-
1153
- const isOutOfBound = (current, target) => {
1154
- return dir === 'next' && current >= target || dir === 'prev' && current <= target;
1155
- };
1156
-
1157
- const animate = () => {
1158
- time = new Date().getTime();
1159
-
1160
- if (startTime === null) {
1161
- startTime = time;
1162
- }
1163
-
1164
- const progress = Math.max(Math.min((time - startTime) / duration, 1), 0);
1165
- const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
1166
- let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);
1167
-
1168
- if (isOutOfBound(currentPosition, targetPosition)) {
1169
- currentPosition = targetPosition;
1170
- }
1171
-
1172
- swiper.wrapperEl.scrollTo({
1173
- [side]: currentPosition
1174
- });
1175
-
1176
- if (isOutOfBound(currentPosition, targetPosition)) {
1177
- swiper.wrapperEl.style.overflow = 'hidden';
1178
- swiper.wrapperEl.style.scrollSnapType = '';
1179
- setTimeout(() => {
1180
- swiper.wrapperEl.style.overflow = '';
1181
- swiper.wrapperEl.scrollTo({
1182
- [side]: currentPosition
1183
- });
1184
- });
1185
- window.cancelAnimationFrame(swiper.cssModeFrameID);
1186
- return;
1187
- }
1188
-
1189
- swiper.cssModeFrameID = window.requestAnimationFrame(animate);
1190
- };
1191
-
1192
- animate();
1193
- }
1194
-
1195
- let support;
1196
-
1197
- function calcSupport() {
1198
- const window = getWindow();
1199
- const document = getDocument();
1200
- return {
1201
- smoothScroll: document.documentElement && 'scrollBehavior' in document.documentElement.style,
1202
- touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
1203
- passiveListener: function checkPassiveListener() {
1204
- let supportsPassive = false;
1205
-
1206
- try {
1207
- const opts = Object.defineProperty({}, 'passive', {
1208
- // eslint-disable-next-line
1209
- get() {
1210
- supportsPassive = true;
1211
- }
1212
-
1213
- });
1214
- window.addEventListener('testPassiveListener', null, opts);
1215
- } catch (e) {// No support
1216
- }
1217
-
1218
- return supportsPassive;
1219
- }(),
1220
- gestures: function checkGestures() {
1221
- return 'ongesturestart' in window;
1222
- }()
1223
- };
1224
- }
1225
-
1226
- function getSupport() {
1227
- if (!support) {
1228
- support = calcSupport();
1229
- }
1230
-
1231
- return support;
1232
- }
1233
-
1234
- let deviceCached;
1235
-
1236
- function calcDevice(_temp) {
1237
- let {
1238
- userAgent
1239
- } = _temp === void 0 ? {} : _temp;
1240
- const support = getSupport();
1241
- const window = getWindow();
1242
- const platform = window.navigator.platform;
1243
- const ua = userAgent || window.navigator.userAgent;
1244
- const device = {
1245
- ios: false,
1246
- android: false
1247
- };
1248
- const screenWidth = window.screen.width;
1249
- const screenHeight = window.screen.height;
1250
- const android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line
1251
-
1252
- let ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
1253
- const ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
1254
- const iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
1255
- const windows = platform === 'Win32';
1256
- let macos = platform === 'MacIntel'; // iPadOs 13 fix
1257
-
1258
- const iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
1259
-
1260
- if (!ipad && macos && support.touch && iPadScreens.indexOf(`${screenWidth}x${screenHeight}`) >= 0) {
1261
- ipad = ua.match(/(Version)\/([\d.]+)/);
1262
- if (!ipad) ipad = [0, 1, '13_0_0'];
1263
- macos = false;
1264
- } // Android
1265
-
1266
-
1267
- if (android && !windows) {
1268
- device.os = 'android';
1269
- device.android = true;
1270
- }
1271
-
1272
- if (ipad || iphone || ipod) {
1273
- device.os = 'ios';
1274
- device.ios = true;
1275
- } // Export object
1276
-
1277
-
1278
- return device;
1279
- }
1280
-
1281
- function getDevice(overrides) {
1282
- if (overrides === void 0) {
1283
- overrides = {};
1284
- }
1285
-
1286
- if (!deviceCached) {
1287
- deviceCached = calcDevice(overrides);
1288
- }
1289
-
1290
- return deviceCached;
1291
- }
1292
-
1293
- let browser;
1294
-
1295
- function calcBrowser() {
1296
- const window = getWindow();
1297
-
1298
- function isSafari() {
1299
- const ua = window.navigator.userAgent.toLowerCase();
1300
- return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
1301
- }
1302
-
1303
- return {
1304
- isSafari: isSafari(),
1305
- isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
1306
- };
1307
- }
1308
-
1309
- function getBrowser() {
1310
- if (!browser) {
1311
- browser = calcBrowser();
1312
- }
1313
-
1314
- return browser;
1315
- }
1316
-
1317
- function Resize(_ref) {
1318
- let {
1319
- swiper,
1320
- on,
1321
- emit
1322
- } = _ref;
1323
- const window = getWindow();
1324
- let observer = null;
1325
- let animationFrame = null;
1326
-
1327
- const resizeHandler = () => {
1328
- if (!swiper || swiper.destroyed || !swiper.initialized) return;
1329
- emit('beforeResize');
1330
- emit('resize');
1331
- };
1332
-
1333
- const createObserver = () => {
1334
- if (!swiper || swiper.destroyed || !swiper.initialized) return;
1335
- observer = new ResizeObserver(entries => {
1336
- animationFrame = window.requestAnimationFrame(() => {
1337
- const {
1338
- width,
1339
- height
1340
- } = swiper;
1341
- let newWidth = width;
1342
- let newHeight = height;
1343
- entries.forEach(_ref2 => {
1344
- let {
1345
- contentBoxSize,
1346
- contentRect,
1347
- target
1348
- } = _ref2;
1349
- if (target && target !== swiper.el) return;
1350
- newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
1351
- newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
1352
- });
1353
-
1354
- if (newWidth !== width || newHeight !== height) {
1355
- resizeHandler();
1356
- }
1357
- });
1358
- });
1359
- observer.observe(swiper.el);
1360
- };
1361
-
1362
- const removeObserver = () => {
1363
- if (animationFrame) {
1364
- window.cancelAnimationFrame(animationFrame);
1365
- }
1366
-
1367
- if (observer && observer.unobserve && swiper.el) {
1368
- observer.unobserve(swiper.el);
1369
- observer = null;
1370
- }
1371
- };
1372
-
1373
- const orientationChangeHandler = () => {
1374
- if (!swiper || swiper.destroyed || !swiper.initialized) return;
1375
- emit('orientationchange');
1376
- };
1377
-
1378
- on('init', () => {
1379
- if (swiper.params.resizeObserver && typeof window.ResizeObserver !== 'undefined') {
1380
- createObserver();
1381
- return;
1382
- }
1383
-
1384
- window.addEventListener('resize', resizeHandler);
1385
- window.addEventListener('orientationchange', orientationChangeHandler);
1386
- });
1387
- on('destroy', () => {
1388
- removeObserver();
1389
- window.removeEventListener('resize', resizeHandler);
1390
- window.removeEventListener('orientationchange', orientationChangeHandler);
1391
- });
1392
- }
1393
-
1394
- function Observer(_ref) {
1395
- let {
1396
- swiper,
1397
- extendParams,
1398
- on,
1399
- emit
1400
- } = _ref;
1401
- const observers = [];
1402
- const window = getWindow();
1403
-
1404
- const attach = function (target, options) {
1405
- if (options === void 0) {
1406
- options = {};
1407
- }
1408
-
1409
- const ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
1410
- const observer = new ObserverFunc(mutations => {
1411
- // The observerUpdate event should only be triggered
1412
- // once despite the number of mutations. Additional
1413
- // triggers are redundant and are very costly
1414
- if (mutations.length === 1) {
1415
- emit('observerUpdate', mutations[0]);
1416
- return;
1417
- }
1418
-
1419
- const observerUpdate = function observerUpdate() {
1420
- emit('observerUpdate', mutations[0]);
1421
- };
1422
-
1423
- if (window.requestAnimationFrame) {
1424
- window.requestAnimationFrame(observerUpdate);
1425
- } else {
1426
- window.setTimeout(observerUpdate, 0);
1427
- }
1428
- });
1429
- observer.observe(target, {
1430
- attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
1431
- childList: typeof options.childList === 'undefined' ? true : options.childList,
1432
- characterData: typeof options.characterData === 'undefined' ? true : options.characterData
1433
- });
1434
- observers.push(observer);
1435
- };
1436
-
1437
- const init = () => {
1438
- if (!swiper.params.observer) return;
1439
-
1440
- if (swiper.params.observeParents) {
1441
- const containerParents = swiper.$el.parents();
1442
-
1443
- for (let i = 0; i < containerParents.length; i += 1) {
1444
- attach(containerParents[i]);
1445
- }
1446
- } // Observe container
1447
-
1448
-
1449
- attach(swiper.$el[0], {
1450
- childList: swiper.params.observeSlideChildren
1451
- }); // Observe wrapper
1452
-
1453
- attach(swiper.$wrapperEl[0], {
1454
- attributes: false
1455
- });
1456
- };
1457
-
1458
- const destroy = () => {
1459
- observers.forEach(observer => {
1460
- observer.disconnect();
1461
- });
1462
- observers.splice(0, observers.length);
1463
- };
1464
-
1465
- extendParams({
1466
- observer: false,
1467
- observeParents: false,
1468
- observeSlideChildren: false
1469
- });
1470
- on('init', init);
1471
- on('destroy', destroy);
1472
- }
1473
-
1474
- /* eslint-disable no-underscore-dangle */
1475
- const eventsEmitter = {
1476
- on(events, handler, priority) {
1477
- const self = this;
1478
- if (!self.eventsListeners || self.destroyed) return self;
1479
- if (typeof handler !== 'function') return self;
1480
- const method = priority ? 'unshift' : 'push';
1481
- events.split(' ').forEach(event => {
1482
- if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
1483
- self.eventsListeners[event][method](handler);
1484
- });
1485
- return self;
1486
- },
1487
-
1488
- once(events, handler, priority) {
1489
- const self = this;
1490
- if (!self.eventsListeners || self.destroyed) return self;
1491
- if (typeof handler !== 'function') return self;
1492
-
1493
- function onceHandler() {
1494
- self.off(events, onceHandler);
1495
-
1496
- if (onceHandler.__emitterProxy) {
1497
- delete onceHandler.__emitterProxy;
1498
- }
1499
-
1500
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1501
- args[_key] = arguments[_key];
1502
- }
1503
-
1504
- handler.apply(self, args);
1505
- }
1506
-
1507
- onceHandler.__emitterProxy = handler;
1508
- return self.on(events, onceHandler, priority);
1509
- },
1510
-
1511
- onAny(handler, priority) {
1512
- const self = this;
1513
- if (!self.eventsListeners || self.destroyed) return self;
1514
- if (typeof handler !== 'function') return self;
1515
- const method = priority ? 'unshift' : 'push';
1516
-
1517
- if (self.eventsAnyListeners.indexOf(handler) < 0) {
1518
- self.eventsAnyListeners[method](handler);
1519
- }
1520
-
1521
- return self;
1522
- },
1523
-
1524
- offAny(handler) {
1525
- const self = this;
1526
- if (!self.eventsListeners || self.destroyed) return self;
1527
- if (!self.eventsAnyListeners) return self;
1528
- const index = self.eventsAnyListeners.indexOf(handler);
1529
-
1530
- if (index >= 0) {
1531
- self.eventsAnyListeners.splice(index, 1);
1532
- }
1533
-
1534
- return self;
1535
- },
1536
-
1537
- off(events, handler) {
1538
- const self = this;
1539
- if (!self.eventsListeners || self.destroyed) return self;
1540
- if (!self.eventsListeners) return self;
1541
- events.split(' ').forEach(event => {
1542
- if (typeof handler === 'undefined') {
1543
- self.eventsListeners[event] = [];
1544
- } else if (self.eventsListeners[event]) {
1545
- self.eventsListeners[event].forEach((eventHandler, index) => {
1546
- if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
1547
- self.eventsListeners[event].splice(index, 1);
1548
- }
1549
- });
1550
- }
1551
- });
1552
- return self;
1553
- },
1554
-
1555
- emit() {
1556
- const self = this;
1557
- if (!self.eventsListeners || self.destroyed) return self;
1558
- if (!self.eventsListeners) return self;
1559
- let events;
1560
- let data;
1561
- let context;
1562
-
1563
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1564
- args[_key2] = arguments[_key2];
1565
- }
1566
-
1567
- if (typeof args[0] === 'string' || Array.isArray(args[0])) {
1568
- events = args[0];
1569
- data = args.slice(1, args.length);
1570
- context = self;
1571
- } else {
1572
- events = args[0].events;
1573
- data = args[0].data;
1574
- context = args[0].context || self;
1575
- }
1576
-
1577
- data.unshift(context);
1578
- const eventsArray = Array.isArray(events) ? events : events.split(' ');
1579
- eventsArray.forEach(event => {
1580
- if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
1581
- self.eventsAnyListeners.forEach(eventHandler => {
1582
- eventHandler.apply(context, [event, ...data]);
1583
- });
1584
- }
1585
-
1586
- if (self.eventsListeners && self.eventsListeners[event]) {
1587
- self.eventsListeners[event].forEach(eventHandler => {
1588
- eventHandler.apply(context, data);
1589
- });
1590
- }
1591
- });
1592
- return self;
1593
- }
1594
-
1595
- };
1596
-
1597
- function updateSize() {
1598
- const swiper = this;
1599
- let width;
1600
- let height;
1601
- const $el = swiper.$el;
1602
-
1603
- if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
1604
- width = swiper.params.width;
1605
- } else {
1606
- width = $el[0].clientWidth;
1607
- }
1608
-
1609
- if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
1610
- height = swiper.params.height;
1611
- } else {
1612
- height = $el[0].clientHeight;
1613
- }
1614
-
1615
- if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
1616
- return;
1617
- } // Subtract paddings
1618
-
1619
-
1620
- width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10);
1621
- height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10);
1622
- if (Number.isNaN(width)) width = 0;
1623
- if (Number.isNaN(height)) height = 0;
1624
- Object.assign(swiper, {
1625
- width,
1626
- height,
1627
- size: swiper.isHorizontal() ? width : height
1628
- });
1629
- }
1630
-
1631
- function updateSlides() {
1632
- const swiper = this;
1633
-
1634
- function getDirectionLabel(property) {
1635
- if (swiper.isHorizontal()) {
1636
- return property;
1637
- } // prettier-ignore
1638
-
1639
-
1640
- return {
1641
- 'width': 'height',
1642
- 'margin-top': 'margin-left',
1643
- 'margin-bottom ': 'margin-right',
1644
- 'margin-left': 'margin-top',
1645
- 'margin-right': 'margin-bottom',
1646
- 'padding-left': 'padding-top',
1647
- 'padding-right': 'padding-bottom',
1648
- 'marginRight': 'marginBottom'
1649
- }[property];
1650
- }
1651
-
1652
- function getDirectionPropertyValue(node, label) {
1653
- return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
1654
- }
1655
-
1656
- const params = swiper.params;
1657
- const {
1658
- $wrapperEl,
1659
- size: swiperSize,
1660
- rtlTranslate: rtl,
1661
- wrongRTL
1662
- } = swiper;
1663
- const isVirtual = swiper.virtual && params.virtual.enabled;
1664
- const previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
1665
- const slides = $wrapperEl.children(`.${swiper.params.slideClass}`);
1666
- const slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
1667
- let snapGrid = [];
1668
- const slidesGrid = [];
1669
- const slidesSizesGrid = [];
1670
- let offsetBefore = params.slidesOffsetBefore;
1671
-
1672
- if (typeof offsetBefore === 'function') {
1673
- offsetBefore = params.slidesOffsetBefore.call(swiper);
1674
- }
1675
-
1676
- let offsetAfter = params.slidesOffsetAfter;
1677
-
1678
- if (typeof offsetAfter === 'function') {
1679
- offsetAfter = params.slidesOffsetAfter.call(swiper);
1680
- }
1681
-
1682
- const previousSnapGridLength = swiper.snapGrid.length;
1683
- const previousSlidesGridLength = swiper.slidesGrid.length;
1684
- let spaceBetween = params.spaceBetween;
1685
- let slidePosition = -offsetBefore;
1686
- let prevSlideSize = 0;
1687
- let index = 0;
1688
-
1689
- if (typeof swiperSize === 'undefined') {
1690
- return;
1691
- }
1692
-
1693
- if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
1694
- spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
1695
- }
1696
-
1697
- swiper.virtualSize = -spaceBetween; // reset margins
1698
-
1699
- if (rtl) slides.css({
1700
- marginLeft: '',
1701
- marginBottom: '',
1702
- marginTop: ''
1703
- });else slides.css({
1704
- marginRight: '',
1705
- marginBottom: '',
1706
- marginTop: ''
1707
- }); // reset cssMode offsets
1708
-
1709
- if (params.centeredSlides && params.cssMode) {
1710
- setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', '');
1711
- setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', '');
1712
- }
1713
-
1714
- const gridEnabled = params.grid && params.grid.rows > 1 && swiper.grid;
1715
-
1716
- if (gridEnabled) {
1717
- swiper.grid.initSlides(slidesLength);
1718
- } // Calc slides
1719
-
1720
-
1721
- let slideSize;
1722
- const shouldResetSlideSize = params.slidesPerView === 'auto' && params.breakpoints && Object.keys(params.breakpoints).filter(key => {
1723
- return typeof params.breakpoints[key].slidesPerView !== 'undefined';
1724
- }).length > 0;
1725
-
1726
- for (let i = 0; i < slidesLength; i += 1) {
1727
- slideSize = 0;
1728
- const slide = slides.eq(i);
1729
-
1730
- if (gridEnabled) {
1731
- swiper.grid.updateSlide(i, slide, slidesLength, getDirectionLabel);
1732
- }
1733
-
1734
- if (slide.css('display') === 'none') continue; // eslint-disable-line
1735
-
1736
- if (params.slidesPerView === 'auto') {
1737
- if (shouldResetSlideSize) {
1738
- slides[i].style[getDirectionLabel('width')] = ``;
1739
- }
1740
-
1741
- const slideStyles = getComputedStyle(slide[0]);
1742
- const currentTransform = slide[0].style.transform;
1743
- const currentWebKitTransform = slide[0].style.webkitTransform;
1744
-
1745
- if (currentTransform) {
1746
- slide[0].style.transform = 'none';
1747
- }
1748
-
1749
- if (currentWebKitTransform) {
1750
- slide[0].style.webkitTransform = 'none';
1751
- }
1752
-
1753
- if (params.roundLengths) {
1754
- slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
1755
- } else {
1756
- // eslint-disable-next-line
1757
- const width = getDirectionPropertyValue(slideStyles, 'width');
1758
- const paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
1759
- const paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
1760
- const marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
1761
- const marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
1762
- const boxSizing = slideStyles.getPropertyValue('box-sizing');
1763
-
1764
- if (boxSizing && boxSizing === 'border-box') {
1765
- slideSize = width + marginLeft + marginRight;
1766
- } else {
1767
- const {
1768
- clientWidth,
1769
- offsetWidth
1770
- } = slide[0];
1771
- slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
1772
- }
1773
- }
1774
-
1775
- if (currentTransform) {
1776
- slide[0].style.transform = currentTransform;
1777
- }
1778
-
1779
- if (currentWebKitTransform) {
1780
- slide[0].style.webkitTransform = currentWebKitTransform;
1781
- }
1782
-
1783
- if (params.roundLengths) slideSize = Math.floor(slideSize);
1784
- } else {
1785
- slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
1786
- if (params.roundLengths) slideSize = Math.floor(slideSize);
1787
-
1788
- if (slides[i]) {
1789
- slides[i].style[getDirectionLabel('width')] = `${slideSize}px`;
1790
- }
1791
- }
1792
-
1793
- if (slides[i]) {
1794
- slides[i].swiperSlideSize = slideSize;
1795
- }
1796
-
1797
- slidesSizesGrid.push(slideSize);
1798
-
1799
- if (params.centeredSlides) {
1800
- slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
1801
- if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
1802
- if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
1803
- if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
1804
- if (params.roundLengths) slidePosition = Math.floor(slidePosition);
1805
- if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
1806
- slidesGrid.push(slidePosition);
1807
- } else {
1808
- if (params.roundLengths) slidePosition = Math.floor(slidePosition);
1809
- if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
1810
- slidesGrid.push(slidePosition);
1811
- slidePosition = slidePosition + slideSize + spaceBetween;
1812
- }
1813
-
1814
- swiper.virtualSize += slideSize + spaceBetween;
1815
- prevSlideSize = slideSize;
1816
- index += 1;
1817
- }
1818
-
1819
- swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
1820
-
1821
- if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
1822
- $wrapperEl.css({
1823
- width: `${swiper.virtualSize + params.spaceBetween}px`
1824
- });
1825
- }
1826
-
1827
- if (params.setWrapperSize) {
1828
- $wrapperEl.css({
1829
- [getDirectionLabel('width')]: `${swiper.virtualSize + params.spaceBetween}px`
1830
- });
1831
- }
1832
-
1833
- if (gridEnabled) {
1834
- swiper.grid.updateWrapperSize(slideSize, snapGrid, getDirectionLabel);
1835
- } // Remove last grid elements depending on width
1836
-
1837
-
1838
- if (!params.centeredSlides) {
1839
- const newSlidesGrid = [];
1840
-
1841
- for (let i = 0; i < snapGrid.length; i += 1) {
1842
- let slidesGridItem = snapGrid[i];
1843
- if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
1844
-
1845
- if (snapGrid[i] <= swiper.virtualSize - swiperSize) {
1846
- newSlidesGrid.push(slidesGridItem);
1847
- }
1848
- }
1849
-
1850
- snapGrid = newSlidesGrid;
1851
-
1852
- if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
1853
- snapGrid.push(swiper.virtualSize - swiperSize);
1854
- }
1855
- }
1856
-
1857
- if (snapGrid.length === 0) snapGrid = [0];
1858
-
1859
- if (params.spaceBetween !== 0) {
1860
- const key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
1861
- slides.filter((_, slideIndex) => {
1862
- if (!params.cssMode) return true;
1863
-
1864
- if (slideIndex === slides.length - 1) {
1865
- return false;
1866
- }
1867
-
1868
- return true;
1869
- }).css({
1870
- [key]: `${spaceBetween}px`
1871
- });
1872
- }
1873
-
1874
- if (params.centeredSlides && params.centeredSlidesBounds) {
1875
- let allSlidesSize = 0;
1876
- slidesSizesGrid.forEach(slideSizeValue => {
1877
- allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
1878
- });
1879
- allSlidesSize -= params.spaceBetween;
1880
- const maxSnap = allSlidesSize - swiperSize;
1881
- snapGrid = snapGrid.map(snap => {
1882
- if (snap < 0) return -offsetBefore;
1883
- if (snap > maxSnap) return maxSnap + offsetAfter;
1884
- return snap;
1885
- });
1886
- }
1887
-
1888
- if (params.centerInsufficientSlides) {
1889
- let allSlidesSize = 0;
1890
- slidesSizesGrid.forEach(slideSizeValue => {
1891
- allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
1892
- });
1893
- allSlidesSize -= params.spaceBetween;
1894
-
1895
- if (allSlidesSize < swiperSize) {
1896
- const allSlidesOffset = (swiperSize - allSlidesSize) / 2;
1897
- snapGrid.forEach((snap, snapIndex) => {
1898
- snapGrid[snapIndex] = snap - allSlidesOffset;
1899
- });
1900
- slidesGrid.forEach((snap, snapIndex) => {
1901
- slidesGrid[snapIndex] = snap + allSlidesOffset;
1902
- });
1903
- }
1904
- }
1905
-
1906
- Object.assign(swiper, {
1907
- slides,
1908
- snapGrid,
1909
- slidesGrid,
1910
- slidesSizesGrid
1911
- });
1912
-
1913
- if (params.centeredSlides && params.cssMode && !params.centeredSlidesBounds) {
1914
- setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-before', `${-snapGrid[0]}px`);
1915
- setCSSProperty(swiper.wrapperEl, '--swiper-centered-offset-after', `${swiper.size / 2 - slidesSizesGrid[slidesSizesGrid.length - 1] / 2}px`);
1916
- const addToSnapGrid = -swiper.snapGrid[0];
1917
- const addToSlidesGrid = -swiper.slidesGrid[0];
1918
- swiper.snapGrid = swiper.snapGrid.map(v => v + addToSnapGrid);
1919
- swiper.slidesGrid = swiper.slidesGrid.map(v => v + addToSlidesGrid);
1920
- }
1921
-
1922
- if (slidesLength !== previousSlidesLength) {
1923
- swiper.emit('slidesLengthChange');
1924
- }
1925
-
1926
- if (snapGrid.length !== previousSnapGridLength) {
1927
- if (swiper.params.watchOverflow) swiper.checkOverflow();
1928
- swiper.emit('snapGridLengthChange');
1929
- }
1930
-
1931
- if (slidesGrid.length !== previousSlidesGridLength) {
1932
- swiper.emit('slidesGridLengthChange');
1933
- }
1934
-
1935
- if (params.watchSlidesProgress) {
1936
- swiper.updateSlidesOffset();
1937
- }
1938
-
1939
- if (!isVirtual && !params.cssMode && (params.effect === 'slide' || params.effect === 'fade')) {
1940
- const backFaceHiddenClass = `${params.containerModifierClass}backface-hidden`;
1941
- const hasClassBackfaceClassAdded = swiper.$el.hasClass(backFaceHiddenClass);
1942
-
1943
- if (slidesLength <= params.maxBackfaceHiddenSlides) {
1944
- if (!hasClassBackfaceClassAdded) swiper.$el.addClass(backFaceHiddenClass);
1945
- } else if (hasClassBackfaceClassAdded) {
1946
- swiper.$el.removeClass(backFaceHiddenClass);
1947
- }
1948
- }
1949
- }
1950
-
1951
- function updateAutoHeight(speed) {
1952
- const swiper = this;
1953
- const activeSlides = [];
1954
- const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
1955
- let newHeight = 0;
1956
- let i;
1957
-
1958
- if (typeof speed === 'number') {
1959
- swiper.setTransition(speed);
1960
- } else if (speed === true) {
1961
- swiper.setTransition(swiper.params.speed);
1962
- }
1963
-
1964
- const getSlideByIndex = index => {
1965
- if (isVirtual) {
1966
- return swiper.slides.filter(el => parseInt(el.getAttribute('data-swiper-slide-index'), 10) === index)[0];
1967
- }
1968
-
1969
- return swiper.slides.eq(index)[0];
1970
- }; // Find slides currently in view
1971
-
1972
-
1973
- if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
1974
- if (swiper.params.centeredSlides) {
1975
- (swiper.visibleSlides || $([])).each(slide => {
1976
- activeSlides.push(slide);
1977
- });
1978
- } else {
1979
- for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
1980
- const index = swiper.activeIndex + i;
1981
- if (index > swiper.slides.length && !isVirtual) break;
1982
- activeSlides.push(getSlideByIndex(index));
1983
- }
1984
- }
1985
- } else {
1986
- activeSlides.push(getSlideByIndex(swiper.activeIndex));
1987
- } // Find new height from highest slide in view
1988
-
1989
-
1990
- for (i = 0; i < activeSlides.length; i += 1) {
1991
- if (typeof activeSlides[i] !== 'undefined') {
1992
- const height = activeSlides[i].offsetHeight;
1993
- newHeight = height > newHeight ? height : newHeight;
1994
- }
1995
- } // Update Height
1996
-
1997
-
1998
- if (newHeight || newHeight === 0) swiper.$wrapperEl.css('height', `${newHeight}px`);
1999
- }
2000
-
2001
- function updateSlidesOffset() {
2002
- const swiper = this;
2003
- const slides = swiper.slides;
2004
-
2005
- for (let i = 0; i < slides.length; i += 1) {
2006
- slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop;
2007
- }
2008
- }
2009
-
2010
- function updateSlidesProgress(translate) {
2011
- if (translate === void 0) {
2012
- translate = this && this.translate || 0;
2013
- }
2014
-
2015
- const swiper = this;
2016
- const params = swiper.params;
2017
- const {
2018
- slides,
2019
- rtlTranslate: rtl,
2020
- snapGrid
2021
- } = swiper;
2022
- if (slides.length === 0) return;
2023
- if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
2024
- let offsetCenter = -translate;
2025
- if (rtl) offsetCenter = translate; // Visible Slides
2026
-
2027
- slides.removeClass(params.slideVisibleClass);
2028
- swiper.visibleSlidesIndexes = [];
2029
- swiper.visibleSlides = [];
2030
-
2031
- for (let i = 0; i < slides.length; i += 1) {
2032
- const slide = slides[i];
2033
- let slideOffset = slide.swiperSlideOffset;
2034
-
2035
- if (params.cssMode && params.centeredSlides) {
2036
- slideOffset -= slides[0].swiperSlideOffset;
2037
- }
2038
-
2039
- const slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
2040
- const originalSlideProgress = (offsetCenter - snapGrid[0] + (params.centeredSlides ? swiper.minTranslate() : 0) - slideOffset) / (slide.swiperSlideSize + params.spaceBetween);
2041
- const slideBefore = -(offsetCenter - slideOffset);
2042
- const slideAfter = slideBefore + swiper.slidesSizesGrid[i];
2043
- const isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
2044
-
2045
- if (isVisible) {
2046
- swiper.visibleSlides.push(slide);
2047
- swiper.visibleSlidesIndexes.push(i);
2048
- slides.eq(i).addClass(params.slideVisibleClass);
2049
- }
2050
-
2051
- slide.progress = rtl ? -slideProgress : slideProgress;
2052
- slide.originalProgress = rtl ? -originalSlideProgress : originalSlideProgress;
2053
- }
2054
-
2055
- swiper.visibleSlides = $(swiper.visibleSlides);
2056
- }
2057
-
2058
- function updateProgress(translate) {
2059
- const swiper = this;
2060
-
2061
- if (typeof translate === 'undefined') {
2062
- const multiplier = swiper.rtlTranslate ? -1 : 1; // eslint-disable-next-line
2063
-
2064
- translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
2065
- }
2066
-
2067
- const params = swiper.params;
2068
- const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2069
- let {
2070
- progress,
2071
- isBeginning,
2072
- isEnd
2073
- } = swiper;
2074
- const wasBeginning = isBeginning;
2075
- const wasEnd = isEnd;
2076
-
2077
- if (translatesDiff === 0) {
2078
- progress = 0;
2079
- isBeginning = true;
2080
- isEnd = true;
2081
- } else {
2082
- progress = (translate - swiper.minTranslate()) / translatesDiff;
2083
- isBeginning = progress <= 0;
2084
- isEnd = progress >= 1;
2085
- }
2086
-
2087
- Object.assign(swiper, {
2088
- progress,
2089
- isBeginning,
2090
- isEnd
2091
- });
2092
- if (params.watchSlidesProgress || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
2093
-
2094
- if (isBeginning && !wasBeginning) {
2095
- swiper.emit('reachBeginning toEdge');
2096
- }
2097
-
2098
- if (isEnd && !wasEnd) {
2099
- swiper.emit('reachEnd toEdge');
2100
- }
2101
-
2102
- if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
2103
- swiper.emit('fromEdge');
2104
- }
2105
-
2106
- swiper.emit('progress', progress);
2107
- }
2108
-
2109
- function updateSlidesClasses() {
2110
- const swiper = this;
2111
- const {
2112
- slides,
2113
- params,
2114
- $wrapperEl,
2115
- activeIndex,
2116
- realIndex
2117
- } = swiper;
2118
- const isVirtual = swiper.virtual && params.virtual.enabled;
2119
- slides.removeClass(`${params.slideActiveClass} ${params.slideNextClass} ${params.slidePrevClass} ${params.slideDuplicateActiveClass} ${params.slideDuplicateNextClass} ${params.slideDuplicatePrevClass}`);
2120
- let activeSlide;
2121
-
2122
- if (isVirtual) {
2123
- activeSlide = swiper.$wrapperEl.find(`.${params.slideClass}[data-swiper-slide-index="${activeIndex}"]`);
2124
- } else {
2125
- activeSlide = slides.eq(activeIndex);
2126
- } // Active classes
2127
-
2128
-
2129
- activeSlide.addClass(params.slideActiveClass);
2130
-
2131
- if (params.loop) {
2132
- // Duplicate to all looped slides
2133
- if (activeSlide.hasClass(params.slideDuplicateClass)) {
2134
- $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass);
2135
- } else {
2136
- $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${realIndex}"]`).addClass(params.slideDuplicateActiveClass);
2137
- }
2138
- } // Next Slide
2139
-
2140
-
2141
- let nextSlide = activeSlide.nextAll(`.${params.slideClass}`).eq(0).addClass(params.slideNextClass);
2142
-
2143
- if (params.loop && nextSlide.length === 0) {
2144
- nextSlide = slides.eq(0);
2145
- nextSlide.addClass(params.slideNextClass);
2146
- } // Prev Slide
2147
-
2148
-
2149
- let prevSlide = activeSlide.prevAll(`.${params.slideClass}`).eq(0).addClass(params.slidePrevClass);
2150
-
2151
- if (params.loop && prevSlide.length === 0) {
2152
- prevSlide = slides.eq(-1);
2153
- prevSlide.addClass(params.slidePrevClass);
2154
- }
2155
-
2156
- if (params.loop) {
2157
- // Duplicate to all looped slides
2158
- if (nextSlide.hasClass(params.slideDuplicateClass)) {
2159
- $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass);
2160
- } else {
2161
- $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${nextSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicateNextClass);
2162
- }
2163
-
2164
- if (prevSlide.hasClass(params.slideDuplicateClass)) {
2165
- $wrapperEl.children(`.${params.slideClass}:not(.${params.slideDuplicateClass})[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass);
2166
- } else {
2167
- $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass}[data-swiper-slide-index="${prevSlide.attr('data-swiper-slide-index')}"]`).addClass(params.slideDuplicatePrevClass);
2168
- }
2169
- }
2170
-
2171
- swiper.emitSlidesClasses();
2172
- }
2173
-
2174
- function updateActiveIndex(newActiveIndex) {
2175
- const swiper = this;
2176
- const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
2177
- const {
2178
- slidesGrid,
2179
- snapGrid,
2180
- params,
2181
- activeIndex: previousIndex,
2182
- realIndex: previousRealIndex,
2183
- snapIndex: previousSnapIndex
2184
- } = swiper;
2185
- let activeIndex = newActiveIndex;
2186
- let snapIndex;
2187
-
2188
- if (typeof activeIndex === 'undefined') {
2189
- for (let i = 0; i < slidesGrid.length; i += 1) {
2190
- if (typeof slidesGrid[i + 1] !== 'undefined') {
2191
- if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
2192
- activeIndex = i;
2193
- } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
2194
- activeIndex = i + 1;
2195
- }
2196
- } else if (translate >= slidesGrid[i]) {
2197
- activeIndex = i;
2198
- }
2199
- } // Normalize slideIndex
2200
-
2201
-
2202
- if (params.normalizeSlideIndex) {
2203
- if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
2204
- }
2205
- }
2206
-
2207
- if (snapGrid.indexOf(translate) >= 0) {
2208
- snapIndex = snapGrid.indexOf(translate);
2209
- } else {
2210
- const skip = Math.min(params.slidesPerGroupSkip, activeIndex);
2211
- snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
2212
- }
2213
-
2214
- if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
2215
-
2216
- if (activeIndex === previousIndex) {
2217
- if (snapIndex !== previousSnapIndex) {
2218
- swiper.snapIndex = snapIndex;
2219
- swiper.emit('snapIndexChange');
2220
- }
2221
-
2222
- return;
2223
- } // Get real index
2224
-
2225
-
2226
- const realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10);
2227
- Object.assign(swiper, {
2228
- snapIndex,
2229
- realIndex,
2230
- previousIndex,
2231
- activeIndex
2232
- });
2233
- swiper.emit('activeIndexChange');
2234
- swiper.emit('snapIndexChange');
2235
-
2236
- if (previousRealIndex !== realIndex) {
2237
- swiper.emit('realIndexChange');
2238
- }
2239
-
2240
- if (swiper.initialized || swiper.params.runCallbacksOnInit) {
2241
- swiper.emit('slideChange');
2242
- }
2243
- }
2244
-
2245
- function updateClickedSlide(e) {
2246
- const swiper = this;
2247
- const params = swiper.params;
2248
- const slide = $(e).closest(`.${params.slideClass}`)[0];
2249
- let slideFound = false;
2250
- let slideIndex;
2251
-
2252
- if (slide) {
2253
- for (let i = 0; i < swiper.slides.length; i += 1) {
2254
- if (swiper.slides[i] === slide) {
2255
- slideFound = true;
2256
- slideIndex = i;
2257
- break;
2258
- }
2259
- }
2260
- }
2261
-
2262
- if (slide && slideFound) {
2263
- swiper.clickedSlide = slide;
2264
-
2265
- if (swiper.virtual && swiper.params.virtual.enabled) {
2266
- swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10);
2267
- } else {
2268
- swiper.clickedIndex = slideIndex;
2269
- }
2270
- } else {
2271
- swiper.clickedSlide = undefined;
2272
- swiper.clickedIndex = undefined;
2273
- return;
2274
- }
2275
-
2276
- if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
2277
- swiper.slideToClickedSlide();
2278
- }
2279
- }
2280
-
2281
- const update = {
2282
- updateSize,
2283
- updateSlides,
2284
- updateAutoHeight,
2285
- updateSlidesOffset,
2286
- updateSlidesProgress,
2287
- updateProgress,
2288
- updateSlidesClasses,
2289
- updateActiveIndex,
2290
- updateClickedSlide
2291
- };
2292
-
2293
- function getSwiperTranslate(axis) {
2294
- if (axis === void 0) {
2295
- axis = this.isHorizontal() ? 'x' : 'y';
2296
- }
2297
-
2298
- const swiper = this;
2299
- const {
2300
- params,
2301
- rtlTranslate: rtl,
2302
- translate,
2303
- $wrapperEl
2304
- } = swiper;
2305
-
2306
- if (params.virtualTranslate) {
2307
- return rtl ? -translate : translate;
2308
- }
2309
-
2310
- if (params.cssMode) {
2311
- return translate;
2312
- }
2313
-
2314
- let currentTranslate = getTranslate($wrapperEl[0], axis);
2315
- if (rtl) currentTranslate = -currentTranslate;
2316
- return currentTranslate || 0;
2317
- }
2318
-
2319
- function setTranslate(translate, byController) {
2320
- const swiper = this;
2321
- const {
2322
- rtlTranslate: rtl,
2323
- params,
2324
- $wrapperEl,
2325
- wrapperEl,
2326
- progress
2327
- } = swiper;
2328
- let x = 0;
2329
- let y = 0;
2330
- const z = 0;
2331
-
2332
- if (swiper.isHorizontal()) {
2333
- x = rtl ? -translate : translate;
2334
- } else {
2335
- y = translate;
2336
- }
2337
-
2338
- if (params.roundLengths) {
2339
- x = Math.floor(x);
2340
- y = Math.floor(y);
2341
- }
2342
-
2343
- if (params.cssMode) {
2344
- wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
2345
- } else if (!params.virtualTranslate) {
2346
- $wrapperEl.transform(`translate3d(${x}px, ${y}px, ${z}px)`);
2347
- }
2348
-
2349
- swiper.previousTranslate = swiper.translate;
2350
- swiper.translate = swiper.isHorizontal() ? x : y; // Check if we need to update progress
2351
-
2352
- let newProgress;
2353
- const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
2354
-
2355
- if (translatesDiff === 0) {
2356
- newProgress = 0;
2357
- } else {
2358
- newProgress = (translate - swiper.minTranslate()) / translatesDiff;
2359
- }
2360
-
2361
- if (newProgress !== progress) {
2362
- swiper.updateProgress(translate);
2363
- }
2364
-
2365
- swiper.emit('setTranslate', swiper.translate, byController);
2366
- }
2367
-
2368
- function minTranslate() {
2369
- return -this.snapGrid[0];
2370
- }
2371
-
2372
- function maxTranslate() {
2373
- return -this.snapGrid[this.snapGrid.length - 1];
2374
- }
2375
-
2376
- function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
2377
- if (translate === void 0) {
2378
- translate = 0;
2379
- }
2380
-
2381
- if (speed === void 0) {
2382
- speed = this.params.speed;
2383
- }
2384
-
2385
- if (runCallbacks === void 0) {
2386
- runCallbacks = true;
2387
- }
2388
-
2389
- if (translateBounds === void 0) {
2390
- translateBounds = true;
2391
- }
2392
-
2393
- const swiper = this;
2394
- const {
2395
- params,
2396
- wrapperEl
2397
- } = swiper;
2398
-
2399
- if (swiper.animating && params.preventInteractionOnTransition) {
2400
- return false;
2401
- }
2402
-
2403
- const minTranslate = swiper.minTranslate();
2404
- const maxTranslate = swiper.maxTranslate();
2405
- let newTranslate;
2406
- if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate; // Update progress
2407
-
2408
- swiper.updateProgress(newTranslate);
2409
-
2410
- if (params.cssMode) {
2411
- const isH = swiper.isHorizontal();
2412
-
2413
- if (speed === 0) {
2414
- wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
2415
- } else {
2416
- if (!swiper.support.smoothScroll) {
2417
- animateCSSModeScroll({
2418
- swiper,
2419
- targetPosition: -newTranslate,
2420
- side: isH ? 'left' : 'top'
2421
- });
2422
- return true;
2423
- }
2424
-
2425
- wrapperEl.scrollTo({
2426
- [isH ? 'left' : 'top']: -newTranslate,
2427
- behavior: 'smooth'
2428
- });
2429
- }
2430
-
2431
- return true;
2432
- }
2433
-
2434
- if (speed === 0) {
2435
- swiper.setTransition(0);
2436
- swiper.setTranslate(newTranslate);
2437
-
2438
- if (runCallbacks) {
2439
- swiper.emit('beforeTransitionStart', speed, internal);
2440
- swiper.emit('transitionEnd');
2441
- }
2442
- } else {
2443
- swiper.setTransition(speed);
2444
- swiper.setTranslate(newTranslate);
2445
-
2446
- if (runCallbacks) {
2447
- swiper.emit('beforeTransitionStart', speed, internal);
2448
- swiper.emit('transitionStart');
2449
- }
2450
-
2451
- if (!swiper.animating) {
2452
- swiper.animating = true;
2453
-
2454
- if (!swiper.onTranslateToWrapperTransitionEnd) {
2455
- swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
2456
- if (!swiper || swiper.destroyed) return;
2457
- if (e.target !== this) return;
2458
- swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
2459
- swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
2460
- swiper.onTranslateToWrapperTransitionEnd = null;
2461
- delete swiper.onTranslateToWrapperTransitionEnd;
2462
-
2463
- if (runCallbacks) {
2464
- swiper.emit('transitionEnd');
2465
- }
2466
- };
2467
- }
2468
-
2469
- swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
2470
- swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
2471
- }
2472
- }
2473
-
2474
- return true;
2475
- }
2476
-
2477
- const translate = {
2478
- getTranslate: getSwiperTranslate,
2479
- setTranslate,
2480
- minTranslate,
2481
- maxTranslate,
2482
- translateTo
2483
- };
2484
-
2485
- function setTransition(duration, byController) {
2486
- const swiper = this;
2487
-
2488
- if (!swiper.params.cssMode) {
2489
- swiper.$wrapperEl.transition(duration);
2490
- }
2491
-
2492
- swiper.emit('setTransition', duration, byController);
2493
- }
2494
-
2495
- function transitionEmit(_ref) {
2496
- let {
2497
- swiper,
2498
- runCallbacks,
2499
- direction,
2500
- step
2501
- } = _ref;
2502
- const {
2503
- activeIndex,
2504
- previousIndex
2505
- } = swiper;
2506
- let dir = direction;
2507
-
2508
- if (!dir) {
2509
- if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
2510
- }
2511
-
2512
- swiper.emit(`transition${step}`);
2513
-
2514
- if (runCallbacks && activeIndex !== previousIndex) {
2515
- if (dir === 'reset') {
2516
- swiper.emit(`slideResetTransition${step}`);
2517
- return;
2518
- }
2519
-
2520
- swiper.emit(`slideChangeTransition${step}`);
2521
-
2522
- if (dir === 'next') {
2523
- swiper.emit(`slideNextTransition${step}`);
2524
- } else {
2525
- swiper.emit(`slidePrevTransition${step}`);
2526
- }
2527
- }
2528
- }
2529
-
2530
- function transitionStart(runCallbacks, direction) {
2531
- if (runCallbacks === void 0) {
2532
- runCallbacks = true;
2533
- }
2534
-
2535
- const swiper = this;
2536
- const {
2537
- params
2538
- } = swiper;
2539
- if (params.cssMode) return;
2540
-
2541
- if (params.autoHeight) {
2542
- swiper.updateAutoHeight();
2543
- }
2544
-
2545
- transitionEmit({
2546
- swiper,
2547
- runCallbacks,
2548
- direction,
2549
- step: 'Start'
2550
- });
2551
- }
2552
-
2553
- function transitionEnd(runCallbacks, direction) {
2554
- if (runCallbacks === void 0) {
2555
- runCallbacks = true;
2556
- }
2557
-
2558
- const swiper = this;
2559
- const {
2560
- params
2561
- } = swiper;
2562
- swiper.animating = false;
2563
- if (params.cssMode) return;
2564
- swiper.setTransition(0);
2565
- transitionEmit({
2566
- swiper,
2567
- runCallbacks,
2568
- direction,
2569
- step: 'End'
2570
- });
2571
- }
2572
-
2573
- const transition = {
2574
- setTransition,
2575
- transitionStart,
2576
- transitionEnd
2577
- };
2578
-
2579
- function slideTo(index, speed, runCallbacks, internal, initial) {
2580
- if (index === void 0) {
2581
- index = 0;
2582
- }
2583
-
2584
- if (speed === void 0) {
2585
- speed = this.params.speed;
2586
- }
2587
-
2588
- if (runCallbacks === void 0) {
2589
- runCallbacks = true;
2590
- }
2591
-
2592
- if (typeof index !== 'number' && typeof index !== 'string') {
2593
- throw new Error(`The 'index' argument cannot have type other than 'number' or 'string'. [${typeof index}] given.`);
2594
- }
2595
-
2596
- if (typeof index === 'string') {
2597
- /**
2598
- * The `index` argument converted from `string` to `number`.
2599
- * @type {number}
2600
- */
2601
- const indexAsNumber = parseInt(index, 10);
2602
- /**
2603
- * Determines whether the `index` argument is a valid `number`
2604
- * after being converted from the `string` type.
2605
- * @type {boolean}
2606
- */
2607
-
2608
- const isValidNumber = isFinite(indexAsNumber);
2609
-
2610
- if (!isValidNumber) {
2611
- throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
2612
- } // Knowing that the converted `index` is a valid number,
2613
- // we can update the original argument's value.
2614
-
2615
-
2616
- index = indexAsNumber;
2617
- }
2618
-
2619
- const swiper = this;
2620
- let slideIndex = index;
2621
- if (slideIndex < 0) slideIndex = 0;
2622
- const {
2623
- params,
2624
- snapGrid,
2625
- slidesGrid,
2626
- previousIndex,
2627
- activeIndex,
2628
- rtlTranslate: rtl,
2629
- wrapperEl,
2630
- enabled
2631
- } = swiper;
2632
-
2633
- if (swiper.animating && params.preventInteractionOnTransition || !enabled && !internal && !initial) {
2634
- return false;
2635
- }
2636
-
2637
- const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
2638
- let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
2639
- if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
2640
-
2641
- if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) {
2642
- swiper.emit('beforeSlideChangeStart');
2643
- }
2644
-
2645
- const translate = -snapGrid[snapIndex]; // Update progress
2646
-
2647
- swiper.updateProgress(translate); // Normalize slideIndex
2648
-
2649
- if (params.normalizeSlideIndex) {
2650
- for (let i = 0; i < slidesGrid.length; i += 1) {
2651
- const normalizedTranslate = -Math.floor(translate * 100);
2652
- const normalizedGrid = Math.floor(slidesGrid[i] * 100);
2653
- const normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
2654
-
2655
- if (typeof slidesGrid[i + 1] !== 'undefined') {
2656
- if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGrid) / 2) {
2657
- slideIndex = i;
2658
- } else if (normalizedTranslate >= normalizedGrid && normalizedTranslate < normalizedGridNext) {
2659
- slideIndex = i + 1;
2660
- }
2661
- } else if (normalizedTranslate >= normalizedGrid) {
2662
- slideIndex = i;
2663
- }
2664
- }
2665
- } // Directions locks
2666
-
2667
-
2668
- if (swiper.initialized && slideIndex !== activeIndex) {
2669
- if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
2670
- return false;
2671
- }
2672
-
2673
- if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
2674
- if ((activeIndex || 0) !== slideIndex) return false;
2675
- }
2676
- }
2677
-
2678
- let direction;
2679
- if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset'; // Update Index
2680
-
2681
- if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
2682
- swiper.updateActiveIndex(slideIndex); // Update Height
2683
-
2684
- if (params.autoHeight) {
2685
- swiper.updateAutoHeight();
2686
- }
2687
-
2688
- swiper.updateSlidesClasses();
2689
-
2690
- if (params.effect !== 'slide') {
2691
- swiper.setTranslate(translate);
2692
- }
2693
-
2694
- if (direction !== 'reset') {
2695
- swiper.transitionStart(runCallbacks, direction);
2696
- swiper.transitionEnd(runCallbacks, direction);
2697
- }
2698
-
2699
- return false;
2700
- }
2701
-
2702
- if (params.cssMode) {
2703
- const isH = swiper.isHorizontal();
2704
- const t = rtl ? translate : -translate;
2705
-
2706
- if (speed === 0) {
2707
- const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
2708
-
2709
- if (isVirtual) {
2710
- swiper.wrapperEl.style.scrollSnapType = 'none';
2711
- swiper._immediateVirtual = true;
2712
- }
2713
-
2714
- wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
2715
-
2716
- if (isVirtual) {
2717
- requestAnimationFrame(() => {
2718
- swiper.wrapperEl.style.scrollSnapType = '';
2719
- swiper._swiperImmediateVirtual = false;
2720
- });
2721
- }
2722
- } else {
2723
- if (!swiper.support.smoothScroll) {
2724
- animateCSSModeScroll({
2725
- swiper,
2726
- targetPosition: t,
2727
- side: isH ? 'left' : 'top'
2728
- });
2729
- return true;
2730
- }
2731
-
2732
- wrapperEl.scrollTo({
2733
- [isH ? 'left' : 'top']: t,
2734
- behavior: 'smooth'
2735
- });
2736
- }
2737
-
2738
- return true;
2739
- }
2740
-
2741
- swiper.setTransition(speed);
2742
- swiper.setTranslate(translate);
2743
- swiper.updateActiveIndex(slideIndex);
2744
- swiper.updateSlidesClasses();
2745
- swiper.emit('beforeTransitionStart', speed, internal);
2746
- swiper.transitionStart(runCallbacks, direction);
2747
-
2748
- if (speed === 0) {
2749
- swiper.transitionEnd(runCallbacks, direction);
2750
- } else if (!swiper.animating) {
2751
- swiper.animating = true;
2752
-
2753
- if (!swiper.onSlideToWrapperTransitionEnd) {
2754
- swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
2755
- if (!swiper || swiper.destroyed) return;
2756
- if (e.target !== this) return;
2757
- swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
2758
- swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
2759
- swiper.onSlideToWrapperTransitionEnd = null;
2760
- delete swiper.onSlideToWrapperTransitionEnd;
2761
- swiper.transitionEnd(runCallbacks, direction);
2762
- };
2763
- }
2764
-
2765
- swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
2766
- swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
2767
- }
2768
-
2769
- return true;
2770
- }
2771
-
2772
- function slideToLoop(index, speed, runCallbacks, internal) {
2773
- if (index === void 0) {
2774
- index = 0;
2775
- }
2776
-
2777
- if (speed === void 0) {
2778
- speed = this.params.speed;
2779
- }
2780
-
2781
- if (runCallbacks === void 0) {
2782
- runCallbacks = true;
2783
- }
2784
-
2785
- if (typeof index === 'string') {
2786
- /**
2787
- * The `index` argument converted from `string` to `number`.
2788
- * @type {number}
2789
- */
2790
- const indexAsNumber = parseInt(index, 10);
2791
- /**
2792
- * Determines whether the `index` argument is a valid `number`
2793
- * after being converted from the `string` type.
2794
- * @type {boolean}
2795
- */
2796
-
2797
- const isValidNumber = isFinite(indexAsNumber);
2798
-
2799
- if (!isValidNumber) {
2800
- throw new Error(`The passed-in 'index' (string) couldn't be converted to 'number'. [${index}] given.`);
2801
- } // Knowing that the converted `index` is a valid number,
2802
- // we can update the original argument's value.
2803
-
2804
-
2805
- index = indexAsNumber;
2806
- }
2807
-
2808
- const swiper = this;
2809
- let newIndex = index;
2810
-
2811
- if (swiper.params.loop) {
2812
- newIndex += swiper.loopedSlides;
2813
- }
2814
-
2815
- return swiper.slideTo(newIndex, speed, runCallbacks, internal);
2816
- }
2817
-
2818
- /* eslint no-unused-vars: "off" */
2819
- function slideNext(speed, runCallbacks, internal) {
2820
- if (speed === void 0) {
2821
- speed = this.params.speed;
2822
- }
2823
-
2824
- if (runCallbacks === void 0) {
2825
- runCallbacks = true;
2826
- }
2827
-
2828
- const swiper = this;
2829
- const {
2830
- animating,
2831
- enabled,
2832
- params
2833
- } = swiper;
2834
- if (!enabled) return swiper;
2835
- let perGroup = params.slidesPerGroup;
2836
-
2837
- if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
2838
- perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1);
2839
- }
2840
-
2841
- const increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : perGroup;
2842
-
2843
- if (params.loop) {
2844
- if (animating && params.loopPreventsSlide) return false;
2845
- swiper.loopFix(); // eslint-disable-next-line
2846
-
2847
- swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
2848
- }
2849
-
2850
- if (params.rewind && swiper.isEnd) {
2851
- return swiper.slideTo(0, speed, runCallbacks, internal);
2852
- }
2853
-
2854
- return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
2855
- }
2856
-
2857
- /* eslint no-unused-vars: "off" */
2858
- function slidePrev(speed, runCallbacks, internal) {
2859
- if (speed === void 0) {
2860
- speed = this.params.speed;
2861
- }
2862
-
2863
- if (runCallbacks === void 0) {
2864
- runCallbacks = true;
2865
- }
2866
-
2867
- const swiper = this;
2868
- const {
2869
- params,
2870
- animating,
2871
- snapGrid,
2872
- slidesGrid,
2873
- rtlTranslate,
2874
- enabled
2875
- } = swiper;
2876
- if (!enabled) return swiper;
2877
-
2878
- if (params.loop) {
2879
- if (animating && params.loopPreventsSlide) return false;
2880
- swiper.loopFix(); // eslint-disable-next-line
2881
-
2882
- swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
2883
- }
2884
-
2885
- const translate = rtlTranslate ? swiper.translate : -swiper.translate;
2886
-
2887
- function normalize(val) {
2888
- if (val < 0) return -Math.floor(Math.abs(val));
2889
- return Math.floor(val);
2890
- }
2891
-
2892
- const normalizedTranslate = normalize(translate);
2893
- const normalizedSnapGrid = snapGrid.map(val => normalize(val));
2894
- let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
2895
-
2896
- if (typeof prevSnap === 'undefined' && params.cssMode) {
2897
- let prevSnapIndex;
2898
- snapGrid.forEach((snap, snapIndex) => {
2899
- if (normalizedTranslate >= snap) {
2900
- // prevSnap = snap;
2901
- prevSnapIndex = snapIndex;
2902
- }
2903
- });
2904
-
2905
- if (typeof prevSnapIndex !== 'undefined') {
2906
- prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
2907
- }
2908
- }
2909
-
2910
- let prevIndex = 0;
2911
-
2912
- if (typeof prevSnap !== 'undefined') {
2913
- prevIndex = slidesGrid.indexOf(prevSnap);
2914
- if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
2915
-
2916
- if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) {
2917
- prevIndex = prevIndex - swiper.slidesPerViewDynamic('previous', true) + 1;
2918
- prevIndex = Math.max(prevIndex, 0);
2919
- }
2920
- }
2921
-
2922
- if (params.rewind && swiper.isBeginning) {
2923
- const lastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
2924
- return swiper.slideTo(lastIndex, speed, runCallbacks, internal);
2925
- }
2926
-
2927
- return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
2928
- }
2929
-
2930
- /* eslint no-unused-vars: "off" */
2931
- function slideReset(speed, runCallbacks, internal) {
2932
- if (speed === void 0) {
2933
- speed = this.params.speed;
2934
- }
2935
-
2936
- if (runCallbacks === void 0) {
2937
- runCallbacks = true;
2938
- }
2939
-
2940
- const swiper = this;
2941
- return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
2942
- }
2943
-
2944
- /* eslint no-unused-vars: "off" */
2945
- function slideToClosest(speed, runCallbacks, internal, threshold) {
2946
- if (speed === void 0) {
2947
- speed = this.params.speed;
2948
- }
2949
-
2950
- if (runCallbacks === void 0) {
2951
- runCallbacks = true;
2952
- }
2953
-
2954
- if (threshold === void 0) {
2955
- threshold = 0.5;
2956
- }
2957
-
2958
- const swiper = this;
2959
- let index = swiper.activeIndex;
2960
- const skip = Math.min(swiper.params.slidesPerGroupSkip, index);
2961
- const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
2962
- const translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
2963
-
2964
- if (translate >= swiper.snapGrid[snapIndex]) {
2965
- // The current translate is on or after the current snap index, so the choice
2966
- // is between the current index and the one after it.
2967
- const currentSnap = swiper.snapGrid[snapIndex];
2968
- const nextSnap = swiper.snapGrid[snapIndex + 1];
2969
-
2970
- if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
2971
- index += swiper.params.slidesPerGroup;
2972
- }
2973
- } else {
2974
- // The current translate is before the current snap index, so the choice
2975
- // is between the current index and the one before it.
2976
- const prevSnap = swiper.snapGrid[snapIndex - 1];
2977
- const currentSnap = swiper.snapGrid[snapIndex];
2978
-
2979
- if (translate - prevSnap <= (currentSnap - prevSnap) * threshold) {
2980
- index -= swiper.params.slidesPerGroup;
2981
- }
2982
- }
2983
-
2984
- index = Math.max(index, 0);
2985
- index = Math.min(index, swiper.slidesGrid.length - 1);
2986
- return swiper.slideTo(index, speed, runCallbacks, internal);
2987
- }
2988
-
2989
- function slideToClickedSlide() {
2990
- const swiper = this;
2991
- const {
2992
- params,
2993
- $wrapperEl
2994
- } = swiper;
2995
- const slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
2996
- let slideToIndex = swiper.clickedIndex;
2997
- let realIndex;
2998
-
2999
- if (params.loop) {
3000
- if (swiper.animating) return;
3001
- realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
3002
-
3003
- if (params.centeredSlides) {
3004
- if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
3005
- swiper.loopFix();
3006
- slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index();
3007
- nextTick(() => {
3008
- swiper.slideTo(slideToIndex);
3009
- });
3010
- } else {
3011
- swiper.slideTo(slideToIndex);
3012
- }
3013
- } else if (slideToIndex > swiper.slides.length - slidesPerView) {
3014
- swiper.loopFix();
3015
- slideToIndex = $wrapperEl.children(`.${params.slideClass}[data-swiper-slide-index="${realIndex}"]:not(.${params.slideDuplicateClass})`).eq(0).index();
3016
- nextTick(() => {
3017
- swiper.slideTo(slideToIndex);
3018
- });
3019
- } else {
3020
- swiper.slideTo(slideToIndex);
3021
- }
3022
- } else {
3023
- swiper.slideTo(slideToIndex);
3024
- }
3025
- }
3026
-
3027
- const slide = {
3028
- slideTo,
3029
- slideToLoop,
3030
- slideNext,
3031
- slidePrev,
3032
- slideReset,
3033
- slideToClosest,
3034
- slideToClickedSlide
3035
- };
3036
-
3037
- function loopCreate() {
3038
- const swiper = this;
3039
- const document = getDocument();
3040
- const {
3041
- params,
3042
- $wrapperEl
3043
- } = swiper; // Remove duplicated slides
3044
-
3045
- const $selector = $wrapperEl.children().length > 0 ? $($wrapperEl.children()[0].parentNode) : $wrapperEl;
3046
- $selector.children(`.${params.slideClass}.${params.slideDuplicateClass}`).remove();
3047
- let slides = $selector.children(`.${params.slideClass}`);
3048
-
3049
- if (params.loopFillGroupWithBlank) {
3050
- const blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup;
3051
-
3052
- if (blankSlidesNum !== params.slidesPerGroup) {
3053
- for (let i = 0; i < blankSlidesNum; i += 1) {
3054
- const blankNode = $(document.createElement('div')).addClass(`${params.slideClass} ${params.slideBlankClass}`);
3055
- $selector.append(blankNode);
3056
- }
3057
-
3058
- slides = $selector.children(`.${params.slideClass}`);
3059
- }
3060
- }
3061
-
3062
- if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length;
3063
- swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10));
3064
- swiper.loopedSlides += params.loopAdditionalSlides;
3065
-
3066
- if (swiper.loopedSlides > slides.length && swiper.params.loopedSlidesLimit) {
3067
- swiper.loopedSlides = slides.length;
3068
- }
3069
-
3070
- const prependSlides = [];
3071
- const appendSlides = [];
3072
- slides.each((el, index) => {
3073
- $(el).attr('data-swiper-slide-index', index);
3074
- });
3075
-
3076
- for (let i = 0; i < swiper.loopedSlides; i += 1) {
3077
- const index = i - Math.floor(i / slides.length) * slides.length;
3078
- appendSlides.push(slides.eq(index)[0]);
3079
- prependSlides.unshift(slides.eq(slides.length - index - 1)[0]);
3080
- }
3081
-
3082
- for (let i = 0; i < appendSlides.length; i += 1) {
3083
- $selector.append($(appendSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass));
3084
- }
3085
-
3086
- for (let i = prependSlides.length - 1; i >= 0; i -= 1) {
3087
- $selector.prepend($(prependSlides[i].cloneNode(true)).addClass(params.slideDuplicateClass));
3088
- }
3089
- }
3090
-
3091
- function loopFix() {
3092
- const swiper = this;
3093
- swiper.emit('beforeLoopFix');
3094
- const {
3095
- activeIndex,
3096
- slides,
3097
- loopedSlides,
3098
- allowSlidePrev,
3099
- allowSlideNext,
3100
- snapGrid,
3101
- rtlTranslate: rtl
3102
- } = swiper;
3103
- let newIndex;
3104
- swiper.allowSlidePrev = true;
3105
- swiper.allowSlideNext = true;
3106
- const snapTranslate = -snapGrid[activeIndex];
3107
- const diff = snapTranslate - swiper.getTranslate(); // Fix For Negative Oversliding
3108
-
3109
- if (activeIndex < loopedSlides) {
3110
- newIndex = slides.length - loopedSlides * 3 + activeIndex;
3111
- newIndex += loopedSlides;
3112
- const slideChanged = swiper.slideTo(newIndex, 0, false, true);
3113
-
3114
- if (slideChanged && diff !== 0) {
3115
- swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
3116
- }
3117
- } else if (activeIndex >= slides.length - loopedSlides) {
3118
- // Fix For Positive Oversliding
3119
- newIndex = -slides.length + activeIndex + loopedSlides;
3120
- newIndex += loopedSlides;
3121
- const slideChanged = swiper.slideTo(newIndex, 0, false, true);
3122
-
3123
- if (slideChanged && diff !== 0) {
3124
- swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
3125
- }
3126
- }
3127
-
3128
- swiper.allowSlidePrev = allowSlidePrev;
3129
- swiper.allowSlideNext = allowSlideNext;
3130
- swiper.emit('loopFix');
3131
- }
3132
-
3133
- function loopDestroy() {
3134
- const swiper = this;
3135
- const {
3136
- $wrapperEl,
3137
- params,
3138
- slides
3139
- } = swiper;
3140
- $wrapperEl.children(`.${params.slideClass}.${params.slideDuplicateClass},.${params.slideClass}.${params.slideBlankClass}`).remove();
3141
- slides.removeAttr('data-swiper-slide-index');
3142
- }
3143
-
3144
- const loop = {
3145
- loopCreate,
3146
- loopFix,
3147
- loopDestroy
3148
- };
3149
-
3150
- function setGrabCursor(moving) {
3151
- const swiper = this;
3152
- if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
3153
- const el = swiper.params.touchEventsTarget === 'container' ? swiper.el : swiper.wrapperEl;
3154
- el.style.cursor = 'move';
3155
- el.style.cursor = moving ? 'grabbing' : 'grab';
3156
- }
3157
-
3158
- function unsetGrabCursor() {
3159
- const swiper = this;
3160
-
3161
- if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
3162
- return;
3163
- }
3164
-
3165
- swiper[swiper.params.touchEventsTarget === 'container' ? 'el' : 'wrapperEl'].style.cursor = '';
3166
- }
3167
-
3168
- const grabCursor = {
3169
- setGrabCursor,
3170
- unsetGrabCursor
3171
- };
3172
-
3173
- function closestElement(selector, base) {
3174
- if (base === void 0) {
3175
- base = this;
3176
- }
3177
-
3178
- function __closestFrom(el) {
3179
- if (!el || el === getDocument() || el === getWindow()) return null;
3180
- if (el.assignedSlot) el = el.assignedSlot;
3181
- const found = el.closest(selector);
3182
-
3183
- if (!found && !el.getRootNode) {
3184
- return null;
3185
- }
3186
-
3187
- return found || __closestFrom(el.getRootNode().host);
3188
- }
3189
-
3190
- return __closestFrom(base);
3191
- }
3192
-
3193
- function onTouchStart(event) {
3194
- const swiper = this;
3195
- const document = getDocument();
3196
- const window = getWindow();
3197
- const data = swiper.touchEventsData;
3198
- const {
3199
- params,
3200
- touches,
3201
- enabled
3202
- } = swiper;
3203
- if (!enabled) return;
3204
-
3205
- if (swiper.animating && params.preventInteractionOnTransition) {
3206
- return;
3207
- }
3208
-
3209
- if (!swiper.animating && params.cssMode && params.loop) {
3210
- swiper.loopFix();
3211
- }
3212
-
3213
- let e = event;
3214
- if (e.originalEvent) e = e.originalEvent;
3215
- let $targetEl = $(e.target);
3216
-
3217
- if (params.touchEventsTarget === 'wrapper') {
3218
- if (!$targetEl.closest(swiper.wrapperEl).length) return;
3219
- }
3220
-
3221
- data.isTouchEvent = e.type === 'touchstart';
3222
- if (!data.isTouchEvent && 'which' in e && e.which === 3) return;
3223
- if (!data.isTouchEvent && 'button' in e && e.button > 0) return;
3224
- if (data.isTouched && data.isMoved) return; // change target el for shadow root component
3225
-
3226
- const swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
3227
-
3228
- if (swipingClassHasValue && e.target && e.target.shadowRoot && event.path && event.path[0]) {
3229
- $targetEl = $(event.path[0]);
3230
- }
3231
-
3232
- const noSwipingSelector = params.noSwipingSelector ? params.noSwipingSelector : `.${params.noSwipingClass}`;
3233
- const isTargetShadow = !!(e.target && e.target.shadowRoot); // use closestElement for shadow root element to get the actual closest for nested shadow root element
3234
-
3235
- if (params.noSwiping && (isTargetShadow ? closestElement(noSwipingSelector, $targetEl[0]) : $targetEl.closest(noSwipingSelector)[0])) {
3236
- swiper.allowClick = true;
3237
- return;
3238
- }
3239
-
3240
- if (params.swipeHandler) {
3241
- if (!$targetEl.closest(params.swipeHandler)[0]) return;
3242
- }
3243
-
3244
- touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
3245
- touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
3246
- const startX = touches.currentX;
3247
- const startY = touches.currentY; // Do NOT start if iOS edge swipe is detected. Otherwise iOS app cannot swipe-to-go-back anymore
3248
-
3249
- const edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
3250
- const edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
3251
-
3252
- if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
3253
- if (edgeSwipeDetection === 'prevent') {
3254
- event.preventDefault();
3255
- } else {
3256
- return;
3257
- }
3258
- }
3259
-
3260
- Object.assign(data, {
3261
- isTouched: true,
3262
- isMoved: false,
3263
- allowTouchCallbacks: true,
3264
- isScrolling: undefined,
3265
- startMoving: undefined
3266
- });
3267
- touches.startX = startX;
3268
- touches.startY = startY;
3269
- data.touchStartTime = now();
3270
- swiper.allowClick = true;
3271
- swiper.updateSize();
3272
- swiper.swipeDirection = undefined;
3273
- if (params.threshold > 0) data.allowThresholdMove = false;
3274
-
3275
- if (e.type !== 'touchstart') {
3276
- let preventDefault = true;
3277
-
3278
- if ($targetEl.is(data.focusableElements)) {
3279
- preventDefault = false;
3280
-
3281
- if ($targetEl[0].nodeName === 'SELECT') {
3282
- data.isTouched = false;
3283
- }
3284
- }
3285
-
3286
- if (document.activeElement && $(document.activeElement).is(data.focusableElements) && document.activeElement !== $targetEl[0]) {
3287
- document.activeElement.blur();
3288
- }
3289
-
3290
- const shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
3291
-
3292
- if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) {
3293
- e.preventDefault();
3294
- }
3295
- }
3296
-
3297
- if (swiper.params.freeMode && swiper.params.freeMode.enabled && swiper.freeMode && swiper.animating && !params.cssMode) {
3298
- swiper.freeMode.onTouchStart();
3299
- }
3300
-
3301
- swiper.emit('touchStart', e);
3302
- }
3303
-
3304
- function onTouchMove(event) {
3305
- const document = getDocument();
3306
- const swiper = this;
3307
- const data = swiper.touchEventsData;
3308
- const {
3309
- params,
3310
- touches,
3311
- rtlTranslate: rtl,
3312
- enabled
3313
- } = swiper;
3314
- if (!enabled) return;
3315
- let e = event;
3316
- if (e.originalEvent) e = e.originalEvent;
3317
-
3318
- if (!data.isTouched) {
3319
- if (data.startMoving && data.isScrolling) {
3320
- swiper.emit('touchMoveOpposite', e);
3321
- }
3322
-
3323
- return;
3324
- }
3325
-
3326
- if (data.isTouchEvent && e.type !== 'touchmove') return;
3327
- const targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]);
3328
- const pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
3329
- const pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
3330
-
3331
- if (e.preventedByNestedSwiper) {
3332
- touches.startX = pageX;
3333
- touches.startY = pageY;
3334
- return;
3335
- }
3336
-
3337
- if (!swiper.allowTouchMove) {
3338
- if (!$(e.target).is(data.focusableElements)) {
3339
- swiper.allowClick = false;
3340
- }
3341
-
3342
- if (data.isTouched) {
3343
- Object.assign(touches, {
3344
- startX: pageX,
3345
- startY: pageY,
3346
- currentX: pageX,
3347
- currentY: pageY
3348
- });
3349
- data.touchStartTime = now();
3350
- }
3351
-
3352
- return;
3353
- }
3354
-
3355
- if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
3356
- if (swiper.isVertical()) {
3357
- // Vertical
3358
- if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
3359
- data.isTouched = false;
3360
- data.isMoved = false;
3361
- return;
3362
- }
3363
- } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
3364
- return;
3365
- }
3366
- }
3367
-
3368
- if (data.isTouchEvent && document.activeElement) {
3369
- if (e.target === document.activeElement && $(e.target).is(data.focusableElements)) {
3370
- data.isMoved = true;
3371
- swiper.allowClick = false;
3372
- return;
3373
- }
3374
- }
3375
-
3376
- if (data.allowTouchCallbacks) {
3377
- swiper.emit('touchMove', e);
3378
- }
3379
-
3380
- if (e.targetTouches && e.targetTouches.length > 1) return;
3381
- touches.currentX = pageX;
3382
- touches.currentY = pageY;
3383
- const diffX = touches.currentX - touches.startX;
3384
- const diffY = touches.currentY - touches.startY;
3385
- if (swiper.params.threshold && Math.sqrt(diffX ** 2 + diffY ** 2) < swiper.params.threshold) return;
3386
-
3387
- if (typeof data.isScrolling === 'undefined') {
3388
- let touchAngle;
3389
-
3390
- if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
3391
- data.isScrolling = false;
3392
- } else {
3393
- // eslint-disable-next-line
3394
- if (diffX * diffX + diffY * diffY >= 25) {
3395
- touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
3396
- data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
3397
- }
3398
- }
3399
- }
3400
-
3401
- if (data.isScrolling) {
3402
- swiper.emit('touchMoveOpposite', e);
3403
- }
3404
-
3405
- if (typeof data.startMoving === 'undefined') {
3406
- if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
3407
- data.startMoving = true;
3408
- }
3409
- }
3410
-
3411
- if (data.isScrolling) {
3412
- data.isTouched = false;
3413
- return;
3414
- }
3415
-
3416
- if (!data.startMoving) {
3417
- return;
3418
- }
3419
-
3420
- swiper.allowClick = false;
3421
-
3422
- if (!params.cssMode && e.cancelable) {
3423
- e.preventDefault();
3424
- }
3425
-
3426
- if (params.touchMoveStopPropagation && !params.nested) {
3427
- e.stopPropagation();
3428
- }
3429
-
3430
- if (!data.isMoved) {
3431
- if (params.loop && !params.cssMode) {
3432
- swiper.loopFix();
3433
- }
3434
-
3435
- data.startTranslate = swiper.getTranslate();
3436
- swiper.setTransition(0);
3437
-
3438
- if (swiper.animating) {
3439
- swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend');
3440
- }
3441
-
3442
- data.allowMomentumBounce = false; // Grab Cursor
3443
-
3444
- if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
3445
- swiper.setGrabCursor(true);
3446
- }
3447
-
3448
- swiper.emit('sliderFirstMove', e);
3449
- }
3450
-
3451
- swiper.emit('sliderMove', e);
3452
- data.isMoved = true;
3453
- let diff = swiper.isHorizontal() ? diffX : diffY;
3454
- touches.diff = diff;
3455
- diff *= params.touchRatio;
3456
- if (rtl) diff = -diff;
3457
- swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
3458
- data.currentTranslate = diff + data.startTranslate;
3459
- let disableParentSwiper = true;
3460
- let resistanceRatio = params.resistanceRatio;
3461
-
3462
- if (params.touchReleaseOnEdges) {
3463
- resistanceRatio = 0;
3464
- }
3465
-
3466
- if (diff > 0 && data.currentTranslate > swiper.minTranslate()) {
3467
- disableParentSwiper = false;
3468
- if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + (-swiper.minTranslate() + data.startTranslate + diff) ** resistanceRatio;
3469
- } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
3470
- disableParentSwiper = false;
3471
- if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - (swiper.maxTranslate() - data.startTranslate - diff) ** resistanceRatio;
3472
- }
3473
-
3474
- if (disableParentSwiper) {
3475
- e.preventedByNestedSwiper = true;
3476
- } // Directions locks
3477
-
3478
-
3479
- if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
3480
- data.currentTranslate = data.startTranslate;
3481
- }
3482
-
3483
- if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
3484
- data.currentTranslate = data.startTranslate;
3485
- }
3486
-
3487
- if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
3488
- data.currentTranslate = data.startTranslate;
3489
- } // Threshold
3490
-
3491
-
3492
- if (params.threshold > 0) {
3493
- if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
3494
- if (!data.allowThresholdMove) {
3495
- data.allowThresholdMove = true;
3496
- touches.startX = touches.currentX;
3497
- touches.startY = touches.currentY;
3498
- data.currentTranslate = data.startTranslate;
3499
- touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
3500
- return;
3501
- }
3502
- } else {
3503
- data.currentTranslate = data.startTranslate;
3504
- return;
3505
- }
3506
- }
3507
-
3508
- if (!params.followFinger || params.cssMode) return; // Update active index in free mode
3509
-
3510
- if (params.freeMode && params.freeMode.enabled && swiper.freeMode || params.watchSlidesProgress) {
3511
- swiper.updateActiveIndex();
3512
- swiper.updateSlidesClasses();
3513
- }
3514
-
3515
- if (swiper.params.freeMode && params.freeMode.enabled && swiper.freeMode) {
3516
- swiper.freeMode.onTouchMove();
3517
- } // Update progress
3518
-
3519
-
3520
- swiper.updateProgress(data.currentTranslate); // Update translate
3521
-
3522
- swiper.setTranslate(data.currentTranslate);
3523
- }
3524
-
3525
- function onTouchEnd(event) {
3526
- const swiper = this;
3527
- const data = swiper.touchEventsData;
3528
- const {
3529
- params,
3530
- touches,
3531
- rtlTranslate: rtl,
3532
- slidesGrid,
3533
- enabled
3534
- } = swiper;
3535
- if (!enabled) return;
3536
- let e = event;
3537
- if (e.originalEvent) e = e.originalEvent;
3538
-
3539
- if (data.allowTouchCallbacks) {
3540
- swiper.emit('touchEnd', e);
3541
- }
3542
-
3543
- data.allowTouchCallbacks = false;
3544
-
3545
- if (!data.isTouched) {
3546
- if (data.isMoved && params.grabCursor) {
3547
- swiper.setGrabCursor(false);
3548
- }
3549
-
3550
- data.isMoved = false;
3551
- data.startMoving = false;
3552
- return;
3553
- } // Return Grab Cursor
3554
-
3555
-
3556
- if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
3557
- swiper.setGrabCursor(false);
3558
- } // Time diff
3559
-
3560
-
3561
- const touchEndTime = now();
3562
- const timeDiff = touchEndTime - data.touchStartTime; // Tap, doubleTap, Click
3563
-
3564
- if (swiper.allowClick) {
3565
- const pathTree = e.path || e.composedPath && e.composedPath();
3566
- swiper.updateClickedSlide(pathTree && pathTree[0] || e.target);
3567
- swiper.emit('tap click', e);
3568
-
3569
- if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
3570
- swiper.emit('doubleTap doubleClick', e);
3571
- }
3572
- }
3573
-
3574
- data.lastClickTime = now();
3575
- nextTick(() => {
3576
- if (!swiper.destroyed) swiper.allowClick = true;
3577
- });
3578
-
3579
- if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
3580
- data.isTouched = false;
3581
- data.isMoved = false;
3582
- data.startMoving = false;
3583
- return;
3584
- }
3585
-
3586
- data.isTouched = false;
3587
- data.isMoved = false;
3588
- data.startMoving = false;
3589
- let currentPos;
3590
-
3591
- if (params.followFinger) {
3592
- currentPos = rtl ? swiper.translate : -swiper.translate;
3593
- } else {
3594
- currentPos = -data.currentTranslate;
3595
- }
3596
-
3597
- if (params.cssMode) {
3598
- return;
3599
- }
3600
-
3601
- if (swiper.params.freeMode && params.freeMode.enabled) {
3602
- swiper.freeMode.onTouchEnd({
3603
- currentPos
3604
- });
3605
- return;
3606
- } // Find current slide
3607
-
3608
-
3609
- let stopIndex = 0;
3610
- let groupSize = swiper.slidesSizesGrid[0];
3611
-
3612
- for (let i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
3613
- const increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
3614
-
3615
- if (typeof slidesGrid[i + increment] !== 'undefined') {
3616
- if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + increment]) {
3617
- stopIndex = i;
3618
- groupSize = slidesGrid[i + increment] - slidesGrid[i];
3619
- }
3620
- } else if (currentPos >= slidesGrid[i]) {
3621
- stopIndex = i;
3622
- groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
3623
- }
3624
- }
3625
-
3626
- let rewindFirstIndex = null;
3627
- let rewindLastIndex = null;
3628
-
3629
- if (params.rewind) {
3630
- if (swiper.isBeginning) {
3631
- rewindLastIndex = swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual ? swiper.virtual.slides.length - 1 : swiper.slides.length - 1;
3632
- } else if (swiper.isEnd) {
3633
- rewindFirstIndex = 0;
3634
- }
3635
- } // Find current slide size
3636
-
3637
-
3638
- const ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
3639
- const increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
3640
-
3641
- if (timeDiff > params.longSwipesMs) {
3642
- // Long touches
3643
- if (!params.longSwipes) {
3644
- swiper.slideTo(swiper.activeIndex);
3645
- return;
3646
- }
3647
-
3648
- if (swiper.swipeDirection === 'next') {
3649
- if (ratio >= params.longSwipesRatio) swiper.slideTo(params.rewind && swiper.isEnd ? rewindFirstIndex : stopIndex + increment);else swiper.slideTo(stopIndex);
3650
- }
3651
-
3652
- if (swiper.swipeDirection === 'prev') {
3653
- if (ratio > 1 - params.longSwipesRatio) {
3654
- swiper.slideTo(stopIndex + increment);
3655
- } else if (rewindLastIndex !== null && ratio < 0 && Math.abs(ratio) > params.longSwipesRatio) {
3656
- swiper.slideTo(rewindLastIndex);
3657
- } else {
3658
- swiper.slideTo(stopIndex);
3659
- }
3660
- }
3661
- } else {
3662
- // Short swipes
3663
- if (!params.shortSwipes) {
3664
- swiper.slideTo(swiper.activeIndex);
3665
- return;
3666
- }
3667
-
3668
- const isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
3669
-
3670
- if (!isNavButtonTarget) {
3671
- if (swiper.swipeDirection === 'next') {
3672
- swiper.slideTo(rewindFirstIndex !== null ? rewindFirstIndex : stopIndex + increment);
3673
- }
3674
-
3675
- if (swiper.swipeDirection === 'prev') {
3676
- swiper.slideTo(rewindLastIndex !== null ? rewindLastIndex : stopIndex);
3677
- }
3678
- } else if (e.target === swiper.navigation.nextEl) {
3679
- swiper.slideTo(stopIndex + increment);
3680
- } else {
3681
- swiper.slideTo(stopIndex);
3682
- }
3683
- }
3684
- }
3685
-
3686
- function onResize() {
3687
- const swiper = this;
3688
- const {
3689
- params,
3690
- el
3691
- } = swiper;
3692
- if (el && el.offsetWidth === 0) return; // Breakpoints
3693
-
3694
- if (params.breakpoints) {
3695
- swiper.setBreakpoint();
3696
- } // Save locks
3697
-
3698
-
3699
- const {
3700
- allowSlideNext,
3701
- allowSlidePrev,
3702
- snapGrid
3703
- } = swiper; // Disable locks on resize
3704
-
3705
- swiper.allowSlideNext = true;
3706
- swiper.allowSlidePrev = true;
3707
- swiper.updateSize();
3708
- swiper.updateSlides();
3709
- swiper.updateSlidesClasses();
3710
-
3711
- if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
3712
- swiper.slideTo(swiper.slides.length - 1, 0, false, true);
3713
- } else {
3714
- swiper.slideTo(swiper.activeIndex, 0, false, true);
3715
- }
3716
-
3717
- if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
3718
- swiper.autoplay.run();
3719
- } // Return locks after resize
3720
-
3721
-
3722
- swiper.allowSlidePrev = allowSlidePrev;
3723
- swiper.allowSlideNext = allowSlideNext;
3724
-
3725
- if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
3726
- swiper.checkOverflow();
3727
- }
3728
- }
3729
-
3730
- function onClick(e) {
3731
- const swiper = this;
3732
- if (!swiper.enabled) return;
3733
-
3734
- if (!swiper.allowClick) {
3735
- if (swiper.params.preventClicks) e.preventDefault();
3736
-
3737
- if (swiper.params.preventClicksPropagation && swiper.animating) {
3738
- e.stopPropagation();
3739
- e.stopImmediatePropagation();
3740
- }
3741
- }
3742
- }
3743
-
3744
- function onScroll() {
3745
- const swiper = this;
3746
- const {
3747
- wrapperEl,
3748
- rtlTranslate,
3749
- enabled
3750
- } = swiper;
3751
- if (!enabled) return;
3752
- swiper.previousTranslate = swiper.translate;
3753
-
3754
- if (swiper.isHorizontal()) {
3755
- swiper.translate = -wrapperEl.scrollLeft;
3756
- } else {
3757
- swiper.translate = -wrapperEl.scrollTop;
3758
- } // eslint-disable-next-line
3759
-
3760
-
3761
- if (swiper.translate === 0) swiper.translate = 0;
3762
- swiper.updateActiveIndex();
3763
- swiper.updateSlidesClasses();
3764
- let newProgress;
3765
- const translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
3766
-
3767
- if (translatesDiff === 0) {
3768
- newProgress = 0;
3769
- } else {
3770
- newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
3771
- }
3772
-
3773
- if (newProgress !== swiper.progress) {
3774
- swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
3775
- }
3776
-
3777
- swiper.emit('setTranslate', swiper.translate, false);
3778
- }
3779
-
3780
- let dummyEventAttached = false;
3781
-
3782
- function dummyEventListener() {}
3783
-
3784
- const events = (swiper, method) => {
3785
- const document = getDocument();
3786
- const {
3787
- params,
3788
- touchEvents,
3789
- el,
3790
- wrapperEl,
3791
- device,
3792
- support
3793
- } = swiper;
3794
- const capture = !!params.nested;
3795
- const domMethod = method === 'on' ? 'addEventListener' : 'removeEventListener';
3796
- const swiperMethod = method; // Touch Events
3797
-
3798
- if (!support.touch) {
3799
- el[domMethod](touchEvents.start, swiper.onTouchStart, false);
3800
- document[domMethod](touchEvents.move, swiper.onTouchMove, capture);
3801
- document[domMethod](touchEvents.end, swiper.onTouchEnd, false);
3802
- } else {
3803
- const passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? {
3804
- passive: true,
3805
- capture: false
3806
- } : false;
3807
- el[domMethod](touchEvents.start, swiper.onTouchStart, passiveListener);
3808
- el[domMethod](touchEvents.move, swiper.onTouchMove, support.passiveListener ? {
3809
- passive: false,
3810
- capture
3811
- } : capture);
3812
- el[domMethod](touchEvents.end, swiper.onTouchEnd, passiveListener);
3813
-
3814
- if (touchEvents.cancel) {
3815
- el[domMethod](touchEvents.cancel, swiper.onTouchEnd, passiveListener);
3816
- }
3817
- } // Prevent Links Clicks
3818
-
3819
-
3820
- if (params.preventClicks || params.preventClicksPropagation) {
3821
- el[domMethod]('click', swiper.onClick, true);
3822
- }
3823
-
3824
- if (params.cssMode) {
3825
- wrapperEl[domMethod]('scroll', swiper.onScroll);
3826
- } // Resize handler
3827
-
3828
-
3829
- if (params.updateOnWindowResize) {
3830
- swiper[swiperMethod](device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
3831
- } else {
3832
- swiper[swiperMethod]('observerUpdate', onResize, true);
3833
- }
3834
- };
3835
-
3836
- function attachEvents() {
3837
- const swiper = this;
3838
- const document = getDocument();
3839
- const {
3840
- params,
3841
- support
3842
- } = swiper;
3843
- swiper.onTouchStart = onTouchStart.bind(swiper);
3844
- swiper.onTouchMove = onTouchMove.bind(swiper);
3845
- swiper.onTouchEnd = onTouchEnd.bind(swiper);
3846
-
3847
- if (params.cssMode) {
3848
- swiper.onScroll = onScroll.bind(swiper);
3849
- }
3850
-
3851
- swiper.onClick = onClick.bind(swiper);
3852
-
3853
- if (support.touch && !dummyEventAttached) {
3854
- document.addEventListener('touchstart', dummyEventListener);
3855
- dummyEventAttached = true;
3856
- }
3857
-
3858
- events(swiper, 'on');
3859
- }
3860
-
3861
- function detachEvents() {
3862
- const swiper = this;
3863
- events(swiper, 'off');
3864
- }
3865
-
3866
- const events$1 = {
3867
- attachEvents,
3868
- detachEvents
3869
- };
3870
-
3871
- const isGridEnabled = (swiper, params) => {
3872
- return swiper.grid && params.grid && params.grid.rows > 1;
3873
- };
3874
-
3875
- function setBreakpoint() {
3876
- const swiper = this;
3877
- const {
3878
- activeIndex,
3879
- initialized,
3880
- loopedSlides = 0,
3881
- params,
3882
- $el
3883
- } = swiper;
3884
- const breakpoints = params.breakpoints;
3885
- if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return; // Get breakpoint for window width and update parameters
3886
-
3887
- const breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
3888
- if (!breakpoint || swiper.currentBreakpoint === breakpoint) return;
3889
- const breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
3890
- const breakpointParams = breakpointOnlyParams || swiper.originalParams;
3891
- const wasMultiRow = isGridEnabled(swiper, params);
3892
- const isMultiRow = isGridEnabled(swiper, breakpointParams);
3893
- const wasEnabled = params.enabled;
3894
-
3895
- if (wasMultiRow && !isMultiRow) {
3896
- $el.removeClass(`${params.containerModifierClass}grid ${params.containerModifierClass}grid-column`);
3897
- swiper.emitContainerClasses();
3898
- } else if (!wasMultiRow && isMultiRow) {
3899
- $el.addClass(`${params.containerModifierClass}grid`);
3900
-
3901
- if (breakpointParams.grid.fill && breakpointParams.grid.fill === 'column' || !breakpointParams.grid.fill && params.grid.fill === 'column') {
3902
- $el.addClass(`${params.containerModifierClass}grid-column`);
3903
- }
3904
-
3905
- swiper.emitContainerClasses();
3906
- } // Toggle navigation, pagination, scrollbar
3907
-
3908
-
3909
- ['navigation', 'pagination', 'scrollbar'].forEach(prop => {
3910
- const wasModuleEnabled = params[prop] && params[prop].enabled;
3911
- const isModuleEnabled = breakpointParams[prop] && breakpointParams[prop].enabled;
3912
-
3913
- if (wasModuleEnabled && !isModuleEnabled) {
3914
- swiper[prop].disable();
3915
- }
3916
-
3917
- if (!wasModuleEnabled && isModuleEnabled) {
3918
- swiper[prop].enable();
3919
- }
3920
- });
3921
- const directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
3922
- const needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
3923
-
3924
- if (directionChanged && initialized) {
3925
- swiper.changeDirection();
3926
- }
3927
-
3928
- extend(swiper.params, breakpointParams);
3929
- const isEnabled = swiper.params.enabled;
3930
- Object.assign(swiper, {
3931
- allowTouchMove: swiper.params.allowTouchMove,
3932
- allowSlideNext: swiper.params.allowSlideNext,
3933
- allowSlidePrev: swiper.params.allowSlidePrev
3934
- });
3935
-
3936
- if (wasEnabled && !isEnabled) {
3937
- swiper.disable();
3938
- } else if (!wasEnabled && isEnabled) {
3939
- swiper.enable();
3940
- }
3941
-
3942
- swiper.currentBreakpoint = breakpoint;
3943
- swiper.emit('_beforeBreakpoint', breakpointParams);
3944
-
3945
- if (needsReLoop && initialized) {
3946
- swiper.loopDestroy();
3947
- swiper.loopCreate();
3948
- swiper.updateSlides();
3949
- swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false);
3950
- }
3951
-
3952
- swiper.emit('breakpoint', breakpointParams);
3953
- }
3954
-
3955
- function getBreakpoint(breakpoints, base, containerEl) {
3956
- if (base === void 0) {
3957
- base = 'window';
3958
- }
3959
-
3960
- if (!breakpoints || base === 'container' && !containerEl) return undefined;
3961
- let breakpoint = false;
3962
- const window = getWindow();
3963
- const currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
3964
- const points = Object.keys(breakpoints).map(point => {
3965
- if (typeof point === 'string' && point.indexOf('@') === 0) {
3966
- const minRatio = parseFloat(point.substr(1));
3967
- const value = currentHeight * minRatio;
3968
- return {
3969
- value,
3970
- point
3971
- };
3972
- }
3973
-
3974
- return {
3975
- value: point,
3976
- point
3977
- };
3978
- });
3979
- points.sort((a, b) => parseInt(a.value, 10) - parseInt(b.value, 10));
3980
-
3981
- for (let i = 0; i < points.length; i += 1) {
3982
- const {
3983
- point,
3984
- value
3985
- } = points[i];
3986
-
3987
- if (base === 'window') {
3988
- if (window.matchMedia(`(min-width: ${value}px)`).matches) {
3989
- breakpoint = point;
3990
- }
3991
- } else if (value <= containerEl.clientWidth) {
3992
- breakpoint = point;
3993
- }
3994
- }
3995
-
3996
- return breakpoint || 'max';
3997
- }
3998
-
3999
- const breakpoints = {
4000
- setBreakpoint,
4001
- getBreakpoint
4002
- };
4003
-
4004
- function prepareClasses(entries, prefix) {
4005
- const resultClasses = [];
4006
- entries.forEach(item => {
4007
- if (typeof item === 'object') {
4008
- Object.keys(item).forEach(classNames => {
4009
- if (item[classNames]) {
4010
- resultClasses.push(prefix + classNames);
4011
- }
4012
- });
4013
- } else if (typeof item === 'string') {
4014
- resultClasses.push(prefix + item);
4015
- }
4016
- });
4017
- return resultClasses;
4018
- }
4019
-
4020
- function addClasses() {
4021
- const swiper = this;
4022
- const {
4023
- classNames,
4024
- params,
4025
- rtl,
4026
- $el,
4027
- device,
4028
- support
4029
- } = swiper; // prettier-ignore
4030
-
4031
- const suffixes = prepareClasses(['initialized', params.direction, {
4032
- 'pointer-events': !support.touch
4033
- }, {
4034
- 'free-mode': swiper.params.freeMode && params.freeMode.enabled
4035
- }, {
4036
- 'autoheight': params.autoHeight
4037
- }, {
4038
- 'rtl': rtl
4039
- }, {
4040
- 'grid': params.grid && params.grid.rows > 1
4041
- }, {
4042
- 'grid-column': params.grid && params.grid.rows > 1 && params.grid.fill === 'column'
4043
- }, {
4044
- 'android': device.android
4045
- }, {
4046
- 'ios': device.ios
4047
- }, {
4048
- 'css-mode': params.cssMode
4049
- }, {
4050
- 'centered': params.cssMode && params.centeredSlides
4051
- }, {
4052
- 'watch-progress': params.watchSlidesProgress
4053
- }], params.containerModifierClass);
4054
- classNames.push(...suffixes);
4055
- $el.addClass([...classNames].join(' '));
4056
- swiper.emitContainerClasses();
4057
- }
4058
-
4059
- function removeClasses() {
4060
- const swiper = this;
4061
- const {
4062
- $el,
4063
- classNames
4064
- } = swiper;
4065
- $el.removeClass(classNames.join(' '));
4066
- swiper.emitContainerClasses();
4067
- }
4068
-
4069
- const classes = {
4070
- addClasses,
4071
- removeClasses
4072
- };
4073
-
4074
- function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) {
4075
- const window = getWindow();
4076
- let image;
4077
-
4078
- function onReady() {
4079
- if (callback) callback();
4080
- }
4081
-
4082
- const isPicture = $(imageEl).parent('picture')[0];
4083
-
4084
- if (!isPicture && (!imageEl.complete || !checkForComplete)) {
4085
- if (src) {
4086
- image = new window.Image();
4087
- image.onload = onReady;
4088
- image.onerror = onReady;
4089
-
4090
- if (sizes) {
4091
- image.sizes = sizes;
4092
- }
4093
-
4094
- if (srcset) {
4095
- image.srcset = srcset;
4096
- }
4097
-
4098
- if (src) {
4099
- image.src = src;
4100
- }
4101
- } else {
4102
- onReady();
4103
- }
4104
- } else {
4105
- // image already loaded...
4106
- onReady();
4107
- }
4108
- }
4109
-
4110
- function preloadImages() {
4111
- const swiper = this;
4112
- swiper.imagesToLoad = swiper.$el.find('img');
4113
-
4114
- function onReady() {
4115
- if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return;
4116
- if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1;
4117
-
4118
- if (swiper.imagesLoaded === swiper.imagesToLoad.length) {
4119
- if (swiper.params.updateOnImagesReady) swiper.update();
4120
- swiper.emit('imagesReady');
4121
- }
4122
- }
4123
-
4124
- for (let i = 0; i < swiper.imagesToLoad.length; i += 1) {
4125
- const imageEl = swiper.imagesToLoad[i];
4126
- swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady);
4127
- }
4128
- }
4129
-
4130
- const images = {
4131
- loadImage,
4132
- preloadImages
4133
- };
4134
-
4135
- function checkOverflow() {
4136
- const swiper = this;
4137
- const {
4138
- isLocked: wasLocked,
4139
- params
4140
- } = swiper;
4141
- const {
4142
- slidesOffsetBefore
4143
- } = params;
4144
-
4145
- if (slidesOffsetBefore) {
4146
- const lastSlideIndex = swiper.slides.length - 1;
4147
- const lastSlideRightEdge = swiper.slidesGrid[lastSlideIndex] + swiper.slidesSizesGrid[lastSlideIndex] + slidesOffsetBefore * 2;
4148
- swiper.isLocked = swiper.size > lastSlideRightEdge;
4149
- } else {
4150
- swiper.isLocked = swiper.snapGrid.length === 1;
4151
- }
4152
-
4153
- if (params.allowSlideNext === true) {
4154
- swiper.allowSlideNext = !swiper.isLocked;
4155
- }
4156
-
4157
- if (params.allowSlidePrev === true) {
4158
- swiper.allowSlidePrev = !swiper.isLocked;
4159
- }
4160
-
4161
- if (wasLocked && wasLocked !== swiper.isLocked) {
4162
- swiper.isEnd = false;
4163
- }
4164
-
4165
- if (wasLocked !== swiper.isLocked) {
4166
- swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
4167
- }
4168
- }
4169
-
4170
- const checkOverflow$1 = {
4171
- checkOverflow
4172
- };
4173
-
4174
- const defaults = {
4175
- init: true,
4176
- direction: 'horizontal',
4177
- touchEventsTarget: 'wrapper',
4178
- initialSlide: 0,
4179
- speed: 300,
4180
- cssMode: false,
4181
- updateOnWindowResize: true,
4182
- resizeObserver: true,
4183
- nested: false,
4184
- createElements: false,
4185
- enabled: true,
4186
- focusableElements: 'input, select, option, textarea, button, video, label',
4187
- // Overrides
4188
- width: null,
4189
- height: null,
4190
- //
4191
- preventInteractionOnTransition: false,
4192
- // ssr
4193
- userAgent: null,
4194
- url: null,
4195
- // To support iOS's swipe-to-go-back gesture (when being used in-app).
4196
- edgeSwipeDetection: false,
4197
- edgeSwipeThreshold: 20,
4198
- // Autoheight
4199
- autoHeight: false,
4200
- // Set wrapper width
4201
- setWrapperSize: false,
4202
- // Virtual Translate
4203
- virtualTranslate: false,
4204
- // Effects
4205
- effect: 'slide',
4206
- // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip'
4207
- // Breakpoints
4208
- breakpoints: undefined,
4209
- breakpointsBase: 'window',
4210
- // Slides grid
4211
- spaceBetween: 0,
4212
- slidesPerView: 1,
4213
- slidesPerGroup: 1,
4214
- slidesPerGroupSkip: 0,
4215
- slidesPerGroupAuto: false,
4216
- centeredSlides: false,
4217
- centeredSlidesBounds: false,
4218
- slidesOffsetBefore: 0,
4219
- // in px
4220
- slidesOffsetAfter: 0,
4221
- // in px
4222
- normalizeSlideIndex: true,
4223
- centerInsufficientSlides: false,
4224
- // Disable swiper and hide navigation when container not overflow
4225
- watchOverflow: true,
4226
- // Round length
4227
- roundLengths: false,
4228
- // Touches
4229
- touchRatio: 1,
4230
- touchAngle: 45,
4231
- simulateTouch: true,
4232
- shortSwipes: true,
4233
- longSwipes: true,
4234
- longSwipesRatio: 0.5,
4235
- longSwipesMs: 300,
4236
- followFinger: true,
4237
- allowTouchMove: true,
4238
- threshold: 0,
4239
- touchMoveStopPropagation: false,
4240
- touchStartPreventDefault: true,
4241
- touchStartForcePreventDefault: false,
4242
- touchReleaseOnEdges: false,
4243
- // Unique Navigation Elements
4244
- uniqueNavElements: true,
4245
- // Resistance
4246
- resistance: true,
4247
- resistanceRatio: 0.85,
4248
- // Progress
4249
- watchSlidesProgress: false,
4250
- // Cursor
4251
- grabCursor: false,
4252
- // Clicks
4253
- preventClicks: true,
4254
- preventClicksPropagation: true,
4255
- slideToClickedSlide: false,
4256
- // Images
4257
- preloadImages: true,
4258
- updateOnImagesReady: true,
4259
- // loop
4260
- loop: false,
4261
- loopAdditionalSlides: 0,
4262
- loopedSlides: null,
4263
- loopedSlidesLimit: true,
4264
- loopFillGroupWithBlank: false,
4265
- loopPreventsSlide: true,
4266
- // rewind
4267
- rewind: false,
4268
- // Swiping/no swiping
4269
- allowSlidePrev: true,
4270
- allowSlideNext: true,
4271
- swipeHandler: null,
4272
- // '.swipe-handler',
4273
- noSwiping: true,
4274
- noSwipingClass: 'swiper-no-swiping',
4275
- noSwipingSelector: null,
4276
- // Passive Listeners
4277
- passiveListeners: true,
4278
- maxBackfaceHiddenSlides: 10,
4279
- // NS
4280
- containerModifierClass: 'swiper-',
4281
- // NEW
4282
- slideClass: 'swiper-slide',
4283
- slideBlankClass: 'swiper-slide-invisible-blank',
4284
- slideActiveClass: 'swiper-slide-active',
4285
- slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
4286
- slideVisibleClass: 'swiper-slide-visible',
4287
- slideDuplicateClass: 'swiper-slide-duplicate',
4288
- slideNextClass: 'swiper-slide-next',
4289
- slideDuplicateNextClass: 'swiper-slide-duplicate-next',
4290
- slidePrevClass: 'swiper-slide-prev',
4291
- slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
4292
- wrapperClass: 'swiper-wrapper',
4293
- // Callbacks
4294
- runCallbacksOnInit: true,
4295
- // Internals
4296
- _emitClasses: false
4297
- };
4298
-
4299
- function moduleExtendParams(params, allModulesParams) {
4300
- return function extendParams(obj) {
4301
- if (obj === void 0) {
4302
- obj = {};
4303
- }
4304
-
4305
- const moduleParamName = Object.keys(obj)[0];
4306
- const moduleParams = obj[moduleParamName];
4307
-
4308
- if (typeof moduleParams !== 'object' || moduleParams === null) {
4309
- extend(allModulesParams, obj);
4310
- return;
4311
- }
4312
-
4313
- if (['navigation', 'pagination', 'scrollbar'].indexOf(moduleParamName) >= 0 && params[moduleParamName] === true) {
4314
- params[moduleParamName] = {
4315
- auto: true
4316
- };
4317
- }
4318
-
4319
- if (!(moduleParamName in params && 'enabled' in moduleParams)) {
4320
- extend(allModulesParams, obj);
4321
- return;
4322
- }
4323
-
4324
- if (params[moduleParamName] === true) {
4325
- params[moduleParamName] = {
4326
- enabled: true
4327
- };
4328
- }
4329
-
4330
- if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
4331
- params[moduleParamName].enabled = true;
4332
- }
4333
-
4334
- if (!params[moduleParamName]) params[moduleParamName] = {
4335
- enabled: false
4336
- };
4337
- extend(allModulesParams, obj);
4338
- };
4339
- }
4340
-
4341
- /* eslint no-param-reassign: "off" */
4342
- const prototypes = {
4343
- eventsEmitter,
4344
- update,
4345
- translate,
4346
- transition,
4347
- slide,
4348
- loop,
4349
- grabCursor,
4350
- events: events$1,
4351
- breakpoints,
4352
- checkOverflow: checkOverflow$1,
4353
- classes,
4354
- images
4355
- };
4356
- const extendedDefaults = {};
4357
-
4358
- class Swiper {
4359
- constructor() {
4360
- let el;
4361
- let params;
4362
-
4363
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4364
- args[_key] = arguments[_key];
4365
- }
4366
-
4367
- if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
4368
- params = args[0];
4369
- } else {
4370
- [el, params] = args;
4371
- }
4372
-
4373
- if (!params) params = {};
4374
- params = extend({}, params);
4375
- if (el && !params.el) params.el = el;
4376
-
4377
- if (params.el && $(params.el).length > 1) {
4378
- const swipers = [];
4379
- $(params.el).each(containerEl => {
4380
- const newParams = extend({}, params, {
4381
- el: containerEl
4382
- });
4383
- swipers.push(new Swiper(newParams));
4384
- });
4385
- return swipers;
4386
- } // Swiper Instance
4387
-
4388
-
4389
- const swiper = this;
4390
- swiper.__swiper__ = true;
4391
- swiper.support = getSupport();
4392
- swiper.device = getDevice({
4393
- userAgent: params.userAgent
4394
- });
4395
- swiper.browser = getBrowser();
4396
- swiper.eventsListeners = {};
4397
- swiper.eventsAnyListeners = [];
4398
- swiper.modules = [...swiper.__modules__];
4399
-
4400
- if (params.modules && Array.isArray(params.modules)) {
4401
- swiper.modules.push(...params.modules);
4402
- }
4403
-
4404
- const allModulesParams = {};
4405
- swiper.modules.forEach(mod => {
4406
- mod({
4407
- swiper,
4408
- extendParams: moduleExtendParams(params, allModulesParams),
4409
- on: swiper.on.bind(swiper),
4410
- once: swiper.once.bind(swiper),
4411
- off: swiper.off.bind(swiper),
4412
- emit: swiper.emit.bind(swiper)
4413
- });
4414
- }); // Extend defaults with modules params
4415
-
4416
- const swiperParams = extend({}, defaults, allModulesParams); // Extend defaults with passed params
4417
-
4418
- swiper.params = extend({}, swiperParams, extendedDefaults, params);
4419
- swiper.originalParams = extend({}, swiper.params);
4420
- swiper.passedParams = extend({}, params); // add event listeners
4421
-
4422
- if (swiper.params && swiper.params.on) {
4423
- Object.keys(swiper.params.on).forEach(eventName => {
4424
- swiper.on(eventName, swiper.params.on[eventName]);
4425
- });
4426
- }
4427
-
4428
- if (swiper.params && swiper.params.onAny) {
4429
- swiper.onAny(swiper.params.onAny);
4430
- } // Save Dom lib
4431
-
4432
-
4433
- swiper.$ = $; // Extend Swiper
4434
-
4435
- Object.assign(swiper, {
4436
- enabled: swiper.params.enabled,
4437
- el,
4438
- // Classes
4439
- classNames: [],
4440
- // Slides
4441
- slides: $(),
4442
- slidesGrid: [],
4443
- snapGrid: [],
4444
- slidesSizesGrid: [],
4445
-
4446
- // isDirection
4447
- isHorizontal() {
4448
- return swiper.params.direction === 'horizontal';
4449
- },
4450
-
4451
- isVertical() {
4452
- return swiper.params.direction === 'vertical';
4453
- },
4454
-
4455
- // Indexes
4456
- activeIndex: 0,
4457
- realIndex: 0,
4458
- //
4459
- isBeginning: true,
4460
- isEnd: false,
4461
- // Props
4462
- translate: 0,
4463
- previousTranslate: 0,
4464
- progress: 0,
4465
- velocity: 0,
4466
- animating: false,
4467
- // Locks
4468
- allowSlideNext: swiper.params.allowSlideNext,
4469
- allowSlidePrev: swiper.params.allowSlidePrev,
4470
- // Touch Events
4471
- touchEvents: function touchEvents() {
4472
- const touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
4473
- const desktop = ['pointerdown', 'pointermove', 'pointerup'];
4474
- swiper.touchEventsTouch = {
4475
- start: touch[0],
4476
- move: touch[1],
4477
- end: touch[2],
4478
- cancel: touch[3]
4479
- };
4480
- swiper.touchEventsDesktop = {
4481
- start: desktop[0],
4482
- move: desktop[1],
4483
- end: desktop[2]
4484
- };
4485
- return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop;
4486
- }(),
4487
- touchEventsData: {
4488
- isTouched: undefined,
4489
- isMoved: undefined,
4490
- allowTouchCallbacks: undefined,
4491
- touchStartTime: undefined,
4492
- isScrolling: undefined,
4493
- currentTranslate: undefined,
4494
- startTranslate: undefined,
4495
- allowThresholdMove: undefined,
4496
- // Form elements to match
4497
- focusableElements: swiper.params.focusableElements,
4498
- // Last click time
4499
- lastClickTime: now(),
4500
- clickTimeout: undefined,
4501
- // Velocities
4502
- velocities: [],
4503
- allowMomentumBounce: undefined,
4504
- isTouchEvent: undefined,
4505
- startMoving: undefined
4506
- },
4507
- // Clicks
4508
- allowClick: true,
4509
- // Touches
4510
- allowTouchMove: swiper.params.allowTouchMove,
4511
- touches: {
4512
- startX: 0,
4513
- startY: 0,
4514
- currentX: 0,
4515
- currentY: 0,
4516
- diff: 0
4517
- },
4518
- // Images
4519
- imagesToLoad: [],
4520
- imagesLoaded: 0
4521
- });
4522
- swiper.emit('_swiper'); // Init
4523
-
4524
- if (swiper.params.init) {
4525
- swiper.init();
4526
- } // Return app instance
4527
-
4528
-
4529
- return swiper;
4530
- }
4531
-
4532
- enable() {
4533
- const swiper = this;
4534
- if (swiper.enabled) return;
4535
- swiper.enabled = true;
4536
-
4537
- if (swiper.params.grabCursor) {
4538
- swiper.setGrabCursor();
4539
- }
4540
-
4541
- swiper.emit('enable');
4542
- }
4543
-
4544
- disable() {
4545
- const swiper = this;
4546
- if (!swiper.enabled) return;
4547
- swiper.enabled = false;
4548
-
4549
- if (swiper.params.grabCursor) {
4550
- swiper.unsetGrabCursor();
4551
- }
4552
-
4553
- swiper.emit('disable');
4554
- }
4555
-
4556
- setProgress(progress, speed) {
4557
- const swiper = this;
4558
- progress = Math.min(Math.max(progress, 0), 1);
4559
- const min = swiper.minTranslate();
4560
- const max = swiper.maxTranslate();
4561
- const current = (max - min) * progress + min;
4562
- swiper.translateTo(current, typeof speed === 'undefined' ? 0 : speed);
4563
- swiper.updateActiveIndex();
4564
- swiper.updateSlidesClasses();
4565
- }
4566
-
4567
- emitContainerClasses() {
4568
- const swiper = this;
4569
- if (!swiper.params._emitClasses || !swiper.el) return;
4570
- const cls = swiper.el.className.split(' ').filter(className => {
4571
- return className.indexOf('swiper') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
4572
- });
4573
- swiper.emit('_containerClasses', cls.join(' '));
4574
- }
4575
-
4576
- getSlideClasses(slideEl) {
4577
- const swiper = this;
4578
- if (swiper.destroyed) return '';
4579
- return slideEl.className.split(' ').filter(className => {
4580
- return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
4581
- }).join(' ');
4582
- }
4583
-
4584
- emitSlidesClasses() {
4585
- const swiper = this;
4586
- if (!swiper.params._emitClasses || !swiper.el) return;
4587
- const updates = [];
4588
- swiper.slides.each(slideEl => {
4589
- const classNames = swiper.getSlideClasses(slideEl);
4590
- updates.push({
4591
- slideEl,
4592
- classNames
4593
- });
4594
- swiper.emit('_slideClass', slideEl, classNames);
4595
- });
4596
- swiper.emit('_slideClasses', updates);
4597
- }
4598
-
4599
- slidesPerViewDynamic(view, exact) {
4600
- if (view === void 0) {
4601
- view = 'current';
4602
- }
4603
-
4604
- if (exact === void 0) {
4605
- exact = false;
4606
- }
4607
-
4608
- const swiper = this;
4609
- const {
4610
- params,
4611
- slides,
4612
- slidesGrid,
4613
- slidesSizesGrid,
4614
- size: swiperSize,
4615
- activeIndex
4616
- } = swiper;
4617
- let spv = 1;
4618
-
4619
- if (params.centeredSlides) {
4620
- let slideSize = slides[activeIndex].swiperSlideSize;
4621
- let breakLoop;
4622
-
4623
- for (let i = activeIndex + 1; i < slides.length; i += 1) {
4624
- if (slides[i] && !breakLoop) {
4625
- slideSize += slides[i].swiperSlideSize;
4626
- spv += 1;
4627
- if (slideSize > swiperSize) breakLoop = true;
4628
- }
4629
- }
4630
-
4631
- for (let i = activeIndex - 1; i >= 0; i -= 1) {
4632
- if (slides[i] && !breakLoop) {
4633
- slideSize += slides[i].swiperSlideSize;
4634
- spv += 1;
4635
- if (slideSize > swiperSize) breakLoop = true;
4636
- }
4637
- }
4638
- } else {
4639
- // eslint-disable-next-line
4640
- if (view === 'current') {
4641
- for (let i = activeIndex + 1; i < slides.length; i += 1) {
4642
- const slideInView = exact ? slidesGrid[i] + slidesSizesGrid[i] - slidesGrid[activeIndex] < swiperSize : slidesGrid[i] - slidesGrid[activeIndex] < swiperSize;
4643
-
4644
- if (slideInView) {
4645
- spv += 1;
4646
- }
4647
- }
4648
- } else {
4649
- // previous
4650
- for (let i = activeIndex - 1; i >= 0; i -= 1) {
4651
- const slideInView = slidesGrid[activeIndex] - slidesGrid[i] < swiperSize;
4652
-
4653
- if (slideInView) {
4654
- spv += 1;
4655
- }
4656
- }
4657
- }
4658
- }
4659
-
4660
- return spv;
4661
- }
4662
-
4663
- update() {
4664
- const swiper = this;
4665
- if (!swiper || swiper.destroyed) return;
4666
- const {
4667
- snapGrid,
4668
- params
4669
- } = swiper; // Breakpoints
4670
-
4671
- if (params.breakpoints) {
4672
- swiper.setBreakpoint();
4673
- }
4674
-
4675
- swiper.updateSize();
4676
- swiper.updateSlides();
4677
- swiper.updateProgress();
4678
- swiper.updateSlidesClasses();
4679
-
4680
- function setTranslate() {
4681
- const translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
4682
- const newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
4683
- swiper.setTranslate(newTranslate);
4684
- swiper.updateActiveIndex();
4685
- swiper.updateSlidesClasses();
4686
- }
4687
-
4688
- let translated;
4689
-
4690
- if (swiper.params.freeMode && swiper.params.freeMode.enabled) {
4691
- setTranslate();
4692
-
4693
- if (swiper.params.autoHeight) {
4694
- swiper.updateAutoHeight();
4695
- }
4696
- } else {
4697
- if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
4698
- translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
4699
- } else {
4700
- translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
4701
- }
4702
-
4703
- if (!translated) {
4704
- setTranslate();
4705
- }
4706
- }
4707
-
4708
- if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
4709
- swiper.checkOverflow();
4710
- }
4711
-
4712
- swiper.emit('update');
4713
- }
4714
-
4715
- changeDirection(newDirection, needUpdate) {
4716
- if (needUpdate === void 0) {
4717
- needUpdate = true;
4718
- }
4719
-
4720
- const swiper = this;
4721
- const currentDirection = swiper.params.direction;
4722
-
4723
- if (!newDirection) {
4724
- // eslint-disable-next-line
4725
- newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
4726
- }
4727
-
4728
- if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
4729
- return swiper;
4730
- }
4731
-
4732
- swiper.$el.removeClass(`${swiper.params.containerModifierClass}${currentDirection}`).addClass(`${swiper.params.containerModifierClass}${newDirection}`);
4733
- swiper.emitContainerClasses();
4734
- swiper.params.direction = newDirection;
4735
- swiper.slides.each(slideEl => {
4736
- if (newDirection === 'vertical') {
4737
- slideEl.style.width = '';
4738
- } else {
4739
- slideEl.style.height = '';
4740
- }
4741
- });
4742
- swiper.emit('changeDirection');
4743
- if (needUpdate) swiper.update();
4744
- return swiper;
4745
- }
4746
-
4747
- changeLanguageDirection(direction) {
4748
- const swiper = this;
4749
- if (swiper.rtl && direction === 'rtl' || !swiper.rtl && direction === 'ltr') return;
4750
- swiper.rtl = direction === 'rtl';
4751
- swiper.rtlTranslate = swiper.params.direction === 'horizontal' && swiper.rtl;
4752
-
4753
- if (swiper.rtl) {
4754
- swiper.$el.addClass(`${swiper.params.containerModifierClass}rtl`);
4755
- swiper.el.dir = 'rtl';
4756
- } else {
4757
- swiper.$el.removeClass(`${swiper.params.containerModifierClass}rtl`);
4758
- swiper.el.dir = 'ltr';
4759
- }
4760
-
4761
- swiper.update();
4762
- }
4763
-
4764
- mount(el) {
4765
- const swiper = this;
4766
- if (swiper.mounted) return true; // Find el
4767
-
4768
- const $el = $(el || swiper.params.el);
4769
- el = $el[0];
4770
-
4771
- if (!el) {
4772
- return false;
4773
- }
4774
-
4775
- el.swiper = swiper;
4776
-
4777
- const getWrapperSelector = () => {
4778
- return `.${(swiper.params.wrapperClass || '').trim().split(' ').join('.')}`;
4779
- };
4780
-
4781
- const getWrapper = () => {
4782
- if (el && el.shadowRoot && el.shadowRoot.querySelector) {
4783
- const res = $(el.shadowRoot.querySelector(getWrapperSelector())); // Children needs to return slot items
4784
-
4785
- res.children = options => $el.children(options);
4786
-
4787
- return res;
4788
- }
4789
-
4790
- if (!$el.children) {
4791
- return $($el).children(getWrapperSelector());
4792
- }
4793
-
4794
- return $el.children(getWrapperSelector());
4795
- }; // Find Wrapper
4796
-
4797
-
4798
- let $wrapperEl = getWrapper();
4799
-
4800
- if ($wrapperEl.length === 0 && swiper.params.createElements) {
4801
- const document = getDocument();
4802
- const wrapper = document.createElement('div');
4803
- $wrapperEl = $(wrapper);
4804
- wrapper.className = swiper.params.wrapperClass;
4805
- $el.append(wrapper);
4806
- $el.children(`.${swiper.params.slideClass}`).each(slideEl => {
4807
- $wrapperEl.append(slideEl);
4808
- });
4809
- }
4810
-
4811
- Object.assign(swiper, {
4812
- $el,
4813
- el,
4814
- $wrapperEl,
4815
- wrapperEl: $wrapperEl[0],
4816
- mounted: true,
4817
- // RTL
4818
- rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl',
4819
- rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'),
4820
- wrongRTL: $wrapperEl.css('display') === '-webkit-box'
4821
- });
4822
- return true;
4823
- }
4824
-
4825
- init(el) {
4826
- const swiper = this;
4827
- if (swiper.initialized) return swiper;
4828
- const mounted = swiper.mount(el);
4829
- if (mounted === false) return swiper;
4830
- swiper.emit('beforeInit'); // Set breakpoint
4831
-
4832
- if (swiper.params.breakpoints) {
4833
- swiper.setBreakpoint();
4834
- } // Add Classes
4835
-
4836
-
4837
- swiper.addClasses(); // Create loop
4838
-
4839
- if (swiper.params.loop) {
4840
- swiper.loopCreate();
4841
- } // Update size
4842
-
4843
-
4844
- swiper.updateSize(); // Update slides
4845
-
4846
- swiper.updateSlides();
4847
-
4848
- if (swiper.params.watchOverflow) {
4849
- swiper.checkOverflow();
4850
- } // Set Grab Cursor
4851
-
4852
-
4853
- if (swiper.params.grabCursor && swiper.enabled) {
4854
- swiper.setGrabCursor();
4855
- }
4856
-
4857
- if (swiper.params.preloadImages) {
4858
- swiper.preloadImages();
4859
- } // Slide To Initial Slide
4860
-
4861
-
4862
- if (swiper.params.loop) {
4863
- swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit, false, true);
4864
- } else {
4865
- swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit, false, true);
4866
- } // Attach events
4867
-
4868
-
4869
- swiper.attachEvents(); // Init Flag
4870
-
4871
- swiper.initialized = true; // Emit
4872
-
4873
- swiper.emit('init');
4874
- swiper.emit('afterInit');
4875
- return swiper;
4876
- }
4877
-
4878
- destroy(deleteInstance, cleanStyles) {
4879
- if (deleteInstance === void 0) {
4880
- deleteInstance = true;
4881
- }
4882
-
4883
- if (cleanStyles === void 0) {
4884
- cleanStyles = true;
4885
- }
4886
-
4887
- const swiper = this;
4888
- const {
4889
- params,
4890
- $el,
4891
- $wrapperEl,
4892
- slides
4893
- } = swiper;
4894
-
4895
- if (typeof swiper.params === 'undefined' || swiper.destroyed) {
4896
- return null;
4897
- }
4898
-
4899
- swiper.emit('beforeDestroy'); // Init Flag
4900
-
4901
- swiper.initialized = false; // Detach events
4902
-
4903
- swiper.detachEvents(); // Destroy loop
4904
-
4905
- if (params.loop) {
4906
- swiper.loopDestroy();
4907
- } // Cleanup styles
4908
-
4909
-
4910
- if (cleanStyles) {
4911
- swiper.removeClasses();
4912
- $el.removeAttr('style');
4913
- $wrapperEl.removeAttr('style');
4914
-
4915
- if (slides && slides.length) {
4916
- slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index');
4917
- }
4918
- }
4919
-
4920
- swiper.emit('destroy'); // Detach emitter events
4921
-
4922
- Object.keys(swiper.eventsListeners).forEach(eventName => {
4923
- swiper.off(eventName);
4924
- });
4925
-
4926
- if (deleteInstance !== false) {
4927
- swiper.$el[0].swiper = null;
4928
- deleteProps(swiper);
4929
- }
4930
-
4931
- swiper.destroyed = true;
4932
- return null;
4933
- }
4934
-
4935
- static extendDefaults(newDefaults) {
4936
- extend(extendedDefaults, newDefaults);
4937
- }
4938
-
4939
- static get extendedDefaults() {
4940
- return extendedDefaults;
4941
- }
4942
-
4943
- static get defaults() {
4944
- return defaults;
4945
- }
4946
-
4947
- static installModule(mod) {
4948
- if (!Swiper.prototype.__modules__) Swiper.prototype.__modules__ = [];
4949
- const modules = Swiper.prototype.__modules__;
4950
-
4951
- if (typeof mod === 'function' && modules.indexOf(mod) < 0) {
4952
- modules.push(mod);
4953
- }
4954
- }
4955
-
4956
- static use(module) {
4957
- if (Array.isArray(module)) {
4958
- module.forEach(m => Swiper.installModule(m));
4959
- return Swiper;
4960
- }
4961
-
4962
- Swiper.installModule(module);
4963
- return Swiper;
4964
- }
4965
-
4966
- }
4967
-
4968
- Object.keys(prototypes).forEach(prototypeGroup => {
4969
- Object.keys(prototypes[prototypeGroup]).forEach(protoMethod => {
4970
- Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
4971
- });
4972
- });
4973
- Swiper.use([Resize, Observer]);
4974
-
4975
- exports.$ = $;
4976
- exports.ArrowLeftIcon = ArrowLeftIcon;
4977
- exports.ArrowRightIcon = ArrowRightIcon;
4978
- exports.Swiper = Swiper;
4979
- exports.getDocument = getDocument;
4980
- exports.getWindow = getWindow;
4981
- exports.isObject = isObject;
4982
- exports.nextTick = nextTick;