@salla.sa/twilight-components 1.6.1 → 1.6.3

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