1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | (function (global, factory) {
|
14 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
15 | typeof define === 'function' && define.amd ? define(factory) :
|
16 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Swiper = factory());
|
17 | }(this, (function () { 'use strict';
|
18 |
|
19 | function _defineProperties(target, props) {
|
20 | for (var i = 0; i < props.length; i++) {
|
21 | var descriptor = props[i];
|
22 | descriptor.enumerable = descriptor.enumerable || false;
|
23 | descriptor.configurable = true;
|
24 | if ("value" in descriptor) descriptor.writable = true;
|
25 | Object.defineProperty(target, descriptor.key, descriptor);
|
26 | }
|
27 | }
|
28 |
|
29 | function _createClass(Constructor, protoProps, staticProps) {
|
30 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
31 | if (staticProps) _defineProperties(Constructor, staticProps);
|
32 | return Constructor;
|
33 | }
|
34 |
|
35 | function _extends() {
|
36 | _extends = Object.assign || function (target) {
|
37 | for (var i = 1; i < arguments.length; i++) {
|
38 | var source = arguments[i];
|
39 |
|
40 | for (var key in source) {
|
41 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
42 | target[key] = source[key];
|
43 | }
|
44 | }
|
45 | }
|
46 |
|
47 | return target;
|
48 | };
|
49 |
|
50 | return _extends.apply(this, arguments);
|
51 | }
|
52 |
|
53 | |
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | function isObject$1(obj) {
|
67 | return obj !== null && typeof obj === 'object' && 'constructor' in obj && obj.constructor === Object;
|
68 | }
|
69 |
|
70 | function extend$1(target, src) {
|
71 | if (target === void 0) {
|
72 | target = {};
|
73 | }
|
74 |
|
75 | if (src === void 0) {
|
76 | src = {};
|
77 | }
|
78 |
|
79 | Object.keys(src).forEach(function (key) {
|
80 | if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject$1(src[key]) && isObject$1(target[key]) && Object.keys(src[key]).length > 0) {
|
81 | extend$1(target[key], src[key]);
|
82 | }
|
83 | });
|
84 | }
|
85 |
|
86 | var ssrDocument = {
|
87 | body: {},
|
88 | addEventListener: function addEventListener() {},
|
89 | removeEventListener: function removeEventListener() {},
|
90 | activeElement: {
|
91 | blur: function blur() {},
|
92 | nodeName: ''
|
93 | },
|
94 | querySelector: function querySelector() {
|
95 | return null;
|
96 | },
|
97 | querySelectorAll: function querySelectorAll() {
|
98 | return [];
|
99 | },
|
100 | getElementById: function getElementById() {
|
101 | return null;
|
102 | },
|
103 | createEvent: function createEvent() {
|
104 | return {
|
105 | initEvent: function initEvent() {}
|
106 | };
|
107 | },
|
108 | createElement: function createElement() {
|
109 | return {
|
110 | children: [],
|
111 | childNodes: [],
|
112 | style: {},
|
113 | setAttribute: function setAttribute() {},
|
114 | getElementsByTagName: function getElementsByTagName() {
|
115 | return [];
|
116 | }
|
117 | };
|
118 | },
|
119 | createElementNS: function createElementNS() {
|
120 | return {};
|
121 | },
|
122 | importNode: function importNode() {
|
123 | return null;
|
124 | },
|
125 | location: {
|
126 | hash: '',
|
127 | host: '',
|
128 | hostname: '',
|
129 | href: '',
|
130 | origin: '',
|
131 | pathname: '',
|
132 | protocol: '',
|
133 | search: ''
|
134 | }
|
135 | };
|
136 |
|
137 | function getDocument() {
|
138 | var doc = typeof document !== 'undefined' ? document : {};
|
139 | extend$1(doc, ssrDocument);
|
140 | return doc;
|
141 | }
|
142 |
|
143 | var ssrWindow = {
|
144 | document: ssrDocument,
|
145 | navigator: {
|
146 | userAgent: ''
|
147 | },
|
148 | location: {
|
149 | hash: '',
|
150 | host: '',
|
151 | hostname: '',
|
152 | href: '',
|
153 | origin: '',
|
154 | pathname: '',
|
155 | protocol: '',
|
156 | search: ''
|
157 | },
|
158 | history: {
|
159 | replaceState: function replaceState() {},
|
160 | pushState: function pushState() {},
|
161 | go: function go() {},
|
162 | back: function back() {}
|
163 | },
|
164 | CustomEvent: function CustomEvent() {
|
165 | return this;
|
166 | },
|
167 | addEventListener: function addEventListener() {},
|
168 | removeEventListener: function removeEventListener() {},
|
169 | getComputedStyle: function getComputedStyle() {
|
170 | return {
|
171 | getPropertyValue: function getPropertyValue() {
|
172 | return '';
|
173 | }
|
174 | };
|
175 | },
|
176 | Image: function Image() {},
|
177 | Date: function Date() {},
|
178 | screen: {},
|
179 | setTimeout: function setTimeout() {},
|
180 | clearTimeout: function clearTimeout() {},
|
181 | matchMedia: function matchMedia() {
|
182 | return {};
|
183 | },
|
184 | requestAnimationFrame: function requestAnimationFrame(callback) {
|
185 | if (typeof setTimeout === 'undefined') {
|
186 | callback();
|
187 | return null;
|
188 | }
|
189 |
|
190 | return setTimeout(callback, 0);
|
191 | },
|
192 | cancelAnimationFrame: function cancelAnimationFrame(id) {
|
193 | if (typeof setTimeout === 'undefined') {
|
194 | return;
|
195 | }
|
196 |
|
197 | clearTimeout(id);
|
198 | }
|
199 | };
|
200 |
|
201 | function getWindow() {
|
202 | var win = typeof window !== 'undefined' ? window : {};
|
203 | extend$1(win, ssrWindow);
|
204 | return win;
|
205 | }
|
206 |
|
207 | |
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | function _inheritsLoose(subClass, superClass) {
|
220 | subClass.prototype = Object.create(superClass.prototype);
|
221 | subClass.prototype.constructor = subClass;
|
222 | subClass.__proto__ = superClass;
|
223 | }
|
224 |
|
225 | function _getPrototypeOf(o) {
|
226 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
227 | return o.__proto__ || Object.getPrototypeOf(o);
|
228 | };
|
229 | return _getPrototypeOf(o);
|
230 | }
|
231 |
|
232 | function _setPrototypeOf(o, p) {
|
233 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
234 | o.__proto__ = p;
|
235 | return o;
|
236 | };
|
237 |
|
238 | return _setPrototypeOf(o, p);
|
239 | }
|
240 |
|
241 | function _isNativeReflectConstruct() {
|
242 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
243 | if (Reflect.construct.sham) return false;
|
244 | if (typeof Proxy === "function") return true;
|
245 |
|
246 | try {
|
247 | Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
248 | return true;
|
249 | } catch (e) {
|
250 | return false;
|
251 | }
|
252 | }
|
253 |
|
254 | function _construct(Parent, args, Class) {
|
255 | if (_isNativeReflectConstruct()) {
|
256 | _construct = Reflect.construct;
|
257 | } else {
|
258 | _construct = function _construct(Parent, args, Class) {
|
259 | var a = [null];
|
260 | a.push.apply(a, args);
|
261 | var Constructor = Function.bind.apply(Parent, a);
|
262 | var instance = new Constructor();
|
263 | if (Class) _setPrototypeOf(instance, Class.prototype);
|
264 | return instance;
|
265 | };
|
266 | }
|
267 |
|
268 | return _construct.apply(null, arguments);
|
269 | }
|
270 |
|
271 | function _isNativeFunction(fn) {
|
272 | return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
273 | }
|
274 |
|
275 | function _wrapNativeSuper(Class) {
|
276 | var _cache = typeof Map === "function" ? new Map() : undefined;
|
277 |
|
278 | _wrapNativeSuper = function _wrapNativeSuper(Class) {
|
279 | if (Class === null || !_isNativeFunction(Class)) return Class;
|
280 |
|
281 | if (typeof Class !== "function") {
|
282 | throw new TypeError("Super expression must either be null or a function");
|
283 | }
|
284 |
|
285 | if (typeof _cache !== "undefined") {
|
286 | if (_cache.has(Class)) return _cache.get(Class);
|
287 |
|
288 | _cache.set(Class, Wrapper);
|
289 | }
|
290 |
|
291 | function Wrapper() {
|
292 | return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
293 | }
|
294 |
|
295 | Wrapper.prototype = Object.create(Class.prototype, {
|
296 | constructor: {
|
297 | value: Wrapper,
|
298 | enumerable: false,
|
299 | writable: true,
|
300 | configurable: true
|
301 | }
|
302 | });
|
303 | return _setPrototypeOf(Wrapper, Class);
|
304 | };
|
305 |
|
306 | return _wrapNativeSuper(Class);
|
307 | }
|
308 |
|
309 | function _assertThisInitialized(self) {
|
310 | if (self === void 0) {
|
311 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
312 | }
|
313 |
|
314 | return self;
|
315 | }
|
316 |
|
317 |
|
318 |
|
319 | function makeReactive(obj) {
|
320 | var proto = obj.__proto__;
|
321 | Object.defineProperty(obj, '__proto__', {
|
322 | get: function get() {
|
323 | return proto;
|
324 | },
|
325 | set: function set(value) {
|
326 | proto.__proto__ = value;
|
327 | }
|
328 | });
|
329 | }
|
330 |
|
331 | var Dom7 = function (_Array) {
|
332 | _inheritsLoose(Dom7, _Array);
|
333 |
|
334 | function Dom7(items) {
|
335 | var _this;
|
336 |
|
337 | _this = _Array.call.apply(_Array, [this].concat(items)) || this;
|
338 | makeReactive(_assertThisInitialized(_this));
|
339 | return _this;
|
340 | }
|
341 |
|
342 | return Dom7;
|
343 | }( _wrapNativeSuper(Array));
|
344 |
|
345 | function arrayFlat(arr) {
|
346 | if (arr === void 0) {
|
347 | arr = [];
|
348 | }
|
349 |
|
350 | var res = [];
|
351 | arr.forEach(function (el) {
|
352 | if (Array.isArray(el)) {
|
353 | res.push.apply(res, arrayFlat(el));
|
354 | } else {
|
355 | res.push(el);
|
356 | }
|
357 | });
|
358 | return res;
|
359 | }
|
360 |
|
361 | function arrayFilter(arr, callback) {
|
362 | return Array.prototype.filter.call(arr, callback);
|
363 | }
|
364 |
|
365 | function arrayUnique(arr) {
|
366 | var uniqueArray = [];
|
367 |
|
368 | for (var i = 0; i < arr.length; i += 1) {
|
369 | if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
|
370 | }
|
371 |
|
372 | return uniqueArray;
|
373 | }
|
374 |
|
375 | function qsa(selector, context) {
|
376 | if (typeof selector !== 'string') {
|
377 | return [selector];
|
378 | }
|
379 |
|
380 | var a = [];
|
381 | var res = context.querySelectorAll(selector);
|
382 |
|
383 | for (var i = 0; i < res.length; i += 1) {
|
384 | a.push(res[i]);
|
385 | }
|
386 |
|
387 | return a;
|
388 | }
|
389 |
|
390 | function $(selector, context) {
|
391 | var window = getWindow();
|
392 | var document = getDocument();
|
393 | var arr = [];
|
394 |
|
395 | if (!context && selector instanceof Dom7) {
|
396 | return selector;
|
397 | }
|
398 |
|
399 | if (!selector) {
|
400 | return new Dom7(arr);
|
401 | }
|
402 |
|
403 | if (typeof selector === 'string') {
|
404 | var html = selector.trim();
|
405 |
|
406 | if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
|
407 | var toCreate = 'div';
|
408 | if (html.indexOf('<li') === 0) toCreate = 'ul';
|
409 | if (html.indexOf('<tr') === 0) toCreate = 'tbody';
|
410 | if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
|
411 | if (html.indexOf('<tbody') === 0) toCreate = 'table';
|
412 | if (html.indexOf('<option') === 0) toCreate = 'select';
|
413 | var tempParent = document.createElement(toCreate);
|
414 | tempParent.innerHTML = html;
|
415 |
|
416 | for (var i = 0; i < tempParent.childNodes.length; i += 1) {
|
417 | arr.push(tempParent.childNodes[i]);
|
418 | }
|
419 | } else {
|
420 | arr = qsa(selector.trim(), context || document);
|
421 | }
|
422 |
|
423 | } else if (selector.nodeType || selector === window || selector === document) {
|
424 | arr.push(selector);
|
425 | } else if (Array.isArray(selector)) {
|
426 | if (selector instanceof Dom7) return selector;
|
427 | arr = selector;
|
428 | }
|
429 |
|
430 | return new Dom7(arrayUnique(arr));
|
431 | }
|
432 |
|
433 | $.fn = Dom7.prototype;
|
434 |
|
435 | function addClass() {
|
436 | for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
|
437 | classes[_key] = arguments[_key];
|
438 | }
|
439 |
|
440 | var classNames = arrayFlat(classes.map(function (c) {
|
441 | return c.split(' ');
|
442 | }));
|
443 | this.forEach(function (el) {
|
444 | var _el$classList;
|
445 |
|
446 | (_el$classList = el.classList).add.apply(_el$classList, classNames);
|
447 | });
|
448 | return this;
|
449 | }
|
450 |
|
451 | function removeClass() {
|
452 | for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
453 | classes[_key2] = arguments[_key2];
|
454 | }
|
455 |
|
456 | var classNames = arrayFlat(classes.map(function (c) {
|
457 | return c.split(' ');
|
458 | }));
|
459 | this.forEach(function (el) {
|
460 | var _el$classList2;
|
461 |
|
462 | (_el$classList2 = el.classList).remove.apply(_el$classList2, classNames);
|
463 | });
|
464 | return this;
|
465 | }
|
466 |
|
467 | function toggleClass() {
|
468 | for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
469 | classes[_key3] = arguments[_key3];
|
470 | }
|
471 |
|
472 | var classNames = arrayFlat(classes.map(function (c) {
|
473 | return c.split(' ');
|
474 | }));
|
475 | this.forEach(function (el) {
|
476 | classNames.forEach(function (className) {
|
477 | el.classList.toggle(className);
|
478 | });
|
479 | });
|
480 | }
|
481 |
|
482 | function hasClass() {
|
483 | for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
484 | classes[_key4] = arguments[_key4];
|
485 | }
|
486 |
|
487 | var classNames = arrayFlat(classes.map(function (c) {
|
488 | return c.split(' ');
|
489 | }));
|
490 | return arrayFilter(this, function (el) {
|
491 | return classNames.filter(function (className) {
|
492 | return el.classList.contains(className);
|
493 | }).length > 0;
|
494 | }).length > 0;
|
495 | }
|
496 |
|
497 | function attr(attrs, value) {
|
498 | if (arguments.length === 1 && typeof attrs === 'string') {
|
499 |
|
500 | if (this[0]) return this[0].getAttribute(attrs);
|
501 | return undefined;
|
502 | }
|
503 |
|
504 |
|
505 | for (var i = 0; i < this.length; i += 1) {
|
506 | if (arguments.length === 2) {
|
507 |
|
508 | this[i].setAttribute(attrs, value);
|
509 | } else {
|
510 |
|
511 | for (var attrName in attrs) {
|
512 | this[i][attrName] = attrs[attrName];
|
513 | this[i].setAttribute(attrName, attrs[attrName]);
|
514 | }
|
515 | }
|
516 | }
|
517 |
|
518 | return this;
|
519 | }
|
520 |
|
521 | function removeAttr(attr) {
|
522 | for (var i = 0; i < this.length; i += 1) {
|
523 | this[i].removeAttribute(attr);
|
524 | }
|
525 |
|
526 | return this;
|
527 | }
|
528 |
|
529 | function transform(transform) {
|
530 | for (var i = 0; i < this.length; i += 1) {
|
531 | this[i].style.transform = transform;
|
532 | }
|
533 |
|
534 | return this;
|
535 | }
|
536 |
|
537 | function transition$1(duration) {
|
538 | for (var i = 0; i < this.length; i += 1) {
|
539 | this[i].style.transitionDuration = typeof duration !== 'string' ? duration + "ms" : duration;
|
540 | }
|
541 |
|
542 | return this;
|
543 | }
|
544 |
|
545 | function on() {
|
546 | for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
547 | args[_key5] = arguments[_key5];
|
548 | }
|
549 |
|
550 | var eventType = args[0],
|
551 | targetSelector = args[1],
|
552 | listener = args[2],
|
553 | capture = args[3];
|
554 |
|
555 | if (typeof args[1] === 'function') {
|
556 | eventType = args[0];
|
557 | listener = args[1];
|
558 | capture = args[2];
|
559 | targetSelector = undefined;
|
560 | }
|
561 |
|
562 | if (!capture) capture = false;
|
563 |
|
564 | function handleLiveEvent(e) {
|
565 | var target = e.target;
|
566 | if (!target) return;
|
567 | var eventData = e.target.dom7EventData || [];
|
568 |
|
569 | if (eventData.indexOf(e) < 0) {
|
570 | eventData.unshift(e);
|
571 | }
|
572 |
|
573 | if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
|
574 | var _parents = $(target).parents();
|
575 |
|
576 |
|
577 | for (var k = 0; k < _parents.length; k += 1) {
|
578 | if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData);
|
579 | }
|
580 | }
|
581 | }
|
582 |
|
583 | function handleEvent(e) {
|
584 | var eventData = e && e.target ? e.target.dom7EventData || [] : [];
|
585 |
|
586 | if (eventData.indexOf(e) < 0) {
|
587 | eventData.unshift(e);
|
588 | }
|
589 |
|
590 | listener.apply(this, eventData);
|
591 | }
|
592 |
|
593 | var events = eventType.split(' ');
|
594 | var j;
|
595 |
|
596 | for (var i = 0; i < this.length; i += 1) {
|
597 | var el = this[i];
|
598 |
|
599 | if (!targetSelector) {
|
600 | for (j = 0; j < events.length; j += 1) {
|
601 | var event = events[j];
|
602 | if (!el.dom7Listeners) el.dom7Listeners = {};
|
603 | if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
|
604 | el.dom7Listeners[event].push({
|
605 | listener: listener,
|
606 | proxyListener: handleEvent
|
607 | });
|
608 | el.addEventListener(event, handleEvent, capture);
|
609 | }
|
610 | } else {
|
611 |
|
612 | for (j = 0; j < events.length; j += 1) {
|
613 | var _event = events[j];
|
614 | if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
|
615 | if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = [];
|
616 |
|
617 | el.dom7LiveListeners[_event].push({
|
618 | listener: listener,
|
619 | proxyListener: handleLiveEvent
|
620 | });
|
621 |
|
622 | el.addEventListener(_event, handleLiveEvent, capture);
|
623 | }
|
624 | }
|
625 | }
|
626 |
|
627 | return this;
|
628 | }
|
629 |
|
630 | function off() {
|
631 | for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
632 | args[_key6] = arguments[_key6];
|
633 | }
|
634 |
|
635 | var eventType = args[0],
|
636 | targetSelector = args[1],
|
637 | listener = args[2],
|
638 | capture = args[3];
|
639 |
|
640 | if (typeof args[1] === 'function') {
|
641 | eventType = args[0];
|
642 | listener = args[1];
|
643 | capture = args[2];
|
644 | targetSelector = undefined;
|
645 | }
|
646 |
|
647 | if (!capture) capture = false;
|
648 | var events = eventType.split(' ');
|
649 |
|
650 | for (var i = 0; i < events.length; i += 1) {
|
651 | var event = events[i];
|
652 |
|
653 | for (var j = 0; j < this.length; j += 1) {
|
654 | var el = this[j];
|
655 | var handlers = void 0;
|
656 |
|
657 | if (!targetSelector && el.dom7Listeners) {
|
658 | handlers = el.dom7Listeners[event];
|
659 | } else if (targetSelector && el.dom7LiveListeners) {
|
660 | handlers = el.dom7LiveListeners[event];
|
661 | }
|
662 |
|
663 | if (handlers && handlers.length) {
|
664 | for (var k = handlers.length - 1; k >= 0; k -= 1) {
|
665 | var handler = handlers[k];
|
666 |
|
667 | if (listener && handler.listener === listener) {
|
668 | el.removeEventListener(event, handler.proxyListener, capture);
|
669 | handlers.splice(k, 1);
|
670 | } else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
|
671 | el.removeEventListener(event, handler.proxyListener, capture);
|
672 | handlers.splice(k, 1);
|
673 | } else if (!listener) {
|
674 | el.removeEventListener(event, handler.proxyListener, capture);
|
675 | handlers.splice(k, 1);
|
676 | }
|
677 | }
|
678 | }
|
679 | }
|
680 | }
|
681 |
|
682 | return this;
|
683 | }
|
684 |
|
685 | function trigger() {
|
686 | var window = getWindow();
|
687 |
|
688 | for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
|
689 | args[_key9] = arguments[_key9];
|
690 | }
|
691 |
|
692 | var events = args[0].split(' ');
|
693 | var eventData = args[1];
|
694 |
|
695 | for (var i = 0; i < events.length; i += 1) {
|
696 | var event = events[i];
|
697 |
|
698 | for (var j = 0; j < this.length; j += 1) {
|
699 | var el = this[j];
|
700 |
|
701 | if (window.CustomEvent) {
|
702 | var evt = new window.CustomEvent(event, {
|
703 | detail: eventData,
|
704 | bubbles: true,
|
705 | cancelable: true
|
706 | });
|
707 | el.dom7EventData = args.filter(function (data, dataIndex) {
|
708 | return dataIndex > 0;
|
709 | });
|
710 | el.dispatchEvent(evt);
|
711 | el.dom7EventData = [];
|
712 | delete el.dom7EventData;
|
713 | }
|
714 | }
|
715 | }
|
716 |
|
717 | return this;
|
718 | }
|
719 |
|
720 | function transitionEnd$1(callback) {
|
721 | var dom = this;
|
722 |
|
723 | function fireCallBack(e) {
|
724 | if (e.target !== this) return;
|
725 | callback.call(this, e);
|
726 | dom.off('transitionend', fireCallBack);
|
727 | }
|
728 |
|
729 | if (callback) {
|
730 | dom.on('transitionend', fireCallBack);
|
731 | }
|
732 |
|
733 | return this;
|
734 | }
|
735 |
|
736 | function outerWidth(includeMargins) {
|
737 | if (this.length > 0) {
|
738 | if (includeMargins) {
|
739 | var _styles = this.styles();
|
740 |
|
741 | return this[0].offsetWidth + parseFloat(_styles.getPropertyValue('margin-right')) + parseFloat(_styles.getPropertyValue('margin-left'));
|
742 | }
|
743 |
|
744 | return this[0].offsetWidth;
|
745 | }
|
746 |
|
747 | return null;
|
748 | }
|
749 |
|
750 | function outerHeight(includeMargins) {
|
751 | if (this.length > 0) {
|
752 | if (includeMargins) {
|
753 | var _styles2 = this.styles();
|
754 |
|
755 | return this[0].offsetHeight + parseFloat(_styles2.getPropertyValue('margin-top')) + parseFloat(_styles2.getPropertyValue('margin-bottom'));
|
756 | }
|
757 |
|
758 | return this[0].offsetHeight;
|
759 | }
|
760 |
|
761 | return null;
|
762 | }
|
763 |
|
764 | function offset() {
|
765 | if (this.length > 0) {
|
766 | var window = getWindow();
|
767 | var document = getDocument();
|
768 | var el = this[0];
|
769 | var box = el.getBoundingClientRect();
|
770 | var body = document.body;
|
771 | var clientTop = el.clientTop || body.clientTop || 0;
|
772 | var clientLeft = el.clientLeft || body.clientLeft || 0;
|
773 | var scrollTop = el === window ? window.scrollY : el.scrollTop;
|
774 | var scrollLeft = el === window ? window.scrollX : el.scrollLeft;
|
775 | return {
|
776 | top: box.top + scrollTop - clientTop,
|
777 | left: box.left + scrollLeft - clientLeft
|
778 | };
|
779 | }
|
780 |
|
781 | return null;
|
782 | }
|
783 |
|
784 | function styles() {
|
785 | var window = getWindow();
|
786 | if (this[0]) return window.getComputedStyle(this[0], null);
|
787 | return {};
|
788 | }
|
789 |
|
790 | function css(props, value) {
|
791 | var window = getWindow();
|
792 | var i;
|
793 |
|
794 | if (arguments.length === 1) {
|
795 | if (typeof props === 'string') {
|
796 |
|
797 | if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
|
798 | } else {
|
799 |
|
800 | for (i = 0; i < this.length; i += 1) {
|
801 | for (var _prop in props) {
|
802 | this[i].style[_prop] = props[_prop];
|
803 | }
|
804 | }
|
805 |
|
806 | return this;
|
807 | }
|
808 | }
|
809 |
|
810 | if (arguments.length === 2 && typeof props === 'string') {
|
811 |
|
812 | for (i = 0; i < this.length; i += 1) {
|
813 | this[i].style[props] = value;
|
814 | }
|
815 |
|
816 | return this;
|
817 | }
|
818 |
|
819 | return this;
|
820 | }
|
821 |
|
822 | function each(callback) {
|
823 | if (!callback) return this;
|
824 | this.forEach(function (el, index) {
|
825 | callback.apply(el, [el, index]);
|
826 | });
|
827 | return this;
|
828 | }
|
829 |
|
830 | function filter(callback) {
|
831 | var result = arrayFilter(this, callback);
|
832 | return $(result);
|
833 | }
|
834 |
|
835 | function html(html) {
|
836 | if (typeof html === 'undefined') {
|
837 | return this[0] ? this[0].innerHTML : null;
|
838 | }
|
839 |
|
840 | for (var i = 0; i < this.length; i += 1) {
|
841 | this[i].innerHTML = html;
|
842 | }
|
843 |
|
844 | return this;
|
845 | }
|
846 |
|
847 | function text(text) {
|
848 | if (typeof text === 'undefined') {
|
849 | return this[0] ? this[0].textContent.trim() : null;
|
850 | }
|
851 |
|
852 | for (var i = 0; i < this.length; i += 1) {
|
853 | this[i].textContent = text;
|
854 | }
|
855 |
|
856 | return this;
|
857 | }
|
858 |
|
859 | function is(selector) {
|
860 | var window = getWindow();
|
861 | var document = getDocument();
|
862 | var el = this[0];
|
863 | var compareWith;
|
864 | var i;
|
865 | if (!el || typeof selector === 'undefined') return false;
|
866 |
|
867 | if (typeof selector === 'string') {
|
868 | if (el.matches) return el.matches(selector);
|
869 | if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
|
870 | if (el.msMatchesSelector) return el.msMatchesSelector(selector);
|
871 | compareWith = $(selector);
|
872 |
|
873 | for (i = 0; i < compareWith.length; i += 1) {
|
874 | if (compareWith[i] === el) return true;
|
875 | }
|
876 |
|
877 | return false;
|
878 | }
|
879 |
|
880 | if (selector === document) {
|
881 | return el === document;
|
882 | }
|
883 |
|
884 | if (selector === window) {
|
885 | return el === window;
|
886 | }
|
887 |
|
888 | if (selector.nodeType || selector instanceof Dom7) {
|
889 | compareWith = selector.nodeType ? [selector] : selector;
|
890 |
|
891 | for (i = 0; i < compareWith.length; i += 1) {
|
892 | if (compareWith[i] === el) return true;
|
893 | }
|
894 |
|
895 | return false;
|
896 | }
|
897 |
|
898 | return false;
|
899 | }
|
900 |
|
901 | function index() {
|
902 | var child = this[0];
|
903 | var i;
|
904 |
|
905 | if (child) {
|
906 | i = 0;
|
907 |
|
908 | while ((child = child.previousSibling) !== null) {
|
909 | if (child.nodeType === 1) i += 1;
|
910 | }
|
911 |
|
912 | return i;
|
913 | }
|
914 |
|
915 | return undefined;
|
916 | }
|
917 |
|
918 | function eq(index) {
|
919 | if (typeof index === 'undefined') return this;
|
920 | var length = this.length;
|
921 |
|
922 | if (index > length - 1) {
|
923 | return $([]);
|
924 | }
|
925 |
|
926 | if (index < 0) {
|
927 | var returnIndex = length + index;
|
928 | if (returnIndex < 0) return $([]);
|
929 | return $([this[returnIndex]]);
|
930 | }
|
931 |
|
932 | return $([this[index]]);
|
933 | }
|
934 |
|
935 | function append() {
|
936 | var newChild;
|
937 | var document = getDocument();
|
938 |
|
939 | for (var k = 0; k < arguments.length; k += 1) {
|
940 | newChild = k < 0 || arguments.length <= k ? undefined : arguments[k];
|
941 |
|
942 | for (var i = 0; i < this.length; i += 1) {
|
943 | if (typeof newChild === 'string') {
|
944 | var tempDiv = document.createElement('div');
|
945 | tempDiv.innerHTML = newChild;
|
946 |
|
947 | while (tempDiv.firstChild) {
|
948 | this[i].appendChild(tempDiv.firstChild);
|
949 | }
|
950 | } else if (newChild instanceof Dom7) {
|
951 | for (var j = 0; j < newChild.length; j += 1) {
|
952 | this[i].appendChild(newChild[j]);
|
953 | }
|
954 | } else {
|
955 | this[i].appendChild(newChild);
|
956 | }
|
957 | }
|
958 | }
|
959 |
|
960 | return this;
|
961 | }
|
962 |
|
963 | function prepend(newChild) {
|
964 | var document = getDocument();
|
965 | var i;
|
966 | var j;
|
967 |
|
968 | for (i = 0; i < this.length; i += 1) {
|
969 | if (typeof newChild === 'string') {
|
970 | var tempDiv = document.createElement('div');
|
971 | tempDiv.innerHTML = newChild;
|
972 |
|
973 | for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) {
|
974 | this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]);
|
975 | }
|
976 | } else if (newChild instanceof Dom7) {
|
977 | for (j = 0; j < newChild.length; j += 1) {
|
978 | this[i].insertBefore(newChild[j], this[i].childNodes[0]);
|
979 | }
|
980 | } else {
|
981 | this[i].insertBefore(newChild, this[i].childNodes[0]);
|
982 | }
|
983 | }
|
984 |
|
985 | return this;
|
986 | }
|
987 |
|
988 | function next(selector) {
|
989 | if (this.length > 0) {
|
990 | if (selector) {
|
991 | if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) {
|
992 | return $([this[0].nextElementSibling]);
|
993 | }
|
994 |
|
995 | return $([]);
|
996 | }
|
997 |
|
998 | if (this[0].nextElementSibling) return $([this[0].nextElementSibling]);
|
999 | return $([]);
|
1000 | }
|
1001 |
|
1002 | return $([]);
|
1003 | }
|
1004 |
|
1005 | function nextAll(selector) {
|
1006 | var nextEls = [];
|
1007 | var el = this[0];
|
1008 | if (!el) return $([]);
|
1009 |
|
1010 | while (el.nextElementSibling) {
|
1011 | var _next = el.nextElementSibling;
|
1012 |
|
1013 | if (selector) {
|
1014 | if ($(_next).is(selector)) nextEls.push(_next);
|
1015 | } else nextEls.push(_next);
|
1016 |
|
1017 | el = _next;
|
1018 | }
|
1019 |
|
1020 | return $(nextEls);
|
1021 | }
|
1022 |
|
1023 | function prev(selector) {
|
1024 | if (this.length > 0) {
|
1025 | var el = this[0];
|
1026 |
|
1027 | if (selector) {
|
1028 | if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) {
|
1029 | return $([el.previousElementSibling]);
|
1030 | }
|
1031 |
|
1032 | return $([]);
|
1033 | }
|
1034 |
|
1035 | if (el.previousElementSibling) return $([el.previousElementSibling]);
|
1036 | return $([]);
|
1037 | }
|
1038 |
|
1039 | return $([]);
|
1040 | }
|
1041 |
|
1042 | function prevAll(selector) {
|
1043 | var prevEls = [];
|
1044 | var el = this[0];
|
1045 | if (!el) return $([]);
|
1046 |
|
1047 | while (el.previousElementSibling) {
|
1048 | var _prev = el.previousElementSibling;
|
1049 |
|
1050 | if (selector) {
|
1051 | if ($(_prev).is(selector)) prevEls.push(_prev);
|
1052 | } else prevEls.push(_prev);
|
1053 |
|
1054 | el = _prev;
|
1055 | }
|
1056 |
|
1057 | return $(prevEls);
|
1058 | }
|
1059 |
|
1060 | function parent(selector) {
|
1061 | var parents = [];
|
1062 |
|
1063 | for (var i = 0; i < this.length; i += 1) {
|
1064 | if (this[i].parentNode !== null) {
|
1065 | if (selector) {
|
1066 | if ($(this[i].parentNode).is(selector)) parents.push(this[i].parentNode);
|
1067 | } else {
|
1068 | parents.push(this[i].parentNode);
|
1069 | }
|
1070 | }
|
1071 | }
|
1072 |
|
1073 | return $(parents);
|
1074 | }
|
1075 |
|
1076 | function parents(selector) {
|
1077 | var parents = [];
|
1078 |
|
1079 | for (var i = 0; i < this.length; i += 1) {
|
1080 | var _parent = this[i].parentNode;
|
1081 |
|
1082 | while (_parent) {
|
1083 | if (selector) {
|
1084 | if ($(_parent).is(selector)) parents.push(_parent);
|
1085 | } else {
|
1086 | parents.push(_parent);
|
1087 | }
|
1088 |
|
1089 | _parent = _parent.parentNode;
|
1090 | }
|
1091 | }
|
1092 |
|
1093 | return $(parents);
|
1094 | }
|
1095 |
|
1096 | function closest(selector) {
|
1097 | var closest = this;
|
1098 |
|
1099 | if (typeof selector === 'undefined') {
|
1100 | return $([]);
|
1101 | }
|
1102 |
|
1103 | if (!closest.is(selector)) {
|
1104 | closest = closest.parents(selector).eq(0);
|
1105 | }
|
1106 |
|
1107 | return closest;
|
1108 | }
|
1109 |
|
1110 | function find(selector) {
|
1111 | var foundElements = [];
|
1112 |
|
1113 | for (var i = 0; i < this.length; i += 1) {
|
1114 | try {
|
1115 | var found = this[i].querySelectorAll(selector);
|
1116 | } catch (err) {
|
1117 | console.log(selector);
|
1118 | }
|
1119 |
|
1120 | for (var j = 0; j < found.length; j += 1) {
|
1121 | foundElements.push(found[j]);
|
1122 | }
|
1123 | }
|
1124 |
|
1125 | return $(foundElements);
|
1126 | }
|
1127 |
|
1128 | function children(selector) {
|
1129 | var children = [];
|
1130 |
|
1131 | for (var i = 0; i < this.length; i += 1) {
|
1132 | var childNodes = this[i].children;
|
1133 |
|
1134 | for (var j = 0; j < childNodes.length; j += 1) {
|
1135 | if (!selector || $(childNodes[j]).is(selector)) {
|
1136 | children.push(childNodes[j]);
|
1137 | }
|
1138 | }
|
1139 | }
|
1140 |
|
1141 | return $(children);
|
1142 | }
|
1143 |
|
1144 | function remove() {
|
1145 | for (var i = 0; i < this.length; i += 1) {
|
1146 | if (this[i].parentNode) this[i].parentNode.removeChild(this[i]);
|
1147 | }
|
1148 |
|
1149 | return this;
|
1150 | }
|
1151 |
|
1152 | var Methods = {
|
1153 | addClass: addClass,
|
1154 | removeClass: removeClass,
|
1155 | hasClass: hasClass,
|
1156 | toggleClass: toggleClass,
|
1157 | attr: attr,
|
1158 | removeAttr: removeAttr,
|
1159 | transform: transform,
|
1160 | transition: transition$1,
|
1161 | on: on,
|
1162 | off: off,
|
1163 | trigger: trigger,
|
1164 | transitionEnd: transitionEnd$1,
|
1165 | outerWidth: outerWidth,
|
1166 | outerHeight: outerHeight,
|
1167 | styles: styles,
|
1168 | offset: offset,
|
1169 | css: css,
|
1170 | each: each,
|
1171 | html: html,
|
1172 | text: text,
|
1173 | is: is,
|
1174 | index: index,
|
1175 | eq: eq,
|
1176 | append: append,
|
1177 | prepend: prepend,
|
1178 | next: next,
|
1179 | nextAll: nextAll,
|
1180 | prev: prev,
|
1181 | prevAll: prevAll,
|
1182 | parent: parent,
|
1183 | parents: parents,
|
1184 | closest: closest,
|
1185 | find: find,
|
1186 | children: children,
|
1187 | filter: filter,
|
1188 | remove: remove
|
1189 | };
|
1190 | Object.keys(Methods).forEach(function (methodName) {
|
1191 | Object.defineProperty($.fn, methodName, {
|
1192 | value: Methods[methodName],
|
1193 | writable: true
|
1194 | });
|
1195 | });
|
1196 |
|
1197 | function deleteProps(obj) {
|
1198 | var object = obj;
|
1199 | Object.keys(object).forEach(function (key) {
|
1200 | try {
|
1201 | object[key] = null;
|
1202 | } catch (e) {
|
1203 | }
|
1204 |
|
1205 | try {
|
1206 | delete object[key];
|
1207 | } catch (e) {
|
1208 | }
|
1209 | });
|
1210 | }
|
1211 |
|
1212 | function nextTick(callback, delay) {
|
1213 | if (delay === void 0) {
|
1214 | delay = 0;
|
1215 | }
|
1216 |
|
1217 | return setTimeout(callback, delay);
|
1218 | }
|
1219 |
|
1220 | function now() {
|
1221 | return Date.now();
|
1222 | }
|
1223 |
|
1224 | function getComputedStyle$1(el) {
|
1225 | var window = getWindow();
|
1226 | var style;
|
1227 |
|
1228 | if (window.getComputedStyle) {
|
1229 | style = window.getComputedStyle(el, null);
|
1230 | }
|
1231 |
|
1232 | if (!style && el.currentStyle) {
|
1233 | style = el.currentStyle;
|
1234 | }
|
1235 |
|
1236 | if (!style) {
|
1237 | style = el.style;
|
1238 | }
|
1239 |
|
1240 | return style;
|
1241 | }
|
1242 |
|
1243 | function getTranslate(el, axis) {
|
1244 | if (axis === void 0) {
|
1245 | axis = 'x';
|
1246 | }
|
1247 |
|
1248 | var window = getWindow();
|
1249 | var matrix;
|
1250 | var curTransform;
|
1251 | var transformMatrix;
|
1252 | var curStyle = getComputedStyle$1(el);
|
1253 |
|
1254 | if (window.WebKitCSSMatrix) {
|
1255 | curTransform = curStyle.transform || curStyle.webkitTransform;
|
1256 |
|
1257 | if (curTransform.split(',').length > 6) {
|
1258 | curTransform = curTransform.split(', ').map(function (a) {
|
1259 | return a.replace(',', '.');
|
1260 | }).join(', ');
|
1261 | }
|
1262 |
|
1263 |
|
1264 |
|
1265 | transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
|
1266 | } else {
|
1267 | transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
|
1268 | matrix = transformMatrix.toString().split(',');
|
1269 | }
|
1270 |
|
1271 | if (axis === 'x') {
|
1272 |
|
1273 | if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41;
|
1274 | else if (matrix.length === 16) curTransform = parseFloat(matrix[12]);
|
1275 | else curTransform = parseFloat(matrix[4]);
|
1276 | }
|
1277 |
|
1278 | if (axis === 'y') {
|
1279 |
|
1280 | if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42;
|
1281 | else if (matrix.length === 16) curTransform = parseFloat(matrix[13]);
|
1282 | else curTransform = parseFloat(matrix[5]);
|
1283 | }
|
1284 |
|
1285 | return curTransform || 0;
|
1286 | }
|
1287 |
|
1288 | function isObject(o) {
|
1289 | return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
1290 | }
|
1291 |
|
1292 | function extend() {
|
1293 | var to = Object(arguments.length <= 0 ? undefined : arguments[0]);
|
1294 | var noExtend = ['__proto__', 'constructor', 'prototype'];
|
1295 |
|
1296 | for (var i = 1; i < arguments.length; i += 1) {
|
1297 | var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
1298 |
|
1299 | if (nextSource !== undefined && nextSource !== null) {
|
1300 | var keysArray = Object.keys(Object(nextSource)).filter(function (key) {
|
1301 | return noExtend.indexOf(key) < 0;
|
1302 | });
|
1303 |
|
1304 | for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) {
|
1305 | var nextKey = keysArray[nextIndex];
|
1306 | var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
1307 |
|
1308 | if (desc !== undefined && desc.enumerable) {
|
1309 | if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
|
1310 | if (nextSource[nextKey].__swiper__) {
|
1311 | to[nextKey] = nextSource[nextKey];
|
1312 | } else {
|
1313 | extend(to[nextKey], nextSource[nextKey]);
|
1314 | }
|
1315 | } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) {
|
1316 | to[nextKey] = {};
|
1317 |
|
1318 | if (nextSource[nextKey].__swiper__) {
|
1319 | to[nextKey] = nextSource[nextKey];
|
1320 | } else {
|
1321 | extend(to[nextKey], nextSource[nextKey]);
|
1322 | }
|
1323 | } else {
|
1324 | to[nextKey] = nextSource[nextKey];
|
1325 | }
|
1326 | }
|
1327 | }
|
1328 | }
|
1329 | }
|
1330 |
|
1331 | return to;
|
1332 | }
|
1333 |
|
1334 | function bindModuleMethods(instance, obj) {
|
1335 | Object.keys(obj).forEach(function (key) {
|
1336 | if (isObject(obj[key])) {
|
1337 | Object.keys(obj[key]).forEach(function (subKey) {
|
1338 | if (typeof obj[key][subKey] === 'function') {
|
1339 | obj[key][subKey] = obj[key][subKey].bind(instance);
|
1340 | }
|
1341 | });
|
1342 | }
|
1343 |
|
1344 | instance[key] = obj[key];
|
1345 | });
|
1346 | }
|
1347 |
|
1348 | function classesToSelector(classes) {
|
1349 | if (classes === void 0) {
|
1350 | classes = '';
|
1351 | }
|
1352 |
|
1353 | return "." + classes.trim().replace(/([\.:\/])/g, '\\$1')
|
1354 | .replace(/ /g, '.');
|
1355 | }
|
1356 |
|
1357 | var support;
|
1358 |
|
1359 | function calcSupport() {
|
1360 | var window = getWindow();
|
1361 | var document = getDocument();
|
1362 | return {
|
1363 | touch: !!('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch),
|
1364 | pointerEvents: !!window.PointerEvent && 'maxTouchPoints' in window.navigator && window.navigator.maxTouchPoints >= 0,
|
1365 | observer: function checkObserver() {
|
1366 | return 'MutationObserver' in window || 'WebkitMutationObserver' in window;
|
1367 | }(),
|
1368 | passiveListener: function checkPassiveListener() {
|
1369 | var supportsPassive = false;
|
1370 |
|
1371 | try {
|
1372 | var opts = Object.defineProperty({}, 'passive', {
|
1373 |
|
1374 | get: function get() {
|
1375 | supportsPassive = true;
|
1376 | }
|
1377 | });
|
1378 | window.addEventListener('testPassiveListener', null, opts);
|
1379 | } catch (e) {
|
1380 | }
|
1381 |
|
1382 | return supportsPassive;
|
1383 | }(),
|
1384 | gestures: function checkGestures() {
|
1385 | return 'ongesturestart' in window;
|
1386 | }()
|
1387 | };
|
1388 | }
|
1389 |
|
1390 | function getSupport() {
|
1391 | if (!support) {
|
1392 | support = calcSupport();
|
1393 | }
|
1394 |
|
1395 | return support;
|
1396 | }
|
1397 |
|
1398 | var device;
|
1399 |
|
1400 | function calcDevice(_temp) {
|
1401 | var _ref = _temp === void 0 ? {} : _temp,
|
1402 | userAgent = _ref.userAgent;
|
1403 |
|
1404 | var support = getSupport();
|
1405 | var window = getWindow();
|
1406 | var platform = window.navigator.platform;
|
1407 | var ua = userAgent || window.navigator.userAgent;
|
1408 | var device = {
|
1409 | ios: false,
|
1410 | android: false
|
1411 | };
|
1412 | var screenWidth = window.screen.width;
|
1413 | var screenHeight = window.screen.height;
|
1414 | var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
|
1415 |
|
1416 | var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
|
1417 | var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
|
1418 | var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/);
|
1419 | var windows = platform === 'Win32';
|
1420 | var macos = platform === 'MacIntel';
|
1421 |
|
1422 | var iPadScreens = ['1024x1366', '1366x1024', '834x1194', '1194x834', '834x1112', '1112x834', '768x1024', '1024x768', '820x1180', '1180x820', '810x1080', '1080x810'];
|
1423 |
|
1424 | if (!ipad && macos && support.touch && iPadScreens.indexOf(screenWidth + "x" + screenHeight) >= 0) {
|
1425 | ipad = ua.match(/(Version)\/([\d.]+)/);
|
1426 | if (!ipad) ipad = [0, 1, '13_0_0'];
|
1427 | macos = false;
|
1428 | }
|
1429 |
|
1430 |
|
1431 | if (android && !windows) {
|
1432 | device.os = 'android';
|
1433 | device.android = true;
|
1434 | }
|
1435 |
|
1436 | if (ipad || iphone || ipod) {
|
1437 | device.os = 'ios';
|
1438 | device.ios = true;
|
1439 | }
|
1440 |
|
1441 |
|
1442 | return device;
|
1443 | }
|
1444 |
|
1445 | function getDevice(overrides) {
|
1446 | if (overrides === void 0) {
|
1447 | overrides = {};
|
1448 | }
|
1449 |
|
1450 | if (!device) {
|
1451 | device = calcDevice(overrides);
|
1452 | }
|
1453 |
|
1454 | return device;
|
1455 | }
|
1456 |
|
1457 | var browser;
|
1458 |
|
1459 | function calcBrowser() {
|
1460 | var window = getWindow();
|
1461 |
|
1462 | function isSafari() {
|
1463 | var ua = window.navigator.userAgent.toLowerCase();
|
1464 | return ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0;
|
1465 | }
|
1466 |
|
1467 | return {
|
1468 | isEdge: !!window.navigator.userAgent.match(/Edge/g),
|
1469 | isSafari: isSafari(),
|
1470 | isWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(window.navigator.userAgent)
|
1471 | };
|
1472 | }
|
1473 |
|
1474 | function getBrowser() {
|
1475 | if (!browser) {
|
1476 | browser = calcBrowser();
|
1477 | }
|
1478 |
|
1479 | return browser;
|
1480 | }
|
1481 |
|
1482 | var supportsResizeObserver = function supportsResizeObserver() {
|
1483 | var window = getWindow();
|
1484 | return typeof window.ResizeObserver !== 'undefined';
|
1485 | };
|
1486 |
|
1487 | var Resize = {
|
1488 | name: 'resize',
|
1489 | create: function create() {
|
1490 | var swiper = this;
|
1491 | extend(swiper, {
|
1492 | resize: {
|
1493 | observer: null,
|
1494 | createObserver: function createObserver() {
|
1495 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
1496 | swiper.resize.observer = new ResizeObserver(function (entries) {
|
1497 | var width = swiper.width,
|
1498 | height = swiper.height;
|
1499 | var newWidth = width;
|
1500 | var newHeight = height;
|
1501 | entries.forEach(function (_ref) {
|
1502 | var contentBoxSize = _ref.contentBoxSize,
|
1503 | contentRect = _ref.contentRect,
|
1504 | target = _ref.target;
|
1505 | if (target && target !== swiper.el) return;
|
1506 | newWidth = contentRect ? contentRect.width : (contentBoxSize[0] || contentBoxSize).inlineSize;
|
1507 | newHeight = contentRect ? contentRect.height : (contentBoxSize[0] || contentBoxSize).blockSize;
|
1508 | });
|
1509 |
|
1510 | if (newWidth !== width || newHeight !== height) {
|
1511 | swiper.resize.resizeHandler();
|
1512 | }
|
1513 | });
|
1514 | swiper.resize.observer.observe(swiper.el);
|
1515 | },
|
1516 | removeObserver: function removeObserver() {
|
1517 | if (swiper.resize.observer && swiper.resize.observer.unobserve && swiper.el) {
|
1518 | swiper.resize.observer.unobserve(swiper.el);
|
1519 | swiper.resize.observer = null;
|
1520 | }
|
1521 | },
|
1522 | resizeHandler: function resizeHandler() {
|
1523 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
1524 | swiper.emit('beforeResize');
|
1525 | swiper.emit('resize');
|
1526 | },
|
1527 | orientationChangeHandler: function orientationChangeHandler() {
|
1528 | if (!swiper || swiper.destroyed || !swiper.initialized) return;
|
1529 | swiper.emit('orientationchange');
|
1530 | }
|
1531 | }
|
1532 | });
|
1533 | },
|
1534 | on: {
|
1535 | init: function init(swiper) {
|
1536 | var window = getWindow();
|
1537 |
|
1538 | if (swiper.params.resizeObserver && supportsResizeObserver()) {
|
1539 | swiper.resize.createObserver();
|
1540 | return;
|
1541 | }
|
1542 |
|
1543 |
|
1544 | window.addEventListener('resize', swiper.resize.resizeHandler);
|
1545 |
|
1546 | window.addEventListener('orientationchange', swiper.resize.orientationChangeHandler);
|
1547 | },
|
1548 | destroy: function destroy(swiper) {
|
1549 | var window = getWindow();
|
1550 | swiper.resize.removeObserver();
|
1551 | window.removeEventListener('resize', swiper.resize.resizeHandler);
|
1552 | window.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler);
|
1553 | }
|
1554 | }
|
1555 | };
|
1556 |
|
1557 | var Observer = {
|
1558 | attach: function attach(target, options) {
|
1559 | if (options === void 0) {
|
1560 | options = {};
|
1561 | }
|
1562 |
|
1563 | var window = getWindow();
|
1564 | var swiper = this;
|
1565 | var ObserverFunc = window.MutationObserver || window.WebkitMutationObserver;
|
1566 | var observer = new ObserverFunc(function (mutations) {
|
1567 |
|
1568 |
|
1569 |
|
1570 | if (mutations.length === 1) {
|
1571 | swiper.emit('observerUpdate', mutations[0]);
|
1572 | return;
|
1573 | }
|
1574 |
|
1575 | var observerUpdate = function observerUpdate() {
|
1576 | swiper.emit('observerUpdate', mutations[0]);
|
1577 | };
|
1578 |
|
1579 | if (window.requestAnimationFrame) {
|
1580 | window.requestAnimationFrame(observerUpdate);
|
1581 | } else {
|
1582 | window.setTimeout(observerUpdate, 0);
|
1583 | }
|
1584 | });
|
1585 | observer.observe(target, {
|
1586 | attributes: typeof options.attributes === 'undefined' ? true : options.attributes,
|
1587 | childList: typeof options.childList === 'undefined' ? true : options.childList,
|
1588 | characterData: typeof options.characterData === 'undefined' ? true : options.characterData
|
1589 | });
|
1590 | swiper.observer.observers.push(observer);
|
1591 | },
|
1592 | init: function init() {
|
1593 | var swiper = this;
|
1594 | if (!swiper.support.observer || !swiper.params.observer) return;
|
1595 |
|
1596 | if (swiper.params.observeParents) {
|
1597 | var containerParents = swiper.$el.parents();
|
1598 |
|
1599 | for (var i = 0; i < containerParents.length; i += 1) {
|
1600 | swiper.observer.attach(containerParents[i]);
|
1601 | }
|
1602 | }
|
1603 |
|
1604 |
|
1605 | swiper.observer.attach(swiper.$el[0], {
|
1606 | childList: swiper.params.observeSlideChildren
|
1607 | });
|
1608 |
|
1609 | swiper.observer.attach(swiper.$wrapperEl[0], {
|
1610 | attributes: false
|
1611 | });
|
1612 | },
|
1613 | destroy: function destroy() {
|
1614 | var swiper = this;
|
1615 | swiper.observer.observers.forEach(function (observer) {
|
1616 | observer.disconnect();
|
1617 | });
|
1618 | swiper.observer.observers = [];
|
1619 | }
|
1620 | };
|
1621 | var Observer$1 = {
|
1622 | name: 'observer',
|
1623 | params: {
|
1624 | observer: false,
|
1625 | observeParents: false,
|
1626 | observeSlideChildren: false
|
1627 | },
|
1628 | create: function create() {
|
1629 | var swiper = this;
|
1630 | bindModuleMethods(swiper, {
|
1631 | observer: _extends({}, Observer, {
|
1632 | observers: []
|
1633 | })
|
1634 | });
|
1635 | },
|
1636 | on: {
|
1637 | init: function init(swiper) {
|
1638 | swiper.observer.init();
|
1639 | },
|
1640 | destroy: function destroy(swiper) {
|
1641 | swiper.observer.destroy();
|
1642 | }
|
1643 | }
|
1644 | };
|
1645 |
|
1646 | var modular = {
|
1647 | useParams: function useParams(instanceParams) {
|
1648 | var instance = this;
|
1649 | if (!instance.modules) return;
|
1650 | Object.keys(instance.modules).forEach(function (moduleName) {
|
1651 | var module = instance.modules[moduleName];
|
1652 |
|
1653 | if (module.params) {
|
1654 | extend(instanceParams, module.params);
|
1655 | }
|
1656 | });
|
1657 | },
|
1658 | useModules: function useModules(modulesParams) {
|
1659 | if (modulesParams === void 0) {
|
1660 | modulesParams = {};
|
1661 | }
|
1662 |
|
1663 | var instance = this;
|
1664 | if (!instance.modules) return;
|
1665 | Object.keys(instance.modules).forEach(function (moduleName) {
|
1666 | var module = instance.modules[moduleName];
|
1667 | var moduleParams = modulesParams[moduleName] || {};
|
1668 |
|
1669 | if (module.on && instance.on) {
|
1670 | Object.keys(module.on).forEach(function (moduleEventName) {
|
1671 | instance.on(moduleEventName, module.on[moduleEventName]);
|
1672 | });
|
1673 | }
|
1674 |
|
1675 |
|
1676 | if (module.create) {
|
1677 | module.create.bind(instance)(moduleParams);
|
1678 | }
|
1679 | });
|
1680 | }
|
1681 | };
|
1682 |
|
1683 |
|
1684 | var eventsEmitter = {
|
1685 | on: function on(events, handler, priority) {
|
1686 | var self = this;
|
1687 | if (typeof handler !== 'function') return self;
|
1688 | var method = priority ? 'unshift' : 'push';
|
1689 | events.split(' ').forEach(function (event) {
|
1690 | if (!self.eventsListeners[event]) self.eventsListeners[event] = [];
|
1691 | self.eventsListeners[event][method](handler);
|
1692 | });
|
1693 | return self;
|
1694 | },
|
1695 | once: function once(events, handler, priority) {
|
1696 | var self = this;
|
1697 | if (typeof handler !== 'function') return self;
|
1698 |
|
1699 | function onceHandler() {
|
1700 | self.off(events, onceHandler);
|
1701 |
|
1702 | if (onceHandler.__emitterProxy) {
|
1703 | delete onceHandler.__emitterProxy;
|
1704 | }
|
1705 |
|
1706 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
1707 | args[_key] = arguments[_key];
|
1708 | }
|
1709 |
|
1710 | handler.apply(self, args);
|
1711 | }
|
1712 |
|
1713 | onceHandler.__emitterProxy = handler;
|
1714 | return self.on(events, onceHandler, priority);
|
1715 | },
|
1716 | onAny: function onAny(handler, priority) {
|
1717 | var self = this;
|
1718 | if (typeof handler !== 'function') return self;
|
1719 | var method = priority ? 'unshift' : 'push';
|
1720 |
|
1721 | if (self.eventsAnyListeners.indexOf(handler) < 0) {
|
1722 | self.eventsAnyListeners[method](handler);
|
1723 | }
|
1724 |
|
1725 | return self;
|
1726 | },
|
1727 | offAny: function offAny(handler) {
|
1728 | var self = this;
|
1729 | if (!self.eventsAnyListeners) return self;
|
1730 | var index = self.eventsAnyListeners.indexOf(handler);
|
1731 |
|
1732 | if (index >= 0) {
|
1733 | self.eventsAnyListeners.splice(index, 1);
|
1734 | }
|
1735 |
|
1736 | return self;
|
1737 | },
|
1738 | off: function off(events, handler) {
|
1739 | var self = this;
|
1740 | if (!self.eventsListeners) return self;
|
1741 | events.split(' ').forEach(function (event) {
|
1742 | if (typeof handler === 'undefined') {
|
1743 | self.eventsListeners[event] = [];
|
1744 | } else if (self.eventsListeners[event]) {
|
1745 | self.eventsListeners[event].forEach(function (eventHandler, index) {
|
1746 | if (eventHandler === handler || eventHandler.__emitterProxy && eventHandler.__emitterProxy === handler) {
|
1747 | self.eventsListeners[event].splice(index, 1);
|
1748 | }
|
1749 | });
|
1750 | }
|
1751 | });
|
1752 | return self;
|
1753 | },
|
1754 | emit: function emit() {
|
1755 | var self = this;
|
1756 | if (!self.eventsListeners) return self;
|
1757 | var events;
|
1758 | var data;
|
1759 | var context;
|
1760 |
|
1761 | for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
1762 | args[_key2] = arguments[_key2];
|
1763 | }
|
1764 |
|
1765 | if (typeof args[0] === 'string' || Array.isArray(args[0])) {
|
1766 | events = args[0];
|
1767 | data = args.slice(1, args.length);
|
1768 | context = self;
|
1769 | } else {
|
1770 | events = args[0].events;
|
1771 | data = args[0].data;
|
1772 | context = args[0].context || self;
|
1773 | }
|
1774 |
|
1775 | data.unshift(context);
|
1776 | var eventsArray = Array.isArray(events) ? events : events.split(' ');
|
1777 | eventsArray.forEach(function (event) {
|
1778 | if (self.eventsAnyListeners && self.eventsAnyListeners.length) {
|
1779 | self.eventsAnyListeners.forEach(function (eventHandler) {
|
1780 | eventHandler.apply(context, [event].concat(data));
|
1781 | });
|
1782 | }
|
1783 |
|
1784 | if (self.eventsListeners && self.eventsListeners[event]) {
|
1785 | self.eventsListeners[event].forEach(function (eventHandler) {
|
1786 | eventHandler.apply(context, data);
|
1787 | });
|
1788 | }
|
1789 | });
|
1790 | return self;
|
1791 | }
|
1792 | };
|
1793 |
|
1794 | function updateSize() {
|
1795 | var swiper = this;
|
1796 | var width;
|
1797 | var height;
|
1798 | var $el = swiper.$el;
|
1799 |
|
1800 | if (typeof swiper.params.width !== 'undefined' && swiper.params.width !== null) {
|
1801 | width = swiper.params.width;
|
1802 | } else {
|
1803 | width = $el[0].clientWidth;
|
1804 | }
|
1805 |
|
1806 | if (typeof swiper.params.height !== 'undefined' && swiper.params.height !== null) {
|
1807 | height = swiper.params.height;
|
1808 | } else {
|
1809 | height = $el[0].clientHeight;
|
1810 | }
|
1811 |
|
1812 | if (width === 0 && swiper.isHorizontal() || height === 0 && swiper.isVertical()) {
|
1813 | return;
|
1814 | }
|
1815 |
|
1816 |
|
1817 | width = width - parseInt($el.css('padding-left') || 0, 10) - parseInt($el.css('padding-right') || 0, 10);
|
1818 | height = height - parseInt($el.css('padding-top') || 0, 10) - parseInt($el.css('padding-bottom') || 0, 10);
|
1819 | if (Number.isNaN(width)) width = 0;
|
1820 | if (Number.isNaN(height)) height = 0;
|
1821 | extend(swiper, {
|
1822 | width: width,
|
1823 | height: height,
|
1824 | size: swiper.isHorizontal() ? width : height
|
1825 | });
|
1826 | }
|
1827 |
|
1828 | function updateSlides() {
|
1829 | var swiper = this;
|
1830 |
|
1831 | var getDirectionLabel = function getDirectionLabel(property) {
|
1832 | if (swiper.isHorizontal()) {
|
1833 | return property;
|
1834 | }
|
1835 |
|
1836 |
|
1837 | return {
|
1838 | 'width': 'height',
|
1839 | 'margin-top': 'margin-left',
|
1840 | 'margin-bottom ': 'margin-right',
|
1841 | 'margin-left': 'margin-top',
|
1842 | 'margin-right': 'margin-bottom',
|
1843 | 'padding-left': 'padding-top',
|
1844 | 'padding-right': 'padding-bottom',
|
1845 | 'marginRight': 'marginBottom'
|
1846 | }[property];
|
1847 | };
|
1848 |
|
1849 | var getDirectionPropertyValue = function getDirectionPropertyValue(node, label) {
|
1850 | return parseFloat(node.getPropertyValue(getDirectionLabel(label)) || 0);
|
1851 | };
|
1852 |
|
1853 | var params = swiper.params;
|
1854 | var $wrapperEl = swiper.$wrapperEl,
|
1855 | swiperSize = swiper.size,
|
1856 | rtl = swiper.rtlTranslate,
|
1857 | wrongRTL = swiper.wrongRTL;
|
1858 | var isVirtual = swiper.virtual && params.virtual.enabled;
|
1859 | var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length;
|
1860 | var slides = $wrapperEl.children("." + swiper.params.slideClass);
|
1861 | var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length;
|
1862 | var snapGrid = [];
|
1863 | var slidesGrid = [];
|
1864 | var slidesSizesGrid = [];
|
1865 |
|
1866 | function slidesForMargin(slideEl, slideIndex) {
|
1867 | if (!params.cssMode) return true;
|
1868 |
|
1869 | if (slideIndex === slides.length - 1) {
|
1870 | return false;
|
1871 | }
|
1872 |
|
1873 | return true;
|
1874 | }
|
1875 |
|
1876 | var offsetBefore = params.slidesOffsetBefore;
|
1877 |
|
1878 | if (typeof offsetBefore === 'function') {
|
1879 | offsetBefore = params.slidesOffsetBefore.call(swiper);
|
1880 | }
|
1881 |
|
1882 | var offsetAfter = params.slidesOffsetAfter;
|
1883 |
|
1884 | if (typeof offsetAfter === 'function') {
|
1885 | offsetAfter = params.slidesOffsetAfter.call(swiper);
|
1886 | }
|
1887 |
|
1888 | var previousSnapGridLength = swiper.snapGrid.length;
|
1889 | var previousSlidesGridLength = swiper.slidesGrid.length;
|
1890 | var spaceBetween = params.spaceBetween;
|
1891 | var slidePosition = -offsetBefore;
|
1892 | var prevSlideSize = 0;
|
1893 | var index = 0;
|
1894 |
|
1895 | if (typeof swiperSize === 'undefined') {
|
1896 | return;
|
1897 | }
|
1898 |
|
1899 | if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
|
1900 | spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * swiperSize;
|
1901 | }
|
1902 |
|
1903 | swiper.virtualSize = -spaceBetween;
|
1904 |
|
1905 | if (rtl) slides.css({
|
1906 | marginLeft: '',
|
1907 | marginTop: ''
|
1908 | });else slides.css({
|
1909 | marginRight: '',
|
1910 | marginBottom: ''
|
1911 | });
|
1912 | var slidesNumberEvenToRows;
|
1913 |
|
1914 | if (params.slidesPerColumn > 1) {
|
1915 | if (Math.floor(slidesLength / params.slidesPerColumn) === slidesLength / swiper.params.slidesPerColumn) {
|
1916 | slidesNumberEvenToRows = slidesLength;
|
1917 | } else {
|
1918 | slidesNumberEvenToRows = Math.ceil(slidesLength / params.slidesPerColumn) * params.slidesPerColumn;
|
1919 | }
|
1920 |
|
1921 | if (params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row') {
|
1922 | slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, params.slidesPerView * params.slidesPerColumn);
|
1923 | }
|
1924 | }
|
1925 |
|
1926 |
|
1927 | var slideSize;
|
1928 | var slidesPerColumn = params.slidesPerColumn;
|
1929 | var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
|
1930 | var numFullColumns = Math.floor(slidesLength / params.slidesPerColumn);
|
1931 |
|
1932 | for (var i = 0; i < slidesLength; i += 1) {
|
1933 | slideSize = 0;
|
1934 | var slide = slides.eq(i);
|
1935 |
|
1936 | if (params.slidesPerColumn > 1) {
|
1937 |
|
1938 | var newSlideOrderIndex = void 0;
|
1939 | var column = void 0;
|
1940 | var row = void 0;
|
1941 |
|
1942 | if (params.slidesPerColumnFill === 'row' && params.slidesPerGroup > 1) {
|
1943 | var groupIndex = Math.floor(i / (params.slidesPerGroup * params.slidesPerColumn));
|
1944 | var slideIndexInGroup = i - params.slidesPerColumn * params.slidesPerGroup * groupIndex;
|
1945 | var columnsInGroup = groupIndex === 0 ? params.slidesPerGroup : Math.min(Math.ceil((slidesLength - groupIndex * slidesPerColumn * params.slidesPerGroup) / slidesPerColumn), params.slidesPerGroup);
|
1946 | row = Math.floor(slideIndexInGroup / columnsInGroup);
|
1947 | column = slideIndexInGroup - row * columnsInGroup + groupIndex * params.slidesPerGroup;
|
1948 | newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn;
|
1949 | slide.css({
|
1950 | '-webkit-box-ordinal-group': newSlideOrderIndex,
|
1951 | '-moz-box-ordinal-group': newSlideOrderIndex,
|
1952 | '-ms-flex-order': newSlideOrderIndex,
|
1953 | '-webkit-order': newSlideOrderIndex,
|
1954 | order: newSlideOrderIndex
|
1955 | });
|
1956 | } else if (params.slidesPerColumnFill === 'column') {
|
1957 | column = Math.floor(i / slidesPerColumn);
|
1958 | row = i - column * slidesPerColumn;
|
1959 |
|
1960 | if (column > numFullColumns || column === numFullColumns && row === slidesPerColumn - 1) {
|
1961 | row += 1;
|
1962 |
|
1963 | if (row >= slidesPerColumn) {
|
1964 | row = 0;
|
1965 | column += 1;
|
1966 | }
|
1967 | }
|
1968 | } else {
|
1969 | row = Math.floor(i / slidesPerRow);
|
1970 | column = i - row * slidesPerRow;
|
1971 | }
|
1972 |
|
1973 | slide.css(getDirectionLabel('margin-top'), row !== 0 && params.spaceBetween && params.spaceBetween + "px");
|
1974 | }
|
1975 |
|
1976 | if (slide.css('display') === 'none') continue;
|
1977 |
|
1978 | if (params.slidesPerView === 'auto') {
|
1979 | var slideStyles = getComputedStyle(slide[0]);
|
1980 | var currentTransform = slide[0].style.transform;
|
1981 | var currentWebKitTransform = slide[0].style.webkitTransform;
|
1982 |
|
1983 | if (currentTransform) {
|
1984 | slide[0].style.transform = 'none';
|
1985 | }
|
1986 |
|
1987 | if (currentWebKitTransform) {
|
1988 | slide[0].style.webkitTransform = 'none';
|
1989 | }
|
1990 |
|
1991 | if (params.roundLengths) {
|
1992 | slideSize = swiper.isHorizontal() ? slide.outerWidth(true) : slide.outerHeight(true);
|
1993 | } else {
|
1994 |
|
1995 | var width = getDirectionPropertyValue(slideStyles, 'width');
|
1996 | var paddingLeft = getDirectionPropertyValue(slideStyles, 'padding-left');
|
1997 | var paddingRight = getDirectionPropertyValue(slideStyles, 'padding-right');
|
1998 | var marginLeft = getDirectionPropertyValue(slideStyles, 'margin-left');
|
1999 | var marginRight = getDirectionPropertyValue(slideStyles, 'margin-right');
|
2000 | var boxSizing = slideStyles.getPropertyValue('box-sizing');
|
2001 |
|
2002 | if (boxSizing && boxSizing === 'border-box') {
|
2003 | slideSize = width + marginLeft + marginRight;
|
2004 | } else {
|
2005 | var _slide$ = slide[0],
|
2006 | clientWidth = _slide$.clientWidth,
|
2007 | offsetWidth = _slide$.offsetWidth;
|
2008 | slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight + (offsetWidth - clientWidth);
|
2009 | }
|
2010 | }
|
2011 |
|
2012 | if (currentTransform) {
|
2013 | slide[0].style.transform = currentTransform;
|
2014 | }
|
2015 |
|
2016 | if (currentWebKitTransform) {
|
2017 | slide[0].style.webkitTransform = currentWebKitTransform;
|
2018 | }
|
2019 |
|
2020 | if (params.roundLengths) slideSize = Math.floor(slideSize);
|
2021 | } else {
|
2022 | slideSize = (swiperSize - (params.slidesPerView - 1) * spaceBetween) / params.slidesPerView;
|
2023 | if (params.roundLengths) slideSize = Math.floor(slideSize);
|
2024 |
|
2025 | if (slides[i]) {
|
2026 | slides[i].style[getDirectionLabel('width')] = slideSize + "px";
|
2027 | }
|
2028 | }
|
2029 |
|
2030 | if (slides[i]) {
|
2031 | slides[i].swiperSlideSize = slideSize;
|
2032 | }
|
2033 |
|
2034 | slidesSizesGrid.push(slideSize);
|
2035 |
|
2036 | if (params.centeredSlides) {
|
2037 | slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
|
2038 | if (prevSlideSize === 0 && i !== 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
2039 | if (i === 0) slidePosition = slidePosition - swiperSize / 2 - spaceBetween;
|
2040 | if (Math.abs(slidePosition) < 1 / 1000) slidePosition = 0;
|
2041 | if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
2042 | if (index % params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
2043 | slidesGrid.push(slidePosition);
|
2044 | } else {
|
2045 | if (params.roundLengths) slidePosition = Math.floor(slidePosition);
|
2046 | if ((index - Math.min(swiper.params.slidesPerGroupSkip, index)) % swiper.params.slidesPerGroup === 0) snapGrid.push(slidePosition);
|
2047 | slidesGrid.push(slidePosition);
|
2048 | slidePosition = slidePosition + slideSize + spaceBetween;
|
2049 | }
|
2050 |
|
2051 | swiper.virtualSize += slideSize + spaceBetween;
|
2052 | prevSlideSize = slideSize;
|
2053 | index += 1;
|
2054 | }
|
2055 |
|
2056 | swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter;
|
2057 | var newSlidesGrid;
|
2058 |
|
2059 | if (rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) {
|
2060 | $wrapperEl.css({
|
2061 | width: swiper.virtualSize + params.spaceBetween + "px"
|
2062 | });
|
2063 | }
|
2064 |
|
2065 | if (params.setWrapperSize) {
|
2066 | var _$wrapperEl$css;
|
2067 |
|
2068 | $wrapperEl.css((_$wrapperEl$css = {}, _$wrapperEl$css[getDirectionLabel('width')] = swiper.virtualSize + params.spaceBetween + "px", _$wrapperEl$css));
|
2069 | }
|
2070 |
|
2071 | if (params.slidesPerColumn > 1) {
|
2072 | var _$wrapperEl$css2;
|
2073 |
|
2074 | swiper.virtualSize = (slideSize + params.spaceBetween) * slidesNumberEvenToRows;
|
2075 | swiper.virtualSize = Math.ceil(swiper.virtualSize / params.slidesPerColumn) - params.spaceBetween;
|
2076 | $wrapperEl.css((_$wrapperEl$css2 = {}, _$wrapperEl$css2[getDirectionLabel('width')] = swiper.virtualSize + params.spaceBetween + "px", _$wrapperEl$css2));
|
2077 |
|
2078 | if (params.centeredSlides) {
|
2079 | newSlidesGrid = [];
|
2080 |
|
2081 | for (var _i = 0; _i < snapGrid.length; _i += 1) {
|
2082 | var slidesGridItem = snapGrid[_i];
|
2083 | if (params.roundLengths) slidesGridItem = Math.floor(slidesGridItem);
|
2084 | if (snapGrid[_i] < swiper.virtualSize + snapGrid[0]) newSlidesGrid.push(slidesGridItem);
|
2085 | }
|
2086 |
|
2087 | snapGrid = newSlidesGrid;
|
2088 | }
|
2089 | }
|
2090 |
|
2091 |
|
2092 | if (!params.centeredSlides) {
|
2093 | newSlidesGrid = [];
|
2094 |
|
2095 | for (var _i2 = 0; _i2 < snapGrid.length; _i2 += 1) {
|
2096 | var _slidesGridItem = snapGrid[_i2];
|
2097 | if (params.roundLengths) _slidesGridItem = Math.floor(_slidesGridItem);
|
2098 |
|
2099 | if (snapGrid[_i2] <= swiper.virtualSize - swiperSize) {
|
2100 | newSlidesGrid.push(_slidesGridItem);
|
2101 | }
|
2102 | }
|
2103 |
|
2104 | snapGrid = newSlidesGrid;
|
2105 |
|
2106 | if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) {
|
2107 | snapGrid.push(swiper.virtualSize - swiperSize);
|
2108 | }
|
2109 | }
|
2110 |
|
2111 | if (snapGrid.length === 0) snapGrid = [0];
|
2112 |
|
2113 | if (params.spaceBetween !== 0) {
|
2114 | var _slides$filter$css;
|
2115 |
|
2116 | var key = swiper.isHorizontal() && rtl ? 'marginLeft' : getDirectionLabel('marginRight');
|
2117 | slides.filter(slidesForMargin).css((_slides$filter$css = {}, _slides$filter$css[key] = spaceBetween + "px", _slides$filter$css));
|
2118 | }
|
2119 |
|
2120 | if (params.centeredSlides && params.centeredSlidesBounds) {
|
2121 | var allSlidesSize = 0;
|
2122 | slidesSizesGrid.forEach(function (slideSizeValue) {
|
2123 | allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
|
2124 | });
|
2125 | allSlidesSize -= params.spaceBetween;
|
2126 | var maxSnap = allSlidesSize - swiperSize;
|
2127 | snapGrid = snapGrid.map(function (snap) {
|
2128 | if (snap < 0) return -offsetBefore;
|
2129 | if (snap > maxSnap) return maxSnap + offsetAfter;
|
2130 | return snap;
|
2131 | });
|
2132 | }
|
2133 |
|
2134 | if (params.centerInsufficientSlides) {
|
2135 | var _allSlidesSize = 0;
|
2136 | slidesSizesGrid.forEach(function (slideSizeValue) {
|
2137 | _allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0);
|
2138 | });
|
2139 | _allSlidesSize -= params.spaceBetween;
|
2140 |
|
2141 | if (_allSlidesSize < swiperSize) {
|
2142 | var allSlidesOffset = (swiperSize - _allSlidesSize) / 2;
|
2143 | snapGrid.forEach(function (snap, snapIndex) {
|
2144 | snapGrid[snapIndex] = snap - allSlidesOffset;
|
2145 | });
|
2146 | slidesGrid.forEach(function (snap, snapIndex) {
|
2147 | slidesGrid[snapIndex] = snap + allSlidesOffset;
|
2148 | });
|
2149 | }
|
2150 | }
|
2151 |
|
2152 | extend(swiper, {
|
2153 | slides: slides,
|
2154 | snapGrid: snapGrid,
|
2155 | slidesGrid: slidesGrid,
|
2156 | slidesSizesGrid: slidesSizesGrid
|
2157 | });
|
2158 |
|
2159 | if (slidesLength !== previousSlidesLength) {
|
2160 | swiper.emit('slidesLengthChange');
|
2161 | }
|
2162 |
|
2163 | if (snapGrid.length !== previousSnapGridLength) {
|
2164 | if (swiper.params.watchOverflow) swiper.checkOverflow();
|
2165 | swiper.emit('snapGridLengthChange');
|
2166 | }
|
2167 |
|
2168 | if (slidesGrid.length !== previousSlidesGridLength) {
|
2169 | swiper.emit('slidesGridLengthChange');
|
2170 | }
|
2171 |
|
2172 | if (params.watchSlidesProgress || params.watchSlidesVisibility) {
|
2173 | swiper.updateSlidesOffset();
|
2174 | }
|
2175 | }
|
2176 |
|
2177 | function updateAutoHeight(speed) {
|
2178 | var swiper = this;
|
2179 | var activeSlides = [];
|
2180 | var newHeight = 0;
|
2181 | var i;
|
2182 |
|
2183 | if (typeof speed === 'number') {
|
2184 | swiper.setTransition(speed);
|
2185 | } else if (speed === true) {
|
2186 | swiper.setTransition(swiper.params.speed);
|
2187 | }
|
2188 |
|
2189 |
|
2190 | if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) {
|
2191 | if (swiper.params.centeredSlides) {
|
2192 | swiper.visibleSlides.each(function (slide) {
|
2193 | activeSlides.push(slide);
|
2194 | });
|
2195 | } else {
|
2196 | for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) {
|
2197 | var index = swiper.activeIndex + i;
|
2198 | if (index > swiper.slides.length) break;
|
2199 | activeSlides.push(swiper.slides.eq(index)[0]);
|
2200 | }
|
2201 | }
|
2202 | } else {
|
2203 | activeSlides.push(swiper.slides.eq(swiper.activeIndex)[0]);
|
2204 | }
|
2205 |
|
2206 |
|
2207 | for (i = 0; i < activeSlides.length; i += 1) {
|
2208 | if (typeof activeSlides[i] !== 'undefined') {
|
2209 | var height = activeSlides[i].offsetHeight;
|
2210 | newHeight = height > newHeight ? height : newHeight;
|
2211 | }
|
2212 | }
|
2213 |
|
2214 |
|
2215 | if (newHeight) swiper.$wrapperEl.css('height', newHeight + "px");
|
2216 | }
|
2217 |
|
2218 | function updateSlidesOffset() {
|
2219 | var swiper = this;
|
2220 | var slides = swiper.slides;
|
2221 |
|
2222 | for (var i = 0; i < slides.length; i += 1) {
|
2223 | slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop;
|
2224 | }
|
2225 | }
|
2226 |
|
2227 | function updateSlidesProgress(translate) {
|
2228 | if (translate === void 0) {
|
2229 | translate = this && this.translate || 0;
|
2230 | }
|
2231 |
|
2232 | var swiper = this;
|
2233 | var params = swiper.params;
|
2234 | var slides = swiper.slides,
|
2235 | rtl = swiper.rtlTranslate;
|
2236 | if (slides.length === 0) return;
|
2237 | if (typeof slides[0].swiperSlideOffset === 'undefined') swiper.updateSlidesOffset();
|
2238 | var offsetCenter = -translate;
|
2239 | if (rtl) offsetCenter = translate;
|
2240 |
|
2241 | slides.removeClass(params.slideVisibleClass);
|
2242 | swiper.visibleSlidesIndexes = [];
|
2243 | swiper.visibleSlides = [];
|
2244 |
|
2245 | for (var i = 0; i < slides.length; i += 1) {
|
2246 | var slide = slides[i];
|
2247 | var slideProgress = (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0) - slide.swiperSlideOffset) / (slide.swiperSlideSize + params.spaceBetween);
|
2248 |
|
2249 | if (params.watchSlidesVisibility || params.centeredSlides && params.autoHeight) {
|
2250 | var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
|
2251 | var slideAfter = slideBefore + swiper.slidesSizesGrid[i];
|
2252 | var isVisible = slideBefore >= 0 && slideBefore < swiper.size - 1 || slideAfter > 1 && slideAfter <= swiper.size || slideBefore <= 0 && slideAfter >= swiper.size;
|
2253 |
|
2254 | if (isVisible) {
|
2255 | swiper.visibleSlides.push(slide);
|
2256 | swiper.visibleSlidesIndexes.push(i);
|
2257 | slides.eq(i).addClass(params.slideVisibleClass);
|
2258 | }
|
2259 | }
|
2260 |
|
2261 | slide.progress = rtl ? -slideProgress : slideProgress;
|
2262 | }
|
2263 |
|
2264 | swiper.visibleSlides = $(swiper.visibleSlides);
|
2265 | }
|
2266 |
|
2267 | function updateProgress(translate) {
|
2268 | var swiper = this;
|
2269 |
|
2270 | if (typeof translate === 'undefined') {
|
2271 | var multiplier = swiper.rtlTranslate ? -1 : 1;
|
2272 |
|
2273 | translate = swiper && swiper.translate && swiper.translate * multiplier || 0;
|
2274 | }
|
2275 |
|
2276 | var params = swiper.params;
|
2277 | var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
2278 | var progress = swiper.progress,
|
2279 | isBeginning = swiper.isBeginning,
|
2280 | isEnd = swiper.isEnd;
|
2281 | var wasBeginning = isBeginning;
|
2282 | var wasEnd = isEnd;
|
2283 |
|
2284 | if (translatesDiff === 0) {
|
2285 | progress = 0;
|
2286 | isBeginning = true;
|
2287 | isEnd = true;
|
2288 | } else {
|
2289 | progress = (translate - swiper.minTranslate()) / translatesDiff;
|
2290 | isBeginning = progress <= 0;
|
2291 | isEnd = progress >= 1;
|
2292 | }
|
2293 |
|
2294 | extend(swiper, {
|
2295 | progress: progress,
|
2296 | isBeginning: isBeginning,
|
2297 | isEnd: isEnd
|
2298 | });
|
2299 | if (params.watchSlidesProgress || params.watchSlidesVisibility || params.centeredSlides && params.autoHeight) swiper.updateSlidesProgress(translate);
|
2300 |
|
2301 | if (isBeginning && !wasBeginning) {
|
2302 | swiper.emit('reachBeginning toEdge');
|
2303 | }
|
2304 |
|
2305 | if (isEnd && !wasEnd) {
|
2306 | swiper.emit('reachEnd toEdge');
|
2307 | }
|
2308 |
|
2309 | if (wasBeginning && !isBeginning || wasEnd && !isEnd) {
|
2310 | swiper.emit('fromEdge');
|
2311 | }
|
2312 |
|
2313 | swiper.emit('progress', progress);
|
2314 | }
|
2315 |
|
2316 | function updateSlidesClasses() {
|
2317 | var swiper = this;
|
2318 | var slides = swiper.slides,
|
2319 | params = swiper.params,
|
2320 | $wrapperEl = swiper.$wrapperEl,
|
2321 | activeIndex = swiper.activeIndex,
|
2322 | realIndex = swiper.realIndex;
|
2323 | var isVirtual = swiper.virtual && params.virtual.enabled;
|
2324 | slides.removeClass(params.slideActiveClass + " " + params.slideNextClass + " " + params.slidePrevClass + " " + params.slideDuplicateActiveClass + " " + params.slideDuplicateNextClass + " " + params.slideDuplicatePrevClass);
|
2325 | var activeSlide;
|
2326 |
|
2327 | if (isVirtual) {
|
2328 | activeSlide = swiper.$wrapperEl.find("." + params.slideClass + "[data-swiper-slide-index=\"" + activeIndex + "\"]");
|
2329 | } else {
|
2330 | activeSlide = slides.eq(activeIndex);
|
2331 | }
|
2332 |
|
2333 |
|
2334 | activeSlide.addClass(params.slideActiveClass);
|
2335 |
|
2336 | if (params.loop) {
|
2337 |
|
2338 | if (activeSlide.hasClass(params.slideDuplicateClass)) {
|
2339 | $wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + realIndex + "\"]").addClass(params.slideDuplicateActiveClass);
|
2340 | } else {
|
2341 | $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + realIndex + "\"]").addClass(params.slideDuplicateActiveClass);
|
2342 | }
|
2343 | }
|
2344 |
|
2345 |
|
2346 | var nextSlide = activeSlide.nextAll("." + params.slideClass).eq(0).addClass(params.slideNextClass);
|
2347 |
|
2348 | if (params.loop && nextSlide.length === 0) {
|
2349 | nextSlide = slides.eq(0);
|
2350 | nextSlide.addClass(params.slideNextClass);
|
2351 | }
|
2352 |
|
2353 |
|
2354 | var prevSlide = activeSlide.prevAll("." + params.slideClass).eq(0).addClass(params.slidePrevClass);
|
2355 |
|
2356 | if (params.loop && prevSlide.length === 0) {
|
2357 | prevSlide = slides.eq(-1);
|
2358 | prevSlide.addClass(params.slidePrevClass);
|
2359 | }
|
2360 |
|
2361 | if (params.loop) {
|
2362 |
|
2363 | if (nextSlide.hasClass(params.slideDuplicateClass)) {
|
2364 | $wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + nextSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicateNextClass);
|
2365 | } else {
|
2366 | $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + nextSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicateNextClass);
|
2367 | }
|
2368 |
|
2369 | if (prevSlide.hasClass(params.slideDuplicateClass)) {
|
2370 | $wrapperEl.children("." + params.slideClass + ":not(." + params.slideDuplicateClass + ")[data-swiper-slide-index=\"" + prevSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicatePrevClass);
|
2371 | } else {
|
2372 | $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + "[data-swiper-slide-index=\"" + prevSlide.attr('data-swiper-slide-index') + "\"]").addClass(params.slideDuplicatePrevClass);
|
2373 | }
|
2374 | }
|
2375 |
|
2376 | swiper.emitSlidesClasses();
|
2377 | }
|
2378 |
|
2379 | function updateActiveIndex(newActiveIndex) {
|
2380 | var swiper = this;
|
2381 | var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
2382 | var slidesGrid = swiper.slidesGrid,
|
2383 | snapGrid = swiper.snapGrid,
|
2384 | params = swiper.params,
|
2385 | previousIndex = swiper.activeIndex,
|
2386 | previousRealIndex = swiper.realIndex,
|
2387 | previousSnapIndex = swiper.snapIndex;
|
2388 | var activeIndex = newActiveIndex;
|
2389 | var snapIndex;
|
2390 |
|
2391 | if (typeof activeIndex === 'undefined') {
|
2392 | for (var i = 0; i < slidesGrid.length; i += 1) {
|
2393 | if (typeof slidesGrid[i + 1] !== 'undefined') {
|
2394 | if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - (slidesGrid[i + 1] - slidesGrid[i]) / 2) {
|
2395 | activeIndex = i;
|
2396 | } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) {
|
2397 | activeIndex = i + 1;
|
2398 | }
|
2399 | } else if (translate >= slidesGrid[i]) {
|
2400 | activeIndex = i;
|
2401 | }
|
2402 | }
|
2403 |
|
2404 |
|
2405 | if (params.normalizeSlideIndex) {
|
2406 | if (activeIndex < 0 || typeof activeIndex === 'undefined') activeIndex = 0;
|
2407 | }
|
2408 | }
|
2409 |
|
2410 | if (snapGrid.indexOf(translate) >= 0) {
|
2411 | snapIndex = snapGrid.indexOf(translate);
|
2412 | } else {
|
2413 | var skip = Math.min(params.slidesPerGroupSkip, activeIndex);
|
2414 | snapIndex = skip + Math.floor((activeIndex - skip) / params.slidesPerGroup);
|
2415 | }
|
2416 |
|
2417 | if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
2418 |
|
2419 | if (activeIndex === previousIndex) {
|
2420 | if (snapIndex !== previousSnapIndex) {
|
2421 | swiper.snapIndex = snapIndex;
|
2422 | swiper.emit('snapIndexChange');
|
2423 | }
|
2424 |
|
2425 | return;
|
2426 | }
|
2427 |
|
2428 |
|
2429 | var realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10);
|
2430 | extend(swiper, {
|
2431 | snapIndex: snapIndex,
|
2432 | realIndex: realIndex,
|
2433 | previousIndex: previousIndex,
|
2434 | activeIndex: activeIndex
|
2435 | });
|
2436 | swiper.emit('activeIndexChange');
|
2437 | swiper.emit('snapIndexChange');
|
2438 |
|
2439 | if (previousRealIndex !== realIndex) {
|
2440 | swiper.emit('realIndexChange');
|
2441 | }
|
2442 |
|
2443 | if (swiper.initialized || swiper.params.runCallbacksOnInit) {
|
2444 | swiper.emit('slideChange');
|
2445 | }
|
2446 | }
|
2447 |
|
2448 | function updateClickedSlide(e) {
|
2449 | var swiper = this;
|
2450 | var params = swiper.params;
|
2451 | var slide = $(e.target).closest("." + params.slideClass)[0];
|
2452 | var slideFound = false;
|
2453 | var slideIndex;
|
2454 |
|
2455 | if (slide) {
|
2456 | for (var i = 0; i < swiper.slides.length; i += 1) {
|
2457 | if (swiper.slides[i] === slide) {
|
2458 | slideFound = true;
|
2459 | slideIndex = i;
|
2460 | break;
|
2461 | }
|
2462 | }
|
2463 | }
|
2464 |
|
2465 | if (slide && slideFound) {
|
2466 | swiper.clickedSlide = slide;
|
2467 |
|
2468 | if (swiper.virtual && swiper.params.virtual.enabled) {
|
2469 | swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10);
|
2470 | } else {
|
2471 | swiper.clickedIndex = slideIndex;
|
2472 | }
|
2473 | } else {
|
2474 | swiper.clickedSlide = undefined;
|
2475 | swiper.clickedIndex = undefined;
|
2476 | return;
|
2477 | }
|
2478 |
|
2479 | if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) {
|
2480 | swiper.slideToClickedSlide();
|
2481 | }
|
2482 | }
|
2483 |
|
2484 | var update = {
|
2485 | updateSize: updateSize,
|
2486 | updateSlides: updateSlides,
|
2487 | updateAutoHeight: updateAutoHeight,
|
2488 | updateSlidesOffset: updateSlidesOffset,
|
2489 | updateSlidesProgress: updateSlidesProgress,
|
2490 | updateProgress: updateProgress,
|
2491 | updateSlidesClasses: updateSlidesClasses,
|
2492 | updateActiveIndex: updateActiveIndex,
|
2493 | updateClickedSlide: updateClickedSlide
|
2494 | };
|
2495 |
|
2496 | function getSwiperTranslate(axis) {
|
2497 | if (axis === void 0) {
|
2498 | axis = this.isHorizontal() ? 'x' : 'y';
|
2499 | }
|
2500 |
|
2501 | var swiper = this;
|
2502 | var params = swiper.params,
|
2503 | rtl = swiper.rtlTranslate,
|
2504 | translate = swiper.translate,
|
2505 | $wrapperEl = swiper.$wrapperEl;
|
2506 |
|
2507 | if (params.virtualTranslate) {
|
2508 | return rtl ? -translate : translate;
|
2509 | }
|
2510 |
|
2511 | if (params.cssMode) {
|
2512 | return translate;
|
2513 | }
|
2514 |
|
2515 | var currentTranslate = getTranslate($wrapperEl[0], axis);
|
2516 | if (rtl) currentTranslate = -currentTranslate;
|
2517 | return currentTranslate || 0;
|
2518 | }
|
2519 |
|
2520 | function setTranslate(translate, byController) {
|
2521 | var swiper = this;
|
2522 | var rtl = swiper.rtlTranslate,
|
2523 | params = swiper.params,
|
2524 | $wrapperEl = swiper.$wrapperEl,
|
2525 | wrapperEl = swiper.wrapperEl,
|
2526 | progress = swiper.progress;
|
2527 | var x = 0;
|
2528 | var y = 0;
|
2529 | var z = 0;
|
2530 |
|
2531 | if (swiper.isHorizontal()) {
|
2532 | x = rtl ? -translate : translate;
|
2533 | } else {
|
2534 | y = translate;
|
2535 | }
|
2536 |
|
2537 | if (params.roundLengths) {
|
2538 | x = Math.floor(x);
|
2539 | y = Math.floor(y);
|
2540 | }
|
2541 |
|
2542 | if (params.cssMode) {
|
2543 | wrapperEl[swiper.isHorizontal() ? 'scrollLeft' : 'scrollTop'] = swiper.isHorizontal() ? -x : -y;
|
2544 | } else if (!params.virtualTranslate) {
|
2545 | $wrapperEl.transform("translate3d(" + x + "px, " + y + "px, " + z + "px)");
|
2546 | }
|
2547 |
|
2548 | swiper.previousTranslate = swiper.translate;
|
2549 | swiper.translate = swiper.isHorizontal() ? x : y;
|
2550 |
|
2551 | var newProgress;
|
2552 | var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
2553 |
|
2554 | if (translatesDiff === 0) {
|
2555 | newProgress = 0;
|
2556 | } else {
|
2557 | newProgress = (translate - swiper.minTranslate()) / translatesDiff;
|
2558 | }
|
2559 |
|
2560 | if (newProgress !== progress) {
|
2561 | swiper.updateProgress(translate);
|
2562 | }
|
2563 |
|
2564 | swiper.emit('setTranslate', swiper.translate, byController);
|
2565 | }
|
2566 |
|
2567 | function minTranslate() {
|
2568 | return -this.snapGrid[0];
|
2569 | }
|
2570 |
|
2571 | function maxTranslate() {
|
2572 | return -this.snapGrid[this.snapGrid.length - 1];
|
2573 | }
|
2574 |
|
2575 | function translateTo(translate, speed, runCallbacks, translateBounds, internal) {
|
2576 | if (translate === void 0) {
|
2577 | translate = 0;
|
2578 | }
|
2579 |
|
2580 | if (speed === void 0) {
|
2581 | speed = this.params.speed;
|
2582 | }
|
2583 |
|
2584 | if (runCallbacks === void 0) {
|
2585 | runCallbacks = true;
|
2586 | }
|
2587 |
|
2588 | if (translateBounds === void 0) {
|
2589 | translateBounds = true;
|
2590 | }
|
2591 |
|
2592 | var swiper = this;
|
2593 | var params = swiper.params,
|
2594 | wrapperEl = swiper.wrapperEl;
|
2595 |
|
2596 | if (swiper.animating && params.preventInteractionOnTransition) {
|
2597 | return false;
|
2598 | }
|
2599 |
|
2600 | var minTranslate = swiper.minTranslate();
|
2601 | var maxTranslate = swiper.maxTranslate();
|
2602 | var newTranslate;
|
2603 | if (translateBounds && translate > minTranslate) newTranslate = minTranslate;else if (translateBounds && translate < maxTranslate) newTranslate = maxTranslate;else newTranslate = translate;
|
2604 |
|
2605 | swiper.updateProgress(newTranslate);
|
2606 |
|
2607 | if (params.cssMode) {
|
2608 | var isH = swiper.isHorizontal();
|
2609 |
|
2610 | if (speed === 0) {
|
2611 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
|
2612 | } else {
|
2613 |
|
2614 | if (wrapperEl.scrollTo) {
|
2615 | var _wrapperEl$scrollTo;
|
2616 |
|
2617 | wrapperEl.scrollTo((_wrapperEl$scrollTo = {}, _wrapperEl$scrollTo[isH ? 'left' : 'top'] = -newTranslate, _wrapperEl$scrollTo.behavior = 'smooth', _wrapperEl$scrollTo));
|
2618 | } else {
|
2619 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = -newTranslate;
|
2620 | }
|
2621 | }
|
2622 |
|
2623 | return true;
|
2624 | }
|
2625 |
|
2626 | if (speed === 0) {
|
2627 | swiper.setTransition(0);
|
2628 | swiper.setTranslate(newTranslate);
|
2629 |
|
2630 | if (runCallbacks) {
|
2631 | swiper.emit('beforeTransitionStart', speed, internal);
|
2632 | swiper.emit('transitionEnd');
|
2633 | }
|
2634 | } else {
|
2635 | swiper.setTransition(speed);
|
2636 | swiper.setTranslate(newTranslate);
|
2637 |
|
2638 | if (runCallbacks) {
|
2639 | swiper.emit('beforeTransitionStart', speed, internal);
|
2640 | swiper.emit('transitionStart');
|
2641 | }
|
2642 |
|
2643 | if (!swiper.animating) {
|
2644 | swiper.animating = true;
|
2645 |
|
2646 | if (!swiper.onTranslateToWrapperTransitionEnd) {
|
2647 | swiper.onTranslateToWrapperTransitionEnd = function transitionEnd(e) {
|
2648 | if (!swiper || swiper.destroyed) return;
|
2649 | if (e.target !== this) return;
|
2650 | swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
2651 | swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
|
2652 | swiper.onTranslateToWrapperTransitionEnd = null;
|
2653 | delete swiper.onTranslateToWrapperTransitionEnd;
|
2654 |
|
2655 | if (runCallbacks) {
|
2656 | swiper.emit('transitionEnd');
|
2657 | }
|
2658 | };
|
2659 | }
|
2660 |
|
2661 | swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onTranslateToWrapperTransitionEnd);
|
2662 | swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onTranslateToWrapperTransitionEnd);
|
2663 | }
|
2664 | }
|
2665 |
|
2666 | return true;
|
2667 | }
|
2668 |
|
2669 | var translate = {
|
2670 | getTranslate: getSwiperTranslate,
|
2671 | setTranslate: setTranslate,
|
2672 | minTranslate: minTranslate,
|
2673 | maxTranslate: maxTranslate,
|
2674 | translateTo: translateTo
|
2675 | };
|
2676 |
|
2677 | function setTransition(duration, byController) {
|
2678 | var swiper = this;
|
2679 |
|
2680 | if (!swiper.params.cssMode) {
|
2681 | swiper.$wrapperEl.transition(duration);
|
2682 | }
|
2683 |
|
2684 | swiper.emit('setTransition', duration, byController);
|
2685 | }
|
2686 |
|
2687 | function transitionStart(runCallbacks, direction) {
|
2688 | if (runCallbacks === void 0) {
|
2689 | runCallbacks = true;
|
2690 | }
|
2691 |
|
2692 | var swiper = this;
|
2693 | var activeIndex = swiper.activeIndex,
|
2694 | params = swiper.params,
|
2695 | previousIndex = swiper.previousIndex;
|
2696 | if (params.cssMode) return;
|
2697 |
|
2698 | if (params.autoHeight) {
|
2699 | swiper.updateAutoHeight();
|
2700 | }
|
2701 |
|
2702 | var dir = direction;
|
2703 |
|
2704 | if (!dir) {
|
2705 | if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
|
2706 | }
|
2707 |
|
2708 | swiper.emit('transitionStart');
|
2709 |
|
2710 | if (runCallbacks && activeIndex !== previousIndex) {
|
2711 | if (dir === 'reset') {
|
2712 | swiper.emit('slideResetTransitionStart');
|
2713 | return;
|
2714 | }
|
2715 |
|
2716 | swiper.emit('slideChangeTransitionStart');
|
2717 |
|
2718 | if (dir === 'next') {
|
2719 | swiper.emit('slideNextTransitionStart');
|
2720 | } else {
|
2721 | swiper.emit('slidePrevTransitionStart');
|
2722 | }
|
2723 | }
|
2724 | }
|
2725 |
|
2726 | function transitionEnd(runCallbacks, direction) {
|
2727 | if (runCallbacks === void 0) {
|
2728 | runCallbacks = true;
|
2729 | }
|
2730 |
|
2731 | var swiper = this;
|
2732 | var activeIndex = swiper.activeIndex,
|
2733 | previousIndex = swiper.previousIndex,
|
2734 | params = swiper.params;
|
2735 | swiper.animating = false;
|
2736 | if (params.cssMode) return;
|
2737 | swiper.setTransition(0);
|
2738 | var dir = direction;
|
2739 |
|
2740 | if (!dir) {
|
2741 | if (activeIndex > previousIndex) dir = 'next';else if (activeIndex < previousIndex) dir = 'prev';else dir = 'reset';
|
2742 | }
|
2743 |
|
2744 | swiper.emit('transitionEnd');
|
2745 |
|
2746 | if (runCallbacks && activeIndex !== previousIndex) {
|
2747 | if (dir === 'reset') {
|
2748 | swiper.emit('slideResetTransitionEnd');
|
2749 | return;
|
2750 | }
|
2751 |
|
2752 | swiper.emit('slideChangeTransitionEnd');
|
2753 |
|
2754 | if (dir === 'next') {
|
2755 | swiper.emit('slideNextTransitionEnd');
|
2756 | } else {
|
2757 | swiper.emit('slidePrevTransitionEnd');
|
2758 | }
|
2759 | }
|
2760 | }
|
2761 |
|
2762 | var transition = {
|
2763 | setTransition: setTransition,
|
2764 | transitionStart: transitionStart,
|
2765 | transitionEnd: transitionEnd
|
2766 | };
|
2767 |
|
2768 | function slideTo(index, speed, runCallbacks, internal) {
|
2769 | if (index === void 0) {
|
2770 | index = 0;
|
2771 | }
|
2772 |
|
2773 | if (speed === void 0) {
|
2774 | speed = this.params.speed;
|
2775 | }
|
2776 |
|
2777 | if (runCallbacks === void 0) {
|
2778 | runCallbacks = true;
|
2779 | }
|
2780 |
|
2781 | if (typeof index !== 'number' && typeof index !== 'string') {
|
2782 | throw new Error("The 'index' argument cannot have type other than 'number' or 'string'. [" + typeof index + "] given.");
|
2783 | }
|
2784 |
|
2785 | if (typeof index === 'string') {
|
2786 | |
2787 |
|
2788 |
|
2789 |
|
2790 | var indexAsNumber = parseInt(index, 10);
|
2791 | |
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 | var isValidNumber = isFinite(indexAsNumber);
|
2798 |
|
2799 | if (!isValidNumber) {
|
2800 | throw new Error("The passed-in 'index' (string) couldn't be converted to 'number'. [" + index + "] given.");
|
2801 | }
|
2802 |
|
2803 |
|
2804 |
|
2805 | index = indexAsNumber;
|
2806 | }
|
2807 |
|
2808 | var swiper = this;
|
2809 | var slideIndex = index;
|
2810 | if (slideIndex < 0) slideIndex = 0;
|
2811 | var params = swiper.params,
|
2812 | snapGrid = swiper.snapGrid,
|
2813 | slidesGrid = swiper.slidesGrid,
|
2814 | previousIndex = swiper.previousIndex,
|
2815 | activeIndex = swiper.activeIndex,
|
2816 | rtl = swiper.rtlTranslate,
|
2817 | wrapperEl = swiper.wrapperEl;
|
2818 |
|
2819 | if (swiper.animating && params.preventInteractionOnTransition) {
|
2820 | return false;
|
2821 | }
|
2822 |
|
2823 | var skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
|
2824 | var snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
|
2825 | if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;
|
2826 |
|
2827 | if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) {
|
2828 | swiper.emit('beforeSlideChangeStart');
|
2829 | }
|
2830 |
|
2831 | var translate = -snapGrid[snapIndex];
|
2832 |
|
2833 | swiper.updateProgress(translate);
|
2834 |
|
2835 | if (params.normalizeSlideIndex) {
|
2836 | for (var i = 0; i < slidesGrid.length; i += 1) {
|
2837 | var normalizedTranslate = -Math.floor(translate * 100);
|
2838 | var normalizedGird = Math.floor(slidesGrid[i] * 100);
|
2839 | var normalizedGridNext = Math.floor(slidesGrid[i + 1] * 100);
|
2840 |
|
2841 | if (typeof slidesGrid[i + 1] !== 'undefined') {
|
2842 | if (normalizedTranslate >= normalizedGird && normalizedTranslate < normalizedGridNext - (normalizedGridNext - normalizedGird) / 2) {
|
2843 | slideIndex = i;
|
2844 | } else if (normalizedTranslate >= normalizedGird && normalizedTranslate < normalizedGridNext) {
|
2845 | slideIndex = i + 1;
|
2846 | }
|
2847 | } else if (normalizedTranslate >= normalizedGird) {
|
2848 | slideIndex = i;
|
2849 | }
|
2850 | }
|
2851 | }
|
2852 |
|
2853 |
|
2854 | if (swiper.initialized && slideIndex !== activeIndex) {
|
2855 | if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) {
|
2856 | return false;
|
2857 | }
|
2858 |
|
2859 | if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) {
|
2860 | if ((activeIndex || 0) !== slideIndex) return false;
|
2861 | }
|
2862 | }
|
2863 |
|
2864 | var direction;
|
2865 | if (slideIndex > activeIndex) direction = 'next';else if (slideIndex < activeIndex) direction = 'prev';else direction = 'reset';
|
2866 |
|
2867 | if (rtl && -translate === swiper.translate || !rtl && translate === swiper.translate) {
|
2868 | swiper.updateActiveIndex(slideIndex);
|
2869 |
|
2870 | if (params.autoHeight) {
|
2871 | swiper.updateAutoHeight();
|
2872 | }
|
2873 |
|
2874 | swiper.updateSlidesClasses();
|
2875 |
|
2876 | if (params.effect !== 'slide') {
|
2877 | swiper.setTranslate(translate);
|
2878 | }
|
2879 |
|
2880 | if (direction !== 'reset') {
|
2881 | swiper.transitionStart(runCallbacks, direction);
|
2882 | swiper.transitionEnd(runCallbacks, direction);
|
2883 | }
|
2884 |
|
2885 | return false;
|
2886 | }
|
2887 |
|
2888 | if (params.cssMode) {
|
2889 | var isH = swiper.isHorizontal();
|
2890 | var t = -translate;
|
2891 |
|
2892 | if (rtl) {
|
2893 | t = wrapperEl.scrollWidth - wrapperEl.offsetWidth - t;
|
2894 | }
|
2895 |
|
2896 | if (speed === 0) {
|
2897 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
2898 | } else {
|
2899 |
|
2900 | if (wrapperEl.scrollTo) {
|
2901 | var _wrapperEl$scrollTo;
|
2902 |
|
2903 | wrapperEl.scrollTo((_wrapperEl$scrollTo = {}, _wrapperEl$scrollTo[isH ? 'left' : 'top'] = t, _wrapperEl$scrollTo.behavior = 'smooth', _wrapperEl$scrollTo));
|
2904 | } else {
|
2905 | wrapperEl[isH ? 'scrollLeft' : 'scrollTop'] = t;
|
2906 | }
|
2907 | }
|
2908 |
|
2909 | return true;
|
2910 | }
|
2911 |
|
2912 | if (speed === 0) {
|
2913 | swiper.setTransition(0);
|
2914 | swiper.setTranslate(translate);
|
2915 | swiper.updateActiveIndex(slideIndex);
|
2916 | swiper.updateSlidesClasses();
|
2917 | swiper.emit('beforeTransitionStart', speed, internal);
|
2918 | swiper.transitionStart(runCallbacks, direction);
|
2919 | swiper.transitionEnd(runCallbacks, direction);
|
2920 | } else {
|
2921 | swiper.setTransition(speed);
|
2922 | swiper.setTranslate(translate);
|
2923 | swiper.updateActiveIndex(slideIndex);
|
2924 | swiper.updateSlidesClasses();
|
2925 | swiper.emit('beforeTransitionStart', speed, internal);
|
2926 | swiper.transitionStart(runCallbacks, direction);
|
2927 |
|
2928 | if (!swiper.animating) {
|
2929 | swiper.animating = true;
|
2930 |
|
2931 | if (!swiper.onSlideToWrapperTransitionEnd) {
|
2932 | swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) {
|
2933 | if (!swiper || swiper.destroyed) return;
|
2934 | if (e.target !== this) return;
|
2935 | swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
2936 | swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
|
2937 | swiper.onSlideToWrapperTransitionEnd = null;
|
2938 | delete swiper.onSlideToWrapperTransitionEnd;
|
2939 | swiper.transitionEnd(runCallbacks, direction);
|
2940 | };
|
2941 | }
|
2942 |
|
2943 | swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd);
|
2944 | swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd);
|
2945 | }
|
2946 | }
|
2947 |
|
2948 | return true;
|
2949 | }
|
2950 |
|
2951 | function slideToLoop(index, speed, runCallbacks, internal) {
|
2952 | if (index === void 0) {
|
2953 | index = 0;
|
2954 | }
|
2955 |
|
2956 | if (speed === void 0) {
|
2957 | speed = this.params.speed;
|
2958 | }
|
2959 |
|
2960 | if (runCallbacks === void 0) {
|
2961 | runCallbacks = true;
|
2962 | }
|
2963 |
|
2964 | var swiper = this;
|
2965 | var newIndex = index;
|
2966 |
|
2967 | if (swiper.params.loop) {
|
2968 | newIndex += swiper.loopedSlides;
|
2969 | }
|
2970 |
|
2971 | return swiper.slideTo(newIndex, speed, runCallbacks, internal);
|
2972 | }
|
2973 |
|
2974 |
|
2975 | function slideNext(speed, runCallbacks, internal) {
|
2976 | if (speed === void 0) {
|
2977 | speed = this.params.speed;
|
2978 | }
|
2979 |
|
2980 | if (runCallbacks === void 0) {
|
2981 | runCallbacks = true;
|
2982 | }
|
2983 |
|
2984 | var swiper = this;
|
2985 | var params = swiper.params,
|
2986 | animating = swiper.animating;
|
2987 | var increment = swiper.activeIndex < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup;
|
2988 |
|
2989 | if (params.loop) {
|
2990 | if (animating && params.loopPreventsSlide) return false;
|
2991 | swiper.loopFix();
|
2992 |
|
2993 | swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
|
2994 | }
|
2995 |
|
2996 | return swiper.slideTo(swiper.activeIndex + increment, speed, runCallbacks, internal);
|
2997 | }
|
2998 |
|
2999 |
|
3000 | function slidePrev(speed, runCallbacks, internal) {
|
3001 | if (speed === void 0) {
|
3002 | speed = this.params.speed;
|
3003 | }
|
3004 |
|
3005 | if (runCallbacks === void 0) {
|
3006 | runCallbacks = true;
|
3007 | }
|
3008 |
|
3009 | var swiper = this;
|
3010 | var params = swiper.params,
|
3011 | animating = swiper.animating,
|
3012 | snapGrid = swiper.snapGrid,
|
3013 | slidesGrid = swiper.slidesGrid,
|
3014 | rtlTranslate = swiper.rtlTranslate;
|
3015 |
|
3016 | if (params.loop) {
|
3017 | if (animating && params.loopPreventsSlide) return false;
|
3018 | swiper.loopFix();
|
3019 |
|
3020 | swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
|
3021 | }
|
3022 |
|
3023 | var translate = rtlTranslate ? swiper.translate : -swiper.translate;
|
3024 |
|
3025 | function normalize(val) {
|
3026 | if (val < 0) return -Math.floor(Math.abs(val));
|
3027 | return Math.floor(val);
|
3028 | }
|
3029 |
|
3030 | var normalizedTranslate = normalize(translate);
|
3031 | var normalizedSnapGrid = snapGrid.map(function (val) {
|
3032 | return normalize(val);
|
3033 | });
|
3034 | snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate)];
|
3035 | var prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
|
3036 |
|
3037 | if (typeof prevSnap === 'undefined' && params.cssMode) {
|
3038 | snapGrid.forEach(function (snap) {
|
3039 | if (!prevSnap && normalizedTranslate >= snap) prevSnap = snap;
|
3040 | });
|
3041 | }
|
3042 |
|
3043 | var prevIndex;
|
3044 |
|
3045 | if (typeof prevSnap !== 'undefined') {
|
3046 | prevIndex = slidesGrid.indexOf(prevSnap);
|
3047 | if (prevIndex < 0) prevIndex = swiper.activeIndex - 1;
|
3048 | }
|
3049 |
|
3050 | return swiper.slideTo(prevIndex, speed, runCallbacks, internal);
|
3051 | }
|
3052 |
|
3053 |
|
3054 | function slideReset(speed, runCallbacks, internal) {
|
3055 | if (speed === void 0) {
|
3056 | speed = this.params.speed;
|
3057 | }
|
3058 |
|
3059 | if (runCallbacks === void 0) {
|
3060 | runCallbacks = true;
|
3061 | }
|
3062 |
|
3063 | var swiper = this;
|
3064 | return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal);
|
3065 | }
|
3066 |
|
3067 |
|
3068 | function slideToClosest(speed, runCallbacks, internal, threshold) {
|
3069 | if (speed === void 0) {
|
3070 | speed = this.params.speed;
|
3071 | }
|
3072 |
|
3073 | if (runCallbacks === void 0) {
|
3074 | runCallbacks = true;
|
3075 | }
|
3076 |
|
3077 | if (threshold === void 0) {
|
3078 | threshold = 0.5;
|
3079 | }
|
3080 |
|
3081 | var swiper = this;
|
3082 | var index = swiper.activeIndex;
|
3083 | var skip = Math.min(swiper.params.slidesPerGroupSkip, index);
|
3084 | var snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup);
|
3085 | var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate;
|
3086 |
|
3087 | if (translate >= swiper.snapGrid[snapIndex]) {
|
3088 |
|
3089 |
|
3090 | var currentSnap = swiper.snapGrid[snapIndex];
|
3091 | var nextSnap = swiper.snapGrid[snapIndex + 1];
|
3092 |
|
3093 | if (translate - currentSnap > (nextSnap - currentSnap) * threshold) {
|
3094 | index += swiper.params.slidesPerGroup;
|
3095 | }
|
3096 | } else {
|
3097 |
|
3098 |
|
3099 | var prevSnap = swiper.snapGrid[snapIndex - 1];
|
3100 | var _currentSnap = swiper.snapGrid[snapIndex];
|
3101 |
|
3102 | if (translate - prevSnap <= (_currentSnap - prevSnap) * threshold) {
|
3103 | index -= swiper.params.slidesPerGroup;
|
3104 | }
|
3105 | }
|
3106 |
|
3107 | index = Math.max(index, 0);
|
3108 | index = Math.min(index, swiper.slidesGrid.length - 1);
|
3109 | return swiper.slideTo(index, speed, runCallbacks, internal);
|
3110 | }
|
3111 |
|
3112 | function slideToClickedSlide() {
|
3113 | var swiper = this;
|
3114 | var params = swiper.params,
|
3115 | $wrapperEl = swiper.$wrapperEl;
|
3116 | var slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView;
|
3117 | var slideToIndex = swiper.clickedIndex;
|
3118 | var realIndex;
|
3119 |
|
3120 | if (params.loop) {
|
3121 | if (swiper.animating) return;
|
3122 | realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10);
|
3123 |
|
3124 | if (params.centeredSlides) {
|
3125 | if (slideToIndex < swiper.loopedSlides - slidesPerView / 2 || slideToIndex > swiper.slides.length - swiper.loopedSlides + slidesPerView / 2) {
|
3126 | swiper.loopFix();
|
3127 | slideToIndex = $wrapperEl.children("." + params.slideClass + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + params.slideDuplicateClass + ")").eq(0).index();
|
3128 | nextTick(function () {
|
3129 | swiper.slideTo(slideToIndex);
|
3130 | });
|
3131 | } else {
|
3132 | swiper.slideTo(slideToIndex);
|
3133 | }
|
3134 | } else if (slideToIndex > swiper.slides.length - slidesPerView) {
|
3135 | swiper.loopFix();
|
3136 | slideToIndex = $wrapperEl.children("." + params.slideClass + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + params.slideDuplicateClass + ")").eq(0).index();
|
3137 | nextTick(function () {
|
3138 | swiper.slideTo(slideToIndex);
|
3139 | });
|
3140 | } else {
|
3141 | swiper.slideTo(slideToIndex);
|
3142 | }
|
3143 | } else {
|
3144 | swiper.slideTo(slideToIndex);
|
3145 | }
|
3146 | }
|
3147 |
|
3148 | var slide = {
|
3149 | slideTo: slideTo,
|
3150 | slideToLoop: slideToLoop,
|
3151 | slideNext: slideNext,
|
3152 | slidePrev: slidePrev,
|
3153 | slideReset: slideReset,
|
3154 | slideToClosest: slideToClosest,
|
3155 | slideToClickedSlide: slideToClickedSlide
|
3156 | };
|
3157 |
|
3158 | function loopCreate() {
|
3159 | var swiper = this;
|
3160 | var document = getDocument();
|
3161 | var params = swiper.params,
|
3162 | $wrapperEl = swiper.$wrapperEl;
|
3163 |
|
3164 | $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass).remove();
|
3165 | var slides = $wrapperEl.children("." + params.slideClass);
|
3166 |
|
3167 | if (params.loopFillGroupWithBlank) {
|
3168 | var blankSlidesNum = params.slidesPerGroup - slides.length % params.slidesPerGroup;
|
3169 |
|
3170 | if (blankSlidesNum !== params.slidesPerGroup) {
|
3171 | for (var i = 0; i < blankSlidesNum; i += 1) {
|
3172 | var blankNode = $(document.createElement('div')).addClass(params.slideClass + " " + params.slideBlankClass);
|
3173 | $wrapperEl.append(blankNode);
|
3174 | }
|
3175 |
|
3176 | slides = $wrapperEl.children("." + params.slideClass);
|
3177 | }
|
3178 | }
|
3179 |
|
3180 | if (params.slidesPerView === 'auto' && !params.loopedSlides) params.loopedSlides = slides.length;
|
3181 | swiper.loopedSlides = Math.ceil(parseFloat(params.loopedSlides || params.slidesPerView, 10));
|
3182 | swiper.loopedSlides += params.loopAdditionalSlides;
|
3183 |
|
3184 | if (swiper.loopedSlides > slides.length) {
|
3185 | swiper.loopedSlides = slides.length;
|
3186 | }
|
3187 |
|
3188 | var prependSlides = [];
|
3189 | var appendSlides = [];
|
3190 | slides.each(function (el, index) {
|
3191 | var slide = $(el);
|
3192 |
|
3193 | if (index < swiper.loopedSlides) {
|
3194 | appendSlides.push(el);
|
3195 | }
|
3196 |
|
3197 | if (index < slides.length && index >= slides.length - swiper.loopedSlides) {
|
3198 | prependSlides.push(el);
|
3199 | }
|
3200 |
|
3201 | slide.attr('data-swiper-slide-index', index);
|
3202 | });
|
3203 |
|
3204 | for (var _i = 0; _i < appendSlides.length; _i += 1) {
|
3205 | $wrapperEl.append($(appendSlides[_i].cloneNode(true)).addClass(params.slideDuplicateClass));
|
3206 | }
|
3207 |
|
3208 | for (var _i2 = prependSlides.length - 1; _i2 >= 0; _i2 -= 1) {
|
3209 | $wrapperEl.prepend($(prependSlides[_i2].cloneNode(true)).addClass(params.slideDuplicateClass));
|
3210 | }
|
3211 | }
|
3212 |
|
3213 | function loopFix() {
|
3214 | var swiper = this;
|
3215 | swiper.emit('beforeLoopFix');
|
3216 | var activeIndex = swiper.activeIndex,
|
3217 | slides = swiper.slides,
|
3218 | loopedSlides = swiper.loopedSlides,
|
3219 | allowSlidePrev = swiper.allowSlidePrev,
|
3220 | allowSlideNext = swiper.allowSlideNext,
|
3221 | snapGrid = swiper.snapGrid,
|
3222 | rtl = swiper.rtlTranslate;
|
3223 | var newIndex;
|
3224 | swiper.allowSlidePrev = true;
|
3225 | swiper.allowSlideNext = true;
|
3226 | var snapTranslate = -snapGrid[activeIndex];
|
3227 | var diff = snapTranslate - swiper.getTranslate();
|
3228 |
|
3229 | if (activeIndex < loopedSlides) {
|
3230 | newIndex = slides.length - loopedSlides * 3 + activeIndex;
|
3231 | newIndex += loopedSlides;
|
3232 | var slideChanged = swiper.slideTo(newIndex, 0, false, true);
|
3233 |
|
3234 | if (slideChanged && diff !== 0) {
|
3235 | swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
|
3236 | }
|
3237 | } else if (activeIndex >= slides.length - loopedSlides) {
|
3238 |
|
3239 | newIndex = -slides.length + activeIndex + loopedSlides;
|
3240 | newIndex += loopedSlides;
|
3241 |
|
3242 | var _slideChanged = swiper.slideTo(newIndex, 0, false, true);
|
3243 |
|
3244 | if (_slideChanged && diff !== 0) {
|
3245 | swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff);
|
3246 | }
|
3247 | }
|
3248 |
|
3249 | swiper.allowSlidePrev = allowSlidePrev;
|
3250 | swiper.allowSlideNext = allowSlideNext;
|
3251 | swiper.emit('loopFix');
|
3252 | }
|
3253 |
|
3254 | function loopDestroy() {
|
3255 | var swiper = this;
|
3256 | var $wrapperEl = swiper.$wrapperEl,
|
3257 | params = swiper.params,
|
3258 | slides = swiper.slides;
|
3259 | $wrapperEl.children("." + params.slideClass + "." + params.slideDuplicateClass + ",." + params.slideClass + "." + params.slideBlankClass).remove();
|
3260 | slides.removeAttr('data-swiper-slide-index');
|
3261 | }
|
3262 |
|
3263 | var loop = {
|
3264 | loopCreate: loopCreate,
|
3265 | loopFix: loopFix,
|
3266 | loopDestroy: loopDestroy
|
3267 | };
|
3268 |
|
3269 | function setGrabCursor(moving) {
|
3270 | var swiper = this;
|
3271 | if (swiper.support.touch || !swiper.params.simulateTouch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) return;
|
3272 | var el = swiper.el;
|
3273 | el.style.cursor = 'move';
|
3274 | el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab';
|
3275 | el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab';
|
3276 | el.style.cursor = moving ? 'grabbing' : 'grab';
|
3277 | }
|
3278 |
|
3279 | function unsetGrabCursor() {
|
3280 | var swiper = this;
|
3281 |
|
3282 | if (swiper.support.touch || swiper.params.watchOverflow && swiper.isLocked || swiper.params.cssMode) {
|
3283 | return;
|
3284 | }
|
3285 |
|
3286 | swiper.el.style.cursor = '';
|
3287 | }
|
3288 |
|
3289 | var grabCursor = {
|
3290 | setGrabCursor: setGrabCursor,
|
3291 | unsetGrabCursor: unsetGrabCursor
|
3292 | };
|
3293 |
|
3294 | function appendSlide(slides) {
|
3295 | var swiper = this;
|
3296 | var $wrapperEl = swiper.$wrapperEl,
|
3297 | params = swiper.params;
|
3298 |
|
3299 | if (params.loop) {
|
3300 | swiper.loopDestroy();
|
3301 | }
|
3302 |
|
3303 | if (typeof slides === 'object' && 'length' in slides) {
|
3304 | for (var i = 0; i < slides.length; i += 1) {
|
3305 | if (slides[i]) $wrapperEl.append(slides[i]);
|
3306 | }
|
3307 | } else {
|
3308 | $wrapperEl.append(slides);
|
3309 | }
|
3310 |
|
3311 | if (params.loop) {
|
3312 | swiper.loopCreate();
|
3313 | }
|
3314 |
|
3315 | if (!(params.observer && swiper.support.observer)) {
|
3316 | swiper.update();
|
3317 | }
|
3318 | }
|
3319 |
|
3320 | function prependSlide(slides) {
|
3321 | var swiper = this;
|
3322 | var params = swiper.params,
|
3323 | $wrapperEl = swiper.$wrapperEl,
|
3324 | activeIndex = swiper.activeIndex;
|
3325 |
|
3326 | if (params.loop) {
|
3327 | swiper.loopDestroy();
|
3328 | }
|
3329 |
|
3330 | var newActiveIndex = activeIndex + 1;
|
3331 |
|
3332 | if (typeof slides === 'object' && 'length' in slides) {
|
3333 | for (var i = 0; i < slides.length; i += 1) {
|
3334 | if (slides[i]) $wrapperEl.prepend(slides[i]);
|
3335 | }
|
3336 |
|
3337 | newActiveIndex = activeIndex + slides.length;
|
3338 | } else {
|
3339 | $wrapperEl.prepend(slides);
|
3340 | }
|
3341 |
|
3342 | if (params.loop) {
|
3343 | swiper.loopCreate();
|
3344 | }
|
3345 |
|
3346 | if (!(params.observer && swiper.support.observer)) {
|
3347 | swiper.update();
|
3348 | }
|
3349 |
|
3350 | swiper.slideTo(newActiveIndex, 0, false);
|
3351 | }
|
3352 |
|
3353 | function addSlide(index, slides) {
|
3354 | var swiper = this;
|
3355 | var $wrapperEl = swiper.$wrapperEl,
|
3356 | params = swiper.params,
|
3357 | activeIndex = swiper.activeIndex;
|
3358 | var activeIndexBuffer = activeIndex;
|
3359 |
|
3360 | if (params.loop) {
|
3361 | activeIndexBuffer -= swiper.loopedSlides;
|
3362 | swiper.loopDestroy();
|
3363 | swiper.slides = $wrapperEl.children("." + params.slideClass);
|
3364 | }
|
3365 |
|
3366 | var baseLength = swiper.slides.length;
|
3367 |
|
3368 | if (index <= 0) {
|
3369 | swiper.prependSlide(slides);
|
3370 | return;
|
3371 | }
|
3372 |
|
3373 | if (index >= baseLength) {
|
3374 | swiper.appendSlide(slides);
|
3375 | return;
|
3376 | }
|
3377 |
|
3378 | var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer;
|
3379 | var slidesBuffer = [];
|
3380 |
|
3381 | for (var i = baseLength - 1; i >= index; i -= 1) {
|
3382 | var currentSlide = swiper.slides.eq(i);
|
3383 | currentSlide.remove();
|
3384 | slidesBuffer.unshift(currentSlide);
|
3385 | }
|
3386 |
|
3387 | if (typeof slides === 'object' && 'length' in slides) {
|
3388 | for (var _i = 0; _i < slides.length; _i += 1) {
|
3389 | if (slides[_i]) $wrapperEl.append(slides[_i]);
|
3390 | }
|
3391 |
|
3392 | newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer;
|
3393 | } else {
|
3394 | $wrapperEl.append(slides);
|
3395 | }
|
3396 |
|
3397 | for (var _i2 = 0; _i2 < slidesBuffer.length; _i2 += 1) {
|
3398 | $wrapperEl.append(slidesBuffer[_i2]);
|
3399 | }
|
3400 |
|
3401 | if (params.loop) {
|
3402 | swiper.loopCreate();
|
3403 | }
|
3404 |
|
3405 | if (!(params.observer && swiper.support.observer)) {
|
3406 | swiper.update();
|
3407 | }
|
3408 |
|
3409 | if (params.loop) {
|
3410 | swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
|
3411 | } else {
|
3412 | swiper.slideTo(newActiveIndex, 0, false);
|
3413 | }
|
3414 | }
|
3415 |
|
3416 | function removeSlide(slidesIndexes) {
|
3417 | var swiper = this;
|
3418 | var params = swiper.params,
|
3419 | $wrapperEl = swiper.$wrapperEl,
|
3420 | activeIndex = swiper.activeIndex;
|
3421 | var activeIndexBuffer = activeIndex;
|
3422 |
|
3423 | if (params.loop) {
|
3424 | activeIndexBuffer -= swiper.loopedSlides;
|
3425 | swiper.loopDestroy();
|
3426 | swiper.slides = $wrapperEl.children("." + params.slideClass);
|
3427 | }
|
3428 |
|
3429 | var newActiveIndex = activeIndexBuffer;
|
3430 | var indexToRemove;
|
3431 |
|
3432 | if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) {
|
3433 | for (var i = 0; i < slidesIndexes.length; i += 1) {
|
3434 | indexToRemove = slidesIndexes[i];
|
3435 | if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove();
|
3436 | if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
|
3437 | }
|
3438 |
|
3439 | newActiveIndex = Math.max(newActiveIndex, 0);
|
3440 | } else {
|
3441 | indexToRemove = slidesIndexes;
|
3442 | if (swiper.slides[indexToRemove]) swiper.slides.eq(indexToRemove).remove();
|
3443 | if (indexToRemove < newActiveIndex) newActiveIndex -= 1;
|
3444 | newActiveIndex = Math.max(newActiveIndex, 0);
|
3445 | }
|
3446 |
|
3447 | if (params.loop) {
|
3448 | swiper.loopCreate();
|
3449 | }
|
3450 |
|
3451 | if (!(params.observer && swiper.support.observer)) {
|
3452 | swiper.update();
|
3453 | }
|
3454 |
|
3455 | if (params.loop) {
|
3456 | swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false);
|
3457 | } else {
|
3458 | swiper.slideTo(newActiveIndex, 0, false);
|
3459 | }
|
3460 | }
|
3461 |
|
3462 | function removeAllSlides() {
|
3463 | var swiper = this;
|
3464 | var slidesIndexes = [];
|
3465 |
|
3466 | for (var i = 0; i < swiper.slides.length; i += 1) {
|
3467 | slidesIndexes.push(i);
|
3468 | }
|
3469 |
|
3470 | swiper.removeSlide(slidesIndexes);
|
3471 | }
|
3472 |
|
3473 | var manipulation = {
|
3474 | appendSlide: appendSlide,
|
3475 | prependSlide: prependSlide,
|
3476 | addSlide: addSlide,
|
3477 | removeSlide: removeSlide,
|
3478 | removeAllSlides: removeAllSlides
|
3479 | };
|
3480 |
|
3481 | function onTouchStart(event) {
|
3482 | var swiper = this;
|
3483 | var document = getDocument();
|
3484 | var window = getWindow();
|
3485 | var data = swiper.touchEventsData;
|
3486 | var params = swiper.params,
|
3487 | touches = swiper.touches;
|
3488 |
|
3489 | if (swiper.animating && params.preventInteractionOnTransition) {
|
3490 | return;
|
3491 | }
|
3492 |
|
3493 | var e = event;
|
3494 | if (e.originalEvent) e = e.originalEvent;
|
3495 | var $targetEl = $(e.target);
|
3496 |
|
3497 | if (params.touchEventsTarget === 'wrapper') {
|
3498 | if (!$targetEl.closest(swiper.wrapperEl).length) return;
|
3499 | }
|
3500 |
|
3501 | data.isTouchEvent = e.type === 'touchstart';
|
3502 | if (!data.isTouchEvent && 'which' in e && e.which === 3) return;
|
3503 | if (!data.isTouchEvent && 'button' in e && e.button > 0) return;
|
3504 | if (data.isTouched && data.isMoved) return;
|
3505 |
|
3506 | var swipingClassHasValue = !!params.noSwipingClass && params.noSwipingClass !== '';
|
3507 |
|
3508 | if (swipingClassHasValue && e.target && e.target.shadowRoot && event.path && event.path[0]) {
|
3509 | $targetEl = $(event.path[0]);
|
3510 | }
|
3511 |
|
3512 | if (params.noSwiping && $targetEl.closest(params.noSwipingSelector ? params.noSwipingSelector : "." + params.noSwipingClass)[0]) {
|
3513 | swiper.allowClick = true;
|
3514 | return;
|
3515 | }
|
3516 |
|
3517 | if (params.swipeHandler) {
|
3518 | if (!$targetEl.closest(params.swipeHandler)[0]) return;
|
3519 | }
|
3520 |
|
3521 | touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
|
3522 | touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
|
3523 | var startX = touches.currentX;
|
3524 | var startY = touches.currentY;
|
3525 |
|
3526 | var edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection;
|
3527 | var edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold;
|
3528 |
|
3529 | if (edgeSwipeDetection && (startX <= edgeSwipeThreshold || startX >= window.innerWidth - edgeSwipeThreshold)) {
|
3530 | if (edgeSwipeDetection === 'prevent') {
|
3531 | event.preventDefault();
|
3532 | } else {
|
3533 | return;
|
3534 | }
|
3535 | }
|
3536 |
|
3537 | extend(data, {
|
3538 | isTouched: true,
|
3539 | isMoved: false,
|
3540 | allowTouchCallbacks: true,
|
3541 | isScrolling: undefined,
|
3542 | startMoving: undefined
|
3543 | });
|
3544 | touches.startX = startX;
|
3545 | touches.startY = startY;
|
3546 | data.touchStartTime = now();
|
3547 | swiper.allowClick = true;
|
3548 | swiper.updateSize();
|
3549 | swiper.swipeDirection = undefined;
|
3550 | if (params.threshold > 0) data.allowThresholdMove = false;
|
3551 |
|
3552 | if (e.type !== 'touchstart') {
|
3553 | var preventDefault = true;
|
3554 | if ($targetEl.is(data.formElements)) preventDefault = false;
|
3555 |
|
3556 | if (document.activeElement && $(document.activeElement).is(data.formElements) && document.activeElement !== $targetEl[0]) {
|
3557 | document.activeElement.blur();
|
3558 | }
|
3559 |
|
3560 | var shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault;
|
3561 |
|
3562 | if ((params.touchStartForcePreventDefault || shouldPreventDefault) && !$targetEl[0].isContentEditable) {
|
3563 | e.preventDefault();
|
3564 | }
|
3565 | }
|
3566 |
|
3567 | swiper.emit('touchStart', e);
|
3568 | }
|
3569 |
|
3570 | function onTouchMove(event) {
|
3571 | var document = getDocument();
|
3572 | var swiper = this;
|
3573 | var data = swiper.touchEventsData;
|
3574 | var params = swiper.params,
|
3575 | touches = swiper.touches,
|
3576 | rtl = swiper.rtlTranslate;
|
3577 | var e = event;
|
3578 | if (e.originalEvent) e = e.originalEvent;
|
3579 |
|
3580 | if (!data.isTouched) {
|
3581 | if (data.startMoving && data.isScrolling) {
|
3582 | swiper.emit('touchMoveOpposite', e);
|
3583 | }
|
3584 |
|
3585 | return;
|
3586 | }
|
3587 |
|
3588 | if (data.isTouchEvent && e.type !== 'touchmove') return;
|
3589 | var targetTouch = e.type === 'touchmove' && e.targetTouches && (e.targetTouches[0] || e.changedTouches[0]);
|
3590 | var pageX = e.type === 'touchmove' ? targetTouch.pageX : e.pageX;
|
3591 | var pageY = e.type === 'touchmove' ? targetTouch.pageY : e.pageY;
|
3592 |
|
3593 | if (e.preventedByNestedSwiper) {
|
3594 | touches.startX = pageX;
|
3595 | touches.startY = pageY;
|
3596 | return;
|
3597 | }
|
3598 |
|
3599 | if (!swiper.allowTouchMove) {
|
3600 |
|
3601 | swiper.allowClick = false;
|
3602 |
|
3603 | if (data.isTouched) {
|
3604 | extend(touches, {
|
3605 | startX: pageX,
|
3606 | startY: pageY,
|
3607 | currentX: pageX,
|
3608 | currentY: pageY
|
3609 | });
|
3610 | data.touchStartTime = now();
|
3611 | }
|
3612 |
|
3613 | return;
|
3614 | }
|
3615 |
|
3616 | if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) {
|
3617 | if (swiper.isVertical()) {
|
3618 |
|
3619 | if (pageY < touches.startY && swiper.translate <= swiper.maxTranslate() || pageY > touches.startY && swiper.translate >= swiper.minTranslate()) {
|
3620 | data.isTouched = false;
|
3621 | data.isMoved = false;
|
3622 | return;
|
3623 | }
|
3624 | } else if (pageX < touches.startX && swiper.translate <= swiper.maxTranslate() || pageX > touches.startX && swiper.translate >= swiper.minTranslate()) {
|
3625 | return;
|
3626 | }
|
3627 | }
|
3628 |
|
3629 | if (data.isTouchEvent && document.activeElement) {
|
3630 | if (e.target === document.activeElement && $(e.target).is(data.formElements)) {
|
3631 | data.isMoved = true;
|
3632 | swiper.allowClick = false;
|
3633 | return;
|
3634 | }
|
3635 | }
|
3636 |
|
3637 | if (data.allowTouchCallbacks) {
|
3638 | swiper.emit('touchMove', e);
|
3639 | }
|
3640 |
|
3641 | if (e.targetTouches && e.targetTouches.length > 1) return;
|
3642 | touches.currentX = pageX;
|
3643 | touches.currentY = pageY;
|
3644 | var diffX = touches.currentX - touches.startX;
|
3645 | var diffY = touches.currentY - touches.startY;
|
3646 | if (swiper.params.threshold && Math.sqrt(Math.pow(diffX, 2) + Math.pow(diffY, 2)) < swiper.params.threshold) return;
|
3647 |
|
3648 | if (typeof data.isScrolling === 'undefined') {
|
3649 | var touchAngle;
|
3650 |
|
3651 | if (swiper.isHorizontal() && touches.currentY === touches.startY || swiper.isVertical() && touches.currentX === touches.startX) {
|
3652 | data.isScrolling = false;
|
3653 | } else {
|
3654 |
|
3655 | if (diffX * diffX + diffY * diffY >= 25) {
|
3656 | touchAngle = Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180 / Math.PI;
|
3657 | data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : 90 - touchAngle > params.touchAngle;
|
3658 | }
|
3659 | }
|
3660 | }
|
3661 |
|
3662 | if (data.isScrolling) {
|
3663 | swiper.emit('touchMoveOpposite', e);
|
3664 | }
|
3665 |
|
3666 | if (typeof data.startMoving === 'undefined') {
|
3667 | if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) {
|
3668 | data.startMoving = true;
|
3669 | }
|
3670 | }
|
3671 |
|
3672 | if (data.isScrolling) {
|
3673 | data.isTouched = false;
|
3674 | return;
|
3675 | }
|
3676 |
|
3677 | if (!data.startMoving) {
|
3678 | return;
|
3679 | }
|
3680 |
|
3681 | swiper.allowClick = false;
|
3682 |
|
3683 | if (!params.cssMode && e.cancelable) {
|
3684 | e.preventDefault();
|
3685 | }
|
3686 |
|
3687 | if (params.touchMoveStopPropagation && !params.nested) {
|
3688 | e.stopPropagation();
|
3689 | }
|
3690 |
|
3691 | if (!data.isMoved) {
|
3692 | if (params.loop) {
|
3693 | swiper.loopFix();
|
3694 | }
|
3695 |
|
3696 | data.startTranslate = swiper.getTranslate();
|
3697 | swiper.setTransition(0);
|
3698 |
|
3699 | if (swiper.animating) {
|
3700 | swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend');
|
3701 | }
|
3702 |
|
3703 | data.allowMomentumBounce = false;
|
3704 |
|
3705 | if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
3706 | swiper.setGrabCursor(true);
|
3707 | }
|
3708 |
|
3709 | swiper.emit('sliderFirstMove', e);
|
3710 | }
|
3711 |
|
3712 | swiper.emit('sliderMove', e);
|
3713 | data.isMoved = true;
|
3714 | var diff = swiper.isHorizontal() ? diffX : diffY;
|
3715 | touches.diff = diff;
|
3716 | diff *= params.touchRatio;
|
3717 | if (rtl) diff = -diff;
|
3718 | swiper.swipeDirection = diff > 0 ? 'prev' : 'next';
|
3719 | data.currentTranslate = diff + data.startTranslate;
|
3720 | var disableParentSwiper = true;
|
3721 | var resistanceRatio = params.resistanceRatio;
|
3722 |
|
3723 | if (params.touchReleaseOnEdges) {
|
3724 | resistanceRatio = 0;
|
3725 | }
|
3726 |
|
3727 | if (diff > 0 && data.currentTranslate > swiper.minTranslate()) {
|
3728 | disableParentSwiper = false;
|
3729 | if (params.resistance) data.currentTranslate = swiper.minTranslate() - 1 + Math.pow(-swiper.minTranslate() + data.startTranslate + diff, resistanceRatio);
|
3730 | } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) {
|
3731 | disableParentSwiper = false;
|
3732 | if (params.resistance) data.currentTranslate = swiper.maxTranslate() + 1 - Math.pow(swiper.maxTranslate() - data.startTranslate - diff, resistanceRatio);
|
3733 | }
|
3734 |
|
3735 | if (disableParentSwiper) {
|
3736 | e.preventedByNestedSwiper = true;
|
3737 | }
|
3738 |
|
3739 |
|
3740 | if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) {
|
3741 | data.currentTranslate = data.startTranslate;
|
3742 | }
|
3743 |
|
3744 | if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) {
|
3745 | data.currentTranslate = data.startTranslate;
|
3746 | }
|
3747 |
|
3748 | if (!swiper.allowSlidePrev && !swiper.allowSlideNext) {
|
3749 | data.currentTranslate = data.startTranslate;
|
3750 | }
|
3751 |
|
3752 |
|
3753 | if (params.threshold > 0) {
|
3754 | if (Math.abs(diff) > params.threshold || data.allowThresholdMove) {
|
3755 | if (!data.allowThresholdMove) {
|
3756 | data.allowThresholdMove = true;
|
3757 | touches.startX = touches.currentX;
|
3758 | touches.startY = touches.currentY;
|
3759 | data.currentTranslate = data.startTranslate;
|
3760 | touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY;
|
3761 | return;
|
3762 | }
|
3763 | } else {
|
3764 | data.currentTranslate = data.startTranslate;
|
3765 | return;
|
3766 | }
|
3767 | }
|
3768 |
|
3769 | if (!params.followFinger || params.cssMode) return;
|
3770 |
|
3771 | if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) {
|
3772 | swiper.updateActiveIndex();
|
3773 | swiper.updateSlidesClasses();
|
3774 | }
|
3775 |
|
3776 | if (params.freeMode) {
|
3777 |
|
3778 | if (data.velocities.length === 0) {
|
3779 | data.velocities.push({
|
3780 | position: touches[swiper.isHorizontal() ? 'startX' : 'startY'],
|
3781 | time: data.touchStartTime
|
3782 | });
|
3783 | }
|
3784 |
|
3785 | data.velocities.push({
|
3786 | position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'],
|
3787 | time: now()
|
3788 | });
|
3789 | }
|
3790 |
|
3791 |
|
3792 | swiper.updateProgress(data.currentTranslate);
|
3793 |
|
3794 | swiper.setTranslate(data.currentTranslate);
|
3795 | }
|
3796 |
|
3797 | function onTouchEnd(event) {
|
3798 | var swiper = this;
|
3799 | var data = swiper.touchEventsData;
|
3800 | var params = swiper.params,
|
3801 | touches = swiper.touches,
|
3802 | rtl = swiper.rtlTranslate,
|
3803 | $wrapperEl = swiper.$wrapperEl,
|
3804 | slidesGrid = swiper.slidesGrid,
|
3805 | snapGrid = swiper.snapGrid;
|
3806 | var e = event;
|
3807 | if (e.originalEvent) e = e.originalEvent;
|
3808 |
|
3809 | if (data.allowTouchCallbacks) {
|
3810 | swiper.emit('touchEnd', e);
|
3811 | }
|
3812 |
|
3813 | data.allowTouchCallbacks = false;
|
3814 |
|
3815 | if (!data.isTouched) {
|
3816 | if (data.isMoved && params.grabCursor) {
|
3817 | swiper.setGrabCursor(false);
|
3818 | }
|
3819 |
|
3820 | data.isMoved = false;
|
3821 | data.startMoving = false;
|
3822 | return;
|
3823 | }
|
3824 |
|
3825 |
|
3826 | if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) {
|
3827 | swiper.setGrabCursor(false);
|
3828 | }
|
3829 |
|
3830 |
|
3831 | var touchEndTime = now();
|
3832 | var timeDiff = touchEndTime - data.touchStartTime;
|
3833 |
|
3834 | if (swiper.allowClick) {
|
3835 | swiper.updateClickedSlide(e);
|
3836 | swiper.emit('tap click', e);
|
3837 |
|
3838 | if (timeDiff < 300 && touchEndTime - data.lastClickTime < 300) {
|
3839 | swiper.emit('doubleTap doubleClick', e);
|
3840 | }
|
3841 | }
|
3842 |
|
3843 | data.lastClickTime = now();
|
3844 | nextTick(function () {
|
3845 | if (!swiper.destroyed) swiper.allowClick = true;
|
3846 | });
|
3847 |
|
3848 | if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) {
|
3849 | data.isTouched = false;
|
3850 | data.isMoved = false;
|
3851 | data.startMoving = false;
|
3852 | return;
|
3853 | }
|
3854 |
|
3855 | data.isTouched = false;
|
3856 | data.isMoved = false;
|
3857 | data.startMoving = false;
|
3858 | var currentPos;
|
3859 |
|
3860 | if (params.followFinger) {
|
3861 | currentPos = rtl ? swiper.translate : -swiper.translate;
|
3862 | } else {
|
3863 | currentPos = -data.currentTranslate;
|
3864 | }
|
3865 |
|
3866 | if (params.cssMode) {
|
3867 | return;
|
3868 | }
|
3869 |
|
3870 | if (params.freeMode) {
|
3871 | if (currentPos < -swiper.minTranslate()) {
|
3872 | swiper.slideTo(swiper.activeIndex);
|
3873 | return;
|
3874 | }
|
3875 |
|
3876 | if (currentPos > -swiper.maxTranslate()) {
|
3877 | if (swiper.slides.length < snapGrid.length) {
|
3878 | swiper.slideTo(snapGrid.length - 1);
|
3879 | } else {
|
3880 | swiper.slideTo(swiper.slides.length - 1);
|
3881 | }
|
3882 |
|
3883 | return;
|
3884 | }
|
3885 |
|
3886 | if (params.freeModeMomentum) {
|
3887 | if (data.velocities.length > 1) {
|
3888 | var lastMoveEvent = data.velocities.pop();
|
3889 | var velocityEvent = data.velocities.pop();
|
3890 | var distance = lastMoveEvent.position - velocityEvent.position;
|
3891 | var time = lastMoveEvent.time - velocityEvent.time;
|
3892 | swiper.velocity = distance / time;
|
3893 | swiper.velocity /= 2;
|
3894 |
|
3895 | if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) {
|
3896 | swiper.velocity = 0;
|
3897 | }
|
3898 |
|
3899 |
|
3900 |
|
3901 | if (time > 150 || now() - lastMoveEvent.time > 300) {
|
3902 | swiper.velocity = 0;
|
3903 | }
|
3904 | } else {
|
3905 | swiper.velocity = 0;
|
3906 | }
|
3907 |
|
3908 | swiper.velocity *= params.freeModeMomentumVelocityRatio;
|
3909 | data.velocities.length = 0;
|
3910 | var momentumDuration = 1000 * params.freeModeMomentumRatio;
|
3911 | var momentumDistance = swiper.velocity * momentumDuration;
|
3912 | var newPosition = swiper.translate + momentumDistance;
|
3913 | if (rtl) newPosition = -newPosition;
|
3914 | var doBounce = false;
|
3915 | var afterBouncePosition;
|
3916 | var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio;
|
3917 | var needsLoopFix;
|
3918 |
|
3919 | if (newPosition < swiper.maxTranslate()) {
|
3920 | if (params.freeModeMomentumBounce) {
|
3921 | if (newPosition + swiper.maxTranslate() < -bounceAmount) {
|
3922 | newPosition = swiper.maxTranslate() - bounceAmount;
|
3923 | }
|
3924 |
|
3925 | afterBouncePosition = swiper.maxTranslate();
|
3926 | doBounce = true;
|
3927 | data.allowMomentumBounce = true;
|
3928 | } else {
|
3929 | newPosition = swiper.maxTranslate();
|
3930 | }
|
3931 |
|
3932 | if (params.loop && params.centeredSlides) needsLoopFix = true;
|
3933 | } else if (newPosition > swiper.minTranslate()) {
|
3934 | if (params.freeModeMomentumBounce) {
|
3935 | if (newPosition - swiper.minTranslate() > bounceAmount) {
|
3936 | newPosition = swiper.minTranslate() + bounceAmount;
|
3937 | }
|
3938 |
|
3939 | afterBouncePosition = swiper.minTranslate();
|
3940 | doBounce = true;
|
3941 | data.allowMomentumBounce = true;
|
3942 | } else {
|
3943 | newPosition = swiper.minTranslate();
|
3944 | }
|
3945 |
|
3946 | if (params.loop && params.centeredSlides) needsLoopFix = true;
|
3947 | } else if (params.freeModeSticky) {
|
3948 | var nextSlide;
|
3949 |
|
3950 | for (var j = 0; j < snapGrid.length; j += 1) {
|
3951 | if (snapGrid[j] > -newPosition) {
|
3952 | nextSlide = j;
|
3953 | break;
|
3954 | }
|
3955 | }
|
3956 |
|
3957 | if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') {
|
3958 | newPosition = snapGrid[nextSlide];
|
3959 | } else {
|
3960 | newPosition = snapGrid[nextSlide - 1];
|
3961 | }
|
3962 |
|
3963 | newPosition = -newPosition;
|
3964 | }
|
3965 |
|
3966 | if (needsLoopFix) {
|
3967 | swiper.once('transitionEnd', function () {
|
3968 | swiper.loopFix();
|
3969 | });
|
3970 | }
|
3971 |
|
3972 |
|
3973 | if (swiper.velocity !== 0) {
|
3974 | if (rtl) {
|
3975 | momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity);
|
3976 | } else {
|
3977 | momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity);
|
3978 | }
|
3979 |
|
3980 | if (params.freeModeSticky) {
|
3981 |
|
3982 |
|
3983 |
|
3984 |
|
3985 |
|
3986 |
|
3987 |
|
3988 | var moveDistance = Math.abs((rtl ? -newPosition : newPosition) - swiper.translate);
|
3989 | var currentSlideSize = swiper.slidesSizesGrid[swiper.activeIndex];
|
3990 |
|
3991 | if (moveDistance < currentSlideSize) {
|
3992 | momentumDuration = params.speed;
|
3993 | } else if (moveDistance < 2 * currentSlideSize) {
|
3994 | momentumDuration = params.speed * 1.5;
|
3995 | } else {
|
3996 | momentumDuration = params.speed * 2.5;
|
3997 | }
|
3998 | }
|
3999 | } else if (params.freeModeSticky) {
|
4000 | swiper.slideToClosest();
|
4001 | return;
|
4002 | }
|
4003 |
|
4004 | if (params.freeModeMomentumBounce && doBounce) {
|
4005 | swiper.updateProgress(afterBouncePosition);
|
4006 | swiper.setTransition(momentumDuration);
|
4007 | swiper.setTranslate(newPosition);
|
4008 | swiper.transitionStart(true, swiper.swipeDirection);
|
4009 | swiper.animating = true;
|
4010 | $wrapperEl.transitionEnd(function () {
|
4011 | if (!swiper || swiper.destroyed || !data.allowMomentumBounce) return;
|
4012 | swiper.emit('momentumBounce');
|
4013 | swiper.setTransition(params.speed);
|
4014 | setTimeout(function () {
|
4015 | swiper.setTranslate(afterBouncePosition);
|
4016 | $wrapperEl.transitionEnd(function () {
|
4017 | if (!swiper || swiper.destroyed) return;
|
4018 | swiper.transitionEnd();
|
4019 | });
|
4020 | }, 0);
|
4021 | });
|
4022 | } else if (swiper.velocity) {
|
4023 | swiper.updateProgress(newPosition);
|
4024 | swiper.setTransition(momentumDuration);
|
4025 | swiper.setTranslate(newPosition);
|
4026 | swiper.transitionStart(true, swiper.swipeDirection);
|
4027 |
|
4028 | if (!swiper.animating) {
|
4029 | swiper.animating = true;
|
4030 | $wrapperEl.transitionEnd(function () {
|
4031 | if (!swiper || swiper.destroyed) return;
|
4032 | swiper.transitionEnd();
|
4033 | });
|
4034 | }
|
4035 | } else {
|
4036 | swiper.emit('_freeModeNoMomentumRelease');
|
4037 | swiper.updateProgress(newPosition);
|
4038 | }
|
4039 |
|
4040 | swiper.updateActiveIndex();
|
4041 | swiper.updateSlidesClasses();
|
4042 | } else if (params.freeModeSticky) {
|
4043 | swiper.slideToClosest();
|
4044 | return;
|
4045 | } else if (params.freeMode) {
|
4046 | swiper.emit('_freeModeNoMomentumRelease');
|
4047 | }
|
4048 |
|
4049 | if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) {
|
4050 | swiper.updateProgress();
|
4051 | swiper.updateActiveIndex();
|
4052 | swiper.updateSlidesClasses();
|
4053 | }
|
4054 |
|
4055 | return;
|
4056 | }
|
4057 |
|
4058 |
|
4059 | var stopIndex = 0;
|
4060 | var groupSize = swiper.slidesSizesGrid[0];
|
4061 |
|
4062 | for (var i = 0; i < slidesGrid.length; i += i < params.slidesPerGroupSkip ? 1 : params.slidesPerGroup) {
|
4063 | var _increment = i < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
4064 |
|
4065 | if (typeof slidesGrid[i + _increment] !== 'undefined') {
|
4066 | if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + _increment]) {
|
4067 | stopIndex = i;
|
4068 | groupSize = slidesGrid[i + _increment] - slidesGrid[i];
|
4069 | }
|
4070 | } else if (currentPos >= slidesGrid[i]) {
|
4071 | stopIndex = i;
|
4072 | groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2];
|
4073 | }
|
4074 | }
|
4075 |
|
4076 |
|
4077 | var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize;
|
4078 | var increment = stopIndex < params.slidesPerGroupSkip - 1 ? 1 : params.slidesPerGroup;
|
4079 |
|
4080 | if (timeDiff > params.longSwipesMs) {
|
4081 |
|
4082 | if (!params.longSwipes) {
|
4083 | swiper.slideTo(swiper.activeIndex);
|
4084 | return;
|
4085 | }
|
4086 |
|
4087 | if (swiper.swipeDirection === 'next') {
|
4088 | if (ratio >= params.longSwipesRatio) swiper.slideTo(stopIndex + increment);else swiper.slideTo(stopIndex);
|
4089 | }
|
4090 |
|
4091 | if (swiper.swipeDirection === 'prev') {
|
4092 | if (ratio > 1 - params.longSwipesRatio) swiper.slideTo(stopIndex + increment);else swiper.slideTo(stopIndex);
|
4093 | }
|
4094 | } else {
|
4095 |
|
4096 | if (!params.shortSwipes) {
|
4097 | swiper.slideTo(swiper.activeIndex);
|
4098 | return;
|
4099 | }
|
4100 |
|
4101 | var isNavButtonTarget = swiper.navigation && (e.target === swiper.navigation.nextEl || e.target === swiper.navigation.prevEl);
|
4102 |
|
4103 | if (!isNavButtonTarget) {
|
4104 | if (swiper.swipeDirection === 'next') {
|
4105 | swiper.slideTo(stopIndex + increment);
|
4106 | }
|
4107 |
|
4108 | if (swiper.swipeDirection === 'prev') {
|
4109 | swiper.slideTo(stopIndex);
|
4110 | }
|
4111 | } else if (e.target === swiper.navigation.nextEl) {
|
4112 | swiper.slideTo(stopIndex + increment);
|
4113 | } else {
|
4114 | swiper.slideTo(stopIndex);
|
4115 | }
|
4116 | }
|
4117 | }
|
4118 |
|
4119 | function onResize() {
|
4120 | var swiper = this;
|
4121 | var params = swiper.params,
|
4122 | el = swiper.el;
|
4123 | if (el && el.offsetWidth === 0) return;
|
4124 |
|
4125 | if (params.breakpoints) {
|
4126 | swiper.setBreakpoint();
|
4127 | }
|
4128 |
|
4129 |
|
4130 | var allowSlideNext = swiper.allowSlideNext,
|
4131 | allowSlidePrev = swiper.allowSlidePrev,
|
4132 | snapGrid = swiper.snapGrid;
|
4133 |
|
4134 | swiper.allowSlideNext = true;
|
4135 | swiper.allowSlidePrev = true;
|
4136 | swiper.updateSize();
|
4137 | swiper.updateSlides();
|
4138 | swiper.updateSlidesClasses();
|
4139 |
|
4140 | if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.isBeginning && !swiper.params.centeredSlides) {
|
4141 | swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
4142 | } else {
|
4143 | swiper.slideTo(swiper.activeIndex, 0, false, true);
|
4144 | }
|
4145 |
|
4146 | if (swiper.autoplay && swiper.autoplay.running && swiper.autoplay.paused) {
|
4147 | swiper.autoplay.run();
|
4148 | }
|
4149 |
|
4150 |
|
4151 | swiper.allowSlidePrev = allowSlidePrev;
|
4152 | swiper.allowSlideNext = allowSlideNext;
|
4153 |
|
4154 | if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
4155 | swiper.checkOverflow();
|
4156 | }
|
4157 | }
|
4158 |
|
4159 | function onClick(e) {
|
4160 | var swiper = this;
|
4161 |
|
4162 | if (!swiper.allowClick) {
|
4163 | if (swiper.params.preventClicks) e.preventDefault();
|
4164 |
|
4165 | if (swiper.params.preventClicksPropagation && swiper.animating) {
|
4166 | e.stopPropagation();
|
4167 | e.stopImmediatePropagation();
|
4168 | }
|
4169 | }
|
4170 | }
|
4171 |
|
4172 | function onScroll() {
|
4173 | var swiper = this;
|
4174 | var wrapperEl = swiper.wrapperEl,
|
4175 | rtlTranslate = swiper.rtlTranslate;
|
4176 | swiper.previousTranslate = swiper.translate;
|
4177 |
|
4178 | if (swiper.isHorizontal()) {
|
4179 | if (rtlTranslate) {
|
4180 | swiper.translate = wrapperEl.scrollWidth - wrapperEl.offsetWidth - wrapperEl.scrollLeft;
|
4181 | } else {
|
4182 | swiper.translate = -wrapperEl.scrollLeft;
|
4183 | }
|
4184 | } else {
|
4185 | swiper.translate = -wrapperEl.scrollTop;
|
4186 | }
|
4187 |
|
4188 |
|
4189 | if (swiper.translate === -0) swiper.translate = 0;
|
4190 | swiper.updateActiveIndex();
|
4191 | swiper.updateSlidesClasses();
|
4192 | var newProgress;
|
4193 | var translatesDiff = swiper.maxTranslate() - swiper.minTranslate();
|
4194 |
|
4195 | if (translatesDiff === 0) {
|
4196 | newProgress = 0;
|
4197 | } else {
|
4198 | newProgress = (swiper.translate - swiper.minTranslate()) / translatesDiff;
|
4199 | }
|
4200 |
|
4201 | if (newProgress !== swiper.progress) {
|
4202 | swiper.updateProgress(rtlTranslate ? -swiper.translate : swiper.translate);
|
4203 | }
|
4204 |
|
4205 | swiper.emit('setTranslate', swiper.translate, false);
|
4206 | }
|
4207 |
|
4208 | var dummyEventAttached = false;
|
4209 |
|
4210 | function dummyEventListener() {}
|
4211 |
|
4212 | function attachEvents() {
|
4213 | var swiper = this;
|
4214 | var document = getDocument();
|
4215 | var params = swiper.params,
|
4216 | touchEvents = swiper.touchEvents,
|
4217 | el = swiper.el,
|
4218 | wrapperEl = swiper.wrapperEl,
|
4219 | device = swiper.device,
|
4220 | support = swiper.support;
|
4221 | swiper.onTouchStart = onTouchStart.bind(swiper);
|
4222 | swiper.onTouchMove = onTouchMove.bind(swiper);
|
4223 | swiper.onTouchEnd = onTouchEnd.bind(swiper);
|
4224 |
|
4225 | if (params.cssMode) {
|
4226 | swiper.onScroll = onScroll.bind(swiper);
|
4227 | }
|
4228 |
|
4229 | swiper.onClick = onClick.bind(swiper);
|
4230 | var capture = !!params.nested;
|
4231 |
|
4232 | if (!support.touch && support.pointerEvents) {
|
4233 | el.addEventListener(touchEvents.start, swiper.onTouchStart, false);
|
4234 | document.addEventListener(touchEvents.move, swiper.onTouchMove, capture);
|
4235 | document.addEventListener(touchEvents.end, swiper.onTouchEnd, false);
|
4236 | } else {
|
4237 | if (support.touch) {
|
4238 | var passiveListener = touchEvents.start === 'touchstart' && support.passiveListener && params.passiveListeners ? {
|
4239 | passive: true,
|
4240 | capture: false
|
4241 | } : false;
|
4242 | el.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
|
4243 | el.addEventListener(touchEvents.move, swiper.onTouchMove, support.passiveListener ? {
|
4244 | passive: false,
|
4245 | capture: capture
|
4246 | } : capture);
|
4247 | el.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
|
4248 |
|
4249 | if (touchEvents.cancel) {
|
4250 | el.addEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
|
4251 | }
|
4252 |
|
4253 | if (!dummyEventAttached) {
|
4254 | document.addEventListener('touchstart', dummyEventListener);
|
4255 | dummyEventAttached = true;
|
4256 | }
|
4257 | }
|
4258 |
|
4259 | if (params.simulateTouch && !device.ios && !device.android || params.simulateTouch && !support.touch && device.ios) {
|
4260 | el.addEventListener('mousedown', swiper.onTouchStart, false);
|
4261 | document.addEventListener('mousemove', swiper.onTouchMove, capture);
|
4262 | document.addEventListener('mouseup', swiper.onTouchEnd, false);
|
4263 | }
|
4264 | }
|
4265 |
|
4266 |
|
4267 | if (params.preventClicks || params.preventClicksPropagation) {
|
4268 | el.addEventListener('click', swiper.onClick, true);
|
4269 | }
|
4270 |
|
4271 | if (params.cssMode) {
|
4272 | wrapperEl.addEventListener('scroll', swiper.onScroll);
|
4273 | }
|
4274 |
|
4275 |
|
4276 | if (params.updateOnWindowResize) {
|
4277 | swiper.on(device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize, true);
|
4278 | } else {
|
4279 | swiper.on('observerUpdate', onResize, true);
|
4280 | }
|
4281 | }
|
4282 |
|
4283 | function detachEvents() {
|
4284 | var swiper = this;
|
4285 | var document = getDocument();
|
4286 | var params = swiper.params,
|
4287 | touchEvents = swiper.touchEvents,
|
4288 | el = swiper.el,
|
4289 | wrapperEl = swiper.wrapperEl,
|
4290 | device = swiper.device,
|
4291 | support = swiper.support;
|
4292 | var capture = !!params.nested;
|
4293 |
|
4294 | if (!support.touch && support.pointerEvents) {
|
4295 | el.removeEventListener(touchEvents.start, swiper.onTouchStart, false);
|
4296 | document.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
|
4297 | document.removeEventListener(touchEvents.end, swiper.onTouchEnd, false);
|
4298 | } else {
|
4299 | if (support.touch) {
|
4300 | var passiveListener = touchEvents.start === 'onTouchStart' && support.passiveListener && params.passiveListeners ? {
|
4301 | passive: true,
|
4302 | capture: false
|
4303 | } : false;
|
4304 | el.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener);
|
4305 | el.removeEventListener(touchEvents.move, swiper.onTouchMove, capture);
|
4306 | el.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener);
|
4307 |
|
4308 | if (touchEvents.cancel) {
|
4309 | el.removeEventListener(touchEvents.cancel, swiper.onTouchEnd, passiveListener);
|
4310 | }
|
4311 | }
|
4312 |
|
4313 | if (params.simulateTouch && !device.ios && !device.android || params.simulateTouch && !support.touch && device.ios) {
|
4314 | el.removeEventListener('mousedown', swiper.onTouchStart, false);
|
4315 | document.removeEventListener('mousemove', swiper.onTouchMove, capture);
|
4316 | document.removeEventListener('mouseup', swiper.onTouchEnd, false);
|
4317 | }
|
4318 | }
|
4319 |
|
4320 |
|
4321 | if (params.preventClicks || params.preventClicksPropagation) {
|
4322 | el.removeEventListener('click', swiper.onClick, true);
|
4323 | }
|
4324 |
|
4325 | if (params.cssMode) {
|
4326 | wrapperEl.removeEventListener('scroll', swiper.onScroll);
|
4327 | }
|
4328 |
|
4329 |
|
4330 | swiper.off(device.ios || device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate', onResize);
|
4331 | }
|
4332 |
|
4333 | var events = {
|
4334 | attachEvents: attachEvents,
|
4335 | detachEvents: detachEvents
|
4336 | };
|
4337 |
|
4338 | function setBreakpoint() {
|
4339 | var swiper = this;
|
4340 | var activeIndex = swiper.activeIndex,
|
4341 | initialized = swiper.initialized,
|
4342 | _swiper$loopedSlides = swiper.loopedSlides,
|
4343 | loopedSlides = _swiper$loopedSlides === void 0 ? 0 : _swiper$loopedSlides,
|
4344 | params = swiper.params,
|
4345 | $el = swiper.$el;
|
4346 | var breakpoints = params.breakpoints;
|
4347 | if (!breakpoints || breakpoints && Object.keys(breakpoints).length === 0) return;
|
4348 |
|
4349 | var breakpoint = swiper.getBreakpoint(breakpoints, swiper.params.breakpointsBase, swiper.el);
|
4350 |
|
4351 | if (breakpoint && swiper.currentBreakpoint !== breakpoint) {
|
4352 | var breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined;
|
4353 |
|
4354 | if (breakpointOnlyParams) {
|
4355 | ['slidesPerView', 'spaceBetween', 'slidesPerGroup', 'slidesPerGroupSkip', 'slidesPerColumn'].forEach(function (param) {
|
4356 | var paramValue = breakpointOnlyParams[param];
|
4357 | if (typeof paramValue === 'undefined') return;
|
4358 |
|
4359 | if (param === 'slidesPerView' && (paramValue === 'AUTO' || paramValue === 'auto')) {
|
4360 | breakpointOnlyParams[param] = 'auto';
|
4361 | } else if (param === 'slidesPerView') {
|
4362 | breakpointOnlyParams[param] = parseFloat(paramValue);
|
4363 | } else {
|
4364 | breakpointOnlyParams[param] = parseInt(paramValue, 10);
|
4365 | }
|
4366 | });
|
4367 | }
|
4368 |
|
4369 | var breakpointParams = breakpointOnlyParams || swiper.originalParams;
|
4370 | var wasMultiRow = params.slidesPerColumn > 1;
|
4371 | var isMultiRow = breakpointParams.slidesPerColumn > 1;
|
4372 |
|
4373 | if (wasMultiRow && !isMultiRow) {
|
4374 | $el.removeClass(params.containerModifierClass + "multirow " + params.containerModifierClass + "multirow-column");
|
4375 | swiper.emitContainerClasses();
|
4376 | } else if (!wasMultiRow && isMultiRow) {
|
4377 | $el.addClass(params.containerModifierClass + "multirow");
|
4378 |
|
4379 | if (breakpointParams.slidesPerColumnFill === 'column') {
|
4380 | $el.addClass(params.containerModifierClass + "multirow-column");
|
4381 | }
|
4382 |
|
4383 | swiper.emitContainerClasses();
|
4384 | }
|
4385 |
|
4386 | var directionChanged = breakpointParams.direction && breakpointParams.direction !== params.direction;
|
4387 | var needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView || directionChanged);
|
4388 |
|
4389 | if (directionChanged && initialized) {
|
4390 | swiper.changeDirection();
|
4391 | }
|
4392 |
|
4393 | extend(swiper.params, breakpointParams);
|
4394 | extend(swiper, {
|
4395 | allowTouchMove: swiper.params.allowTouchMove,
|
4396 | allowSlideNext: swiper.params.allowSlideNext,
|
4397 | allowSlidePrev: swiper.params.allowSlidePrev
|
4398 | });
|
4399 | swiper.currentBreakpoint = breakpoint;
|
4400 | swiper.emit('_beforeBreakpoint', breakpointParams);
|
4401 |
|
4402 | if (needsReLoop && initialized) {
|
4403 | swiper.loopDestroy();
|
4404 | swiper.loopCreate();
|
4405 | swiper.updateSlides();
|
4406 | swiper.slideTo(activeIndex - loopedSlides + swiper.loopedSlides, 0, false);
|
4407 | }
|
4408 |
|
4409 | swiper.emit('breakpoint', breakpointParams);
|
4410 | }
|
4411 | }
|
4412 |
|
4413 | function getBreakpoint(breakpoints, base, containerEl) {
|
4414 | if (base === void 0) {
|
4415 | base = 'window';
|
4416 | }
|
4417 |
|
4418 | if (!breakpoints || base === 'container' && !containerEl) return undefined;
|
4419 | var breakpoint = false;
|
4420 | var window = getWindow();
|
4421 | var currentWidth = base === 'window' ? window.innerWidth : containerEl.clientWidth;
|
4422 | var currentHeight = base === 'window' ? window.innerHeight : containerEl.clientHeight;
|
4423 | var points = Object.keys(breakpoints).map(function (point) {
|
4424 | if (typeof point === 'string' && point.indexOf('@') === 0) {
|
4425 | var minRatio = parseFloat(point.substr(1));
|
4426 | var value = currentHeight * minRatio;
|
4427 | return {
|
4428 | value: value,
|
4429 | point: point
|
4430 | };
|
4431 | }
|
4432 |
|
4433 | return {
|
4434 | value: point,
|
4435 | point: point
|
4436 | };
|
4437 | });
|
4438 | points.sort(function (a, b) {
|
4439 | return parseInt(a.value, 10) - parseInt(b.value, 10);
|
4440 | });
|
4441 |
|
4442 | for (var i = 0; i < points.length; i += 1) {
|
4443 | var _points$i = points[i],
|
4444 | point = _points$i.point,
|
4445 | value = _points$i.value;
|
4446 |
|
4447 | if (value <= currentWidth) {
|
4448 | breakpoint = point;
|
4449 | }
|
4450 | }
|
4451 |
|
4452 | return breakpoint || 'max';
|
4453 | }
|
4454 |
|
4455 | var breakpoints = {
|
4456 | setBreakpoint: setBreakpoint,
|
4457 | getBreakpoint: getBreakpoint
|
4458 | };
|
4459 |
|
4460 | function prepareClasses(entries, prefix) {
|
4461 | var resultClasses = [];
|
4462 | entries.forEach(function (item) {
|
4463 | if (typeof item === 'object') {
|
4464 | Object.keys(item).forEach(function (classNames) {
|
4465 | if (item[classNames]) {
|
4466 | resultClasses.push(prefix + classNames);
|
4467 | }
|
4468 | });
|
4469 | } else if (typeof item === 'string') {
|
4470 | resultClasses.push(prefix + item);
|
4471 | }
|
4472 | });
|
4473 | return resultClasses;
|
4474 | }
|
4475 |
|
4476 | function addClasses() {
|
4477 | var swiper = this;
|
4478 | var classNames = swiper.classNames,
|
4479 | params = swiper.params,
|
4480 | rtl = swiper.rtl,
|
4481 | $el = swiper.$el,
|
4482 | device = swiper.device,
|
4483 | support = swiper.support;
|
4484 |
|
4485 | var suffixes = prepareClasses(['initialized', params.direction, {
|
4486 | 'pointer-events': support.pointerEvents && !support.touch
|
4487 | }, {
|
4488 | 'free-mode': params.freeMode
|
4489 | }, {
|
4490 | 'autoheight': params.autoHeight
|
4491 | }, {
|
4492 | 'rtl': rtl
|
4493 | }, {
|
4494 | 'multirow': params.slidesPerColumn > 1
|
4495 | }, {
|
4496 | 'multirow-column': params.slidesPerColumn > 1 && params.slidesPerColumnFill === 'column'
|
4497 | }, {
|
4498 | 'android': device.android
|
4499 | }, {
|
4500 | 'ios': device.ios
|
4501 | }, {
|
4502 | 'css-mode': params.cssMode
|
4503 | }], params.containerModifierClass);
|
4504 | classNames.push.apply(classNames, suffixes);
|
4505 | $el.addClass([].concat(classNames).join(' '));
|
4506 | swiper.emitContainerClasses();
|
4507 | }
|
4508 |
|
4509 | function removeClasses() {
|
4510 | var swiper = this;
|
4511 | var $el = swiper.$el,
|
4512 | classNames = swiper.classNames;
|
4513 | $el.removeClass(classNames.join(' '));
|
4514 | swiper.emitContainerClasses();
|
4515 | }
|
4516 |
|
4517 | var classes = {
|
4518 | addClasses: addClasses,
|
4519 | removeClasses: removeClasses
|
4520 | };
|
4521 |
|
4522 | function loadImage(imageEl, src, srcset, sizes, checkForComplete, callback) {
|
4523 | var window = getWindow();
|
4524 | var image;
|
4525 |
|
4526 | function onReady() {
|
4527 | if (callback) callback();
|
4528 | }
|
4529 |
|
4530 | var isPicture = $(imageEl).parent('picture')[0];
|
4531 |
|
4532 | if (!isPicture && (!imageEl.complete || !checkForComplete)) {
|
4533 | if (src) {
|
4534 | image = new window.Image();
|
4535 | image.onload = onReady;
|
4536 | image.onerror = onReady;
|
4537 |
|
4538 | if (sizes) {
|
4539 | image.sizes = sizes;
|
4540 | }
|
4541 |
|
4542 | if (srcset) {
|
4543 | image.srcset = srcset;
|
4544 | }
|
4545 |
|
4546 | if (src) {
|
4547 | image.src = src;
|
4548 | }
|
4549 | } else {
|
4550 | onReady();
|
4551 | }
|
4552 | } else {
|
4553 |
|
4554 | onReady();
|
4555 | }
|
4556 | }
|
4557 |
|
4558 | function preloadImages() {
|
4559 | var swiper = this;
|
4560 | swiper.imagesToLoad = swiper.$el.find('img');
|
4561 |
|
4562 | function onReady() {
|
4563 | if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) return;
|
4564 | if (swiper.imagesLoaded !== undefined) swiper.imagesLoaded += 1;
|
4565 |
|
4566 | if (swiper.imagesLoaded === swiper.imagesToLoad.length) {
|
4567 | if (swiper.params.updateOnImagesReady) swiper.update();
|
4568 | swiper.emit('imagesReady');
|
4569 | }
|
4570 | }
|
4571 |
|
4572 | for (var i = 0; i < swiper.imagesToLoad.length; i += 1) {
|
4573 | var imageEl = swiper.imagesToLoad[i];
|
4574 | swiper.loadImage(imageEl, imageEl.currentSrc || imageEl.getAttribute('src'), imageEl.srcset || imageEl.getAttribute('srcset'), imageEl.sizes || imageEl.getAttribute('sizes'), true, onReady);
|
4575 | }
|
4576 | }
|
4577 |
|
4578 | var images = {
|
4579 | loadImage: loadImage,
|
4580 | preloadImages: preloadImages
|
4581 | };
|
4582 |
|
4583 | function checkOverflow() {
|
4584 | var swiper = this;
|
4585 | var params = swiper.params;
|
4586 | var wasLocked = swiper.isLocked;
|
4587 | var lastSlidePosition = swiper.slides.length > 0 && params.slidesOffsetBefore + params.spaceBetween * (swiper.slides.length - 1) + swiper.slides[0].offsetWidth * swiper.slides.length;
|
4588 |
|
4589 | if (params.slidesOffsetBefore && params.slidesOffsetAfter && lastSlidePosition) {
|
4590 | swiper.isLocked = lastSlidePosition <= swiper.size;
|
4591 | } else {
|
4592 | swiper.isLocked = swiper.snapGrid.length === 1;
|
4593 | }
|
4594 |
|
4595 | swiper.allowSlideNext = !swiper.isLocked;
|
4596 | swiper.allowSlidePrev = !swiper.isLocked;
|
4597 |
|
4598 | if (wasLocked !== swiper.isLocked) swiper.emit(swiper.isLocked ? 'lock' : 'unlock');
|
4599 |
|
4600 | if (wasLocked && wasLocked !== swiper.isLocked) {
|
4601 | swiper.isEnd = false;
|
4602 | if (swiper.navigation) swiper.navigation.update();
|
4603 | }
|
4604 | }
|
4605 |
|
4606 | var checkOverflow$1 = {
|
4607 | checkOverflow: checkOverflow
|
4608 | };
|
4609 |
|
4610 | var defaults = {
|
4611 | init: true,
|
4612 | direction: 'horizontal',
|
4613 | touchEventsTarget: 'container',
|
4614 | initialSlide: 0,
|
4615 | speed: 300,
|
4616 | cssMode: false,
|
4617 | updateOnWindowResize: true,
|
4618 | resizeObserver: false,
|
4619 | nested: false,
|
4620 |
|
4621 | width: null,
|
4622 | height: null,
|
4623 |
|
4624 | preventInteractionOnTransition: false,
|
4625 |
|
4626 | userAgent: null,
|
4627 | url: null,
|
4628 |
|
4629 | edgeSwipeDetection: false,
|
4630 | edgeSwipeThreshold: 20,
|
4631 |
|
4632 | freeMode: false,
|
4633 | freeModeMomentum: true,
|
4634 | freeModeMomentumRatio: 1,
|
4635 | freeModeMomentumBounce: true,
|
4636 | freeModeMomentumBounceRatio: 1,
|
4637 | freeModeMomentumVelocityRatio: 1,
|
4638 | freeModeSticky: false,
|
4639 | freeModeMinimumVelocity: 0.02,
|
4640 |
|
4641 | autoHeight: false,
|
4642 |
|
4643 | setWrapperSize: false,
|
4644 |
|
4645 | virtualTranslate: false,
|
4646 |
|
4647 | effect: 'slide',
|
4648 |
|
4649 |
|
4650 | breakpoints: undefined,
|
4651 | breakpointsBase: 'window',
|
4652 |
|
4653 | spaceBetween: 0,
|
4654 | slidesPerView: 1,
|
4655 | slidesPerColumn: 1,
|
4656 | slidesPerColumnFill: 'column',
|
4657 | slidesPerGroup: 1,
|
4658 | slidesPerGroupSkip: 0,
|
4659 | centeredSlides: false,
|
4660 | centeredSlidesBounds: false,
|
4661 | slidesOffsetBefore: 0,
|
4662 |
|
4663 | slidesOffsetAfter: 0,
|
4664 |
|
4665 | normalizeSlideIndex: true,
|
4666 | centerInsufficientSlides: false,
|
4667 |
|
4668 | watchOverflow: false,
|
4669 |
|
4670 | roundLengths: false,
|
4671 |
|
4672 | touchRatio: 1,
|
4673 | touchAngle: 45,
|
4674 | simulateTouch: true,
|
4675 | shortSwipes: true,
|
4676 | longSwipes: true,
|
4677 | longSwipesRatio: 0.5,
|
4678 | longSwipesMs: 300,
|
4679 | followFinger: true,
|
4680 | allowTouchMove: true,
|
4681 | threshold: 0,
|
4682 | touchMoveStopPropagation: false,
|
4683 | touchStartPreventDefault: true,
|
4684 | touchStartForcePreventDefault: false,
|
4685 | touchReleaseOnEdges: false,
|
4686 |
|
4687 | uniqueNavElements: true,
|
4688 |
|
4689 | resistance: true,
|
4690 | resistanceRatio: 0.85,
|
4691 |
|
4692 | watchSlidesProgress: false,
|
4693 | watchSlidesVisibility: false,
|
4694 |
|
4695 | grabCursor: false,
|
4696 |
|
4697 | preventClicks: true,
|
4698 | preventClicksPropagation: true,
|
4699 | slideToClickedSlide: false,
|
4700 |
|
4701 | preloadImages: true,
|
4702 | updateOnImagesReady: true,
|
4703 |
|
4704 | loop: false,
|
4705 | loopAdditionalSlides: 0,
|
4706 | loopedSlides: null,
|
4707 | loopFillGroupWithBlank: false,
|
4708 | loopPreventsSlide: true,
|
4709 |
|
4710 | allowSlidePrev: true,
|
4711 | allowSlideNext: true,
|
4712 | swipeHandler: null,
|
4713 |
|
4714 | noSwiping: true,
|
4715 | noSwipingClass: 'swiper-no-swiping',
|
4716 | noSwipingSelector: null,
|
4717 |
|
4718 | passiveListeners: true,
|
4719 |
|
4720 | containerModifierClass: 'swiper-container-',
|
4721 |
|
4722 | slideClass: 'swiper-slide',
|
4723 | slideBlankClass: 'swiper-slide-invisible-blank',
|
4724 | slideActiveClass: 'swiper-slide-active',
|
4725 | slideDuplicateActiveClass: 'swiper-slide-duplicate-active',
|
4726 | slideVisibleClass: 'swiper-slide-visible',
|
4727 | slideDuplicateClass: 'swiper-slide-duplicate',
|
4728 | slideNextClass: 'swiper-slide-next',
|
4729 | slideDuplicateNextClass: 'swiper-slide-duplicate-next',
|
4730 | slidePrevClass: 'swiper-slide-prev',
|
4731 | slideDuplicatePrevClass: 'swiper-slide-duplicate-prev',
|
4732 | wrapperClass: 'swiper-wrapper',
|
4733 |
|
4734 | runCallbacksOnInit: true,
|
4735 |
|
4736 | _emitClasses: false
|
4737 | };
|
4738 |
|
4739 | var prototypes = {
|
4740 | modular: modular,
|
4741 | eventsEmitter: eventsEmitter,
|
4742 | update: update,
|
4743 | translate: translate,
|
4744 | transition: transition,
|
4745 | slide: slide,
|
4746 | loop: loop,
|
4747 | grabCursor: grabCursor,
|
4748 | manipulation: manipulation,
|
4749 | events: events,
|
4750 | breakpoints: breakpoints,
|
4751 | checkOverflow: checkOverflow$1,
|
4752 | classes: classes,
|
4753 | images: images
|
4754 | };
|
4755 | var extendedDefaults = {};
|
4756 |
|
4757 | var Swiper = function () {
|
4758 | function Swiper() {
|
4759 | var el;
|
4760 | var params;
|
4761 |
|
4762 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
4763 | args[_key] = arguments[_key];
|
4764 | }
|
4765 |
|
4766 | if (args.length === 1 && args[0].constructor && Object.prototype.toString.call(args[0]).slice(8, -1) === 'Object') {
|
4767 | params = args[0];
|
4768 | } else {
|
4769 | el = args[0];
|
4770 | params = args[1];
|
4771 | }
|
4772 |
|
4773 | if (!params) params = {};
|
4774 | params = extend({}, params);
|
4775 | if (el && !params.el) params.el = el;
|
4776 |
|
4777 | if (params.el && $(params.el).length > 1) {
|
4778 | var swipers = [];
|
4779 | $(params.el).each(function (containerEl) {
|
4780 | var newParams = extend({}, params, {
|
4781 | el: containerEl
|
4782 | });
|
4783 | swipers.push(new Swiper(newParams));
|
4784 | });
|
4785 | return swipers;
|
4786 | }
|
4787 |
|
4788 |
|
4789 | var swiper = this;
|
4790 | swiper.__swiper__ = true;
|
4791 | swiper.support = getSupport();
|
4792 | swiper.device = getDevice({
|
4793 | userAgent: params.userAgent
|
4794 | });
|
4795 | swiper.browser = getBrowser();
|
4796 | swiper.eventsListeners = {};
|
4797 | swiper.eventsAnyListeners = [];
|
4798 |
|
4799 | if (typeof swiper.modules === 'undefined') {
|
4800 | swiper.modules = {};
|
4801 | }
|
4802 |
|
4803 | Object.keys(swiper.modules).forEach(function (moduleName) {
|
4804 | var module = swiper.modules[moduleName];
|
4805 |
|
4806 | if (module.params) {
|
4807 | var moduleParamName = Object.keys(module.params)[0];
|
4808 | var moduleParams = module.params[moduleParamName];
|
4809 | if (typeof moduleParams !== 'object' || moduleParams === null) return;
|
4810 | if (!(moduleParamName in params && 'enabled' in moduleParams)) return;
|
4811 |
|
4812 | if (params[moduleParamName] === true) {
|
4813 | params[moduleParamName] = {
|
4814 | enabled: true
|
4815 | };
|
4816 | }
|
4817 |
|
4818 | if (typeof params[moduleParamName] === 'object' && !('enabled' in params[moduleParamName])) {
|
4819 | params[moduleParamName].enabled = true;
|
4820 | }
|
4821 |
|
4822 | if (!params[moduleParamName]) params[moduleParamName] = {
|
4823 | enabled: false
|
4824 | };
|
4825 | }
|
4826 | });
|
4827 |
|
4828 | var swiperParams = extend({}, defaults);
|
4829 | swiper.useParams(swiperParams);
|
4830 |
|
4831 | swiper.params = extend({}, swiperParams, extendedDefaults, params);
|
4832 | swiper.originalParams = extend({}, swiper.params);
|
4833 | swiper.passedParams = extend({}, params);
|
4834 |
|
4835 | if (swiper.params && swiper.params.on) {
|
4836 | Object.keys(swiper.params.on).forEach(function (eventName) {
|
4837 | swiper.on(eventName, swiper.params.on[eventName]);
|
4838 | });
|
4839 | }
|
4840 |
|
4841 | if (swiper.params && swiper.params.onAny) {
|
4842 | swiper.onAny(swiper.params.onAny);
|
4843 | }
|
4844 |
|
4845 |
|
4846 | swiper.$ = $;
|
4847 |
|
4848 | extend(swiper, {
|
4849 | el: el,
|
4850 |
|
4851 | classNames: [],
|
4852 |
|
4853 | slides: $(),
|
4854 | slidesGrid: [],
|
4855 | snapGrid: [],
|
4856 | slidesSizesGrid: [],
|
4857 |
|
4858 | isHorizontal: function isHorizontal() {
|
4859 | return swiper.params.direction === 'horizontal';
|
4860 | },
|
4861 | isVertical: function isVertical() {
|
4862 | return swiper.params.direction === 'vertical';
|
4863 | },
|
4864 |
|
4865 | activeIndex: 0,
|
4866 | realIndex: 0,
|
4867 |
|
4868 | isBeginning: true,
|
4869 | isEnd: false,
|
4870 |
|
4871 | translate: 0,
|
4872 | previousTranslate: 0,
|
4873 | progress: 0,
|
4874 | velocity: 0,
|
4875 | animating: false,
|
4876 |
|
4877 | allowSlideNext: swiper.params.allowSlideNext,
|
4878 | allowSlidePrev: swiper.params.allowSlidePrev,
|
4879 |
|
4880 | touchEvents: function touchEvents() {
|
4881 | var touch = ['touchstart', 'touchmove', 'touchend', 'touchcancel'];
|
4882 | var desktop = ['mousedown', 'mousemove', 'mouseup'];
|
4883 |
|
4884 | if (swiper.support.pointerEvents) {
|
4885 | desktop = ['pointerdown', 'pointermove', 'pointerup'];
|
4886 | }
|
4887 |
|
4888 | swiper.touchEventsTouch = {
|
4889 | start: touch[0],
|
4890 | move: touch[1],
|
4891 | end: touch[2],
|
4892 | cancel: touch[3]
|
4893 | };
|
4894 | swiper.touchEventsDesktop = {
|
4895 | start: desktop[0],
|
4896 | move: desktop[1],
|
4897 | end: desktop[2]
|
4898 | };
|
4899 | return swiper.support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop;
|
4900 | }(),
|
4901 | touchEventsData: {
|
4902 | isTouched: undefined,
|
4903 | isMoved: undefined,
|
4904 | allowTouchCallbacks: undefined,
|
4905 | touchStartTime: undefined,
|
4906 | isScrolling: undefined,
|
4907 | currentTranslate: undefined,
|
4908 | startTranslate: undefined,
|
4909 | allowThresholdMove: undefined,
|
4910 |
|
4911 | formElements: 'input, select, option, textarea, button, video, label',
|
4912 |
|
4913 | lastClickTime: now(),
|
4914 | clickTimeout: undefined,
|
4915 |
|
4916 | velocities: [],
|
4917 | allowMomentumBounce: undefined,
|
4918 | isTouchEvent: undefined,
|
4919 | startMoving: undefined
|
4920 | },
|
4921 |
|
4922 | allowClick: true,
|
4923 |
|
4924 | allowTouchMove: swiper.params.allowTouchMove,
|
4925 | touches: {
|
4926 | startX: 0,
|
4927 | startY: 0,
|
4928 | currentX: 0,
|
4929 | currentY: 0,
|
4930 | diff: 0
|
4931 | },
|
4932 |
|
4933 | imagesToLoad: [],
|
4934 | imagesLoaded: 0
|
4935 | });
|
4936 |
|
4937 | swiper.useModules();
|
4938 | swiper.emit('_swiper');
|
4939 |
|
4940 | if (swiper.params.init) {
|
4941 | swiper.init();
|
4942 | }
|
4943 |
|
4944 |
|
4945 | return swiper;
|
4946 | }
|
4947 |
|
4948 | var _proto = Swiper.prototype;
|
4949 |
|
4950 | _proto.emitContainerClasses = function emitContainerClasses() {
|
4951 | var swiper = this;
|
4952 | if (!swiper.params._emitClasses || !swiper.el) return;
|
4953 | var classes = swiper.el.className.split(' ').filter(function (className) {
|
4954 | return className.indexOf('swiper-container') === 0 || className.indexOf(swiper.params.containerModifierClass) === 0;
|
4955 | });
|
4956 | swiper.emit('_containerClasses', classes.join(' '));
|
4957 | };
|
4958 |
|
4959 | _proto.getSlideClasses = function getSlideClasses(slideEl) {
|
4960 | var swiper = this;
|
4961 | return slideEl.className.split(' ').filter(function (className) {
|
4962 | return className.indexOf('swiper-slide') === 0 || className.indexOf(swiper.params.slideClass) === 0;
|
4963 | }).join(' ');
|
4964 | };
|
4965 |
|
4966 | _proto.emitSlidesClasses = function emitSlidesClasses() {
|
4967 | var swiper = this;
|
4968 | if (!swiper.params._emitClasses || !swiper.el) return;
|
4969 | var updates = [];
|
4970 | swiper.slides.each(function (slideEl) {
|
4971 | var classNames = swiper.getSlideClasses(slideEl);
|
4972 | updates.push({
|
4973 | slideEl: slideEl,
|
4974 | classNames: classNames
|
4975 | });
|
4976 | swiper.emit('_slideClass', slideEl, classNames);
|
4977 | });
|
4978 | swiper.emit('_slideClasses', updates);
|
4979 | };
|
4980 |
|
4981 | _proto.slidesPerViewDynamic = function slidesPerViewDynamic() {
|
4982 | var swiper = this;
|
4983 | var params = swiper.params,
|
4984 | slides = swiper.slides,
|
4985 | slidesGrid = swiper.slidesGrid,
|
4986 | swiperSize = swiper.size,
|
4987 | activeIndex = swiper.activeIndex;
|
4988 | var spv = 1;
|
4989 |
|
4990 | if (params.centeredSlides) {
|
4991 | var slideSize = slides[activeIndex].swiperSlideSize;
|
4992 | var breakLoop;
|
4993 |
|
4994 | for (var i = activeIndex + 1; i < slides.length; i += 1) {
|
4995 | if (slides[i] && !breakLoop) {
|
4996 | slideSize += slides[i].swiperSlideSize;
|
4997 | spv += 1;
|
4998 | if (slideSize > swiperSize) breakLoop = true;
|
4999 | }
|
5000 | }
|
5001 |
|
5002 | for (var _i = activeIndex - 1; _i >= 0; _i -= 1) {
|
5003 | if (slides[_i] && !breakLoop) {
|
5004 | slideSize += slides[_i].swiperSlideSize;
|
5005 | spv += 1;
|
5006 | if (slideSize > swiperSize) breakLoop = true;
|
5007 | }
|
5008 | }
|
5009 | } else {
|
5010 | for (var _i2 = activeIndex + 1; _i2 < slides.length; _i2 += 1) {
|
5011 | if (slidesGrid[_i2] - slidesGrid[activeIndex] < swiperSize) {
|
5012 | spv += 1;
|
5013 | }
|
5014 | }
|
5015 | }
|
5016 |
|
5017 | return spv;
|
5018 | };
|
5019 |
|
5020 | _proto.update = function update() {
|
5021 | var swiper = this;
|
5022 | if (!swiper || swiper.destroyed) return;
|
5023 | var snapGrid = swiper.snapGrid,
|
5024 | params = swiper.params;
|
5025 |
|
5026 | if (params.breakpoints) {
|
5027 | swiper.setBreakpoint();
|
5028 | }
|
5029 |
|
5030 | swiper.updateSize();
|
5031 | swiper.updateSlides();
|
5032 | swiper.updateProgress();
|
5033 | swiper.updateSlidesClasses();
|
5034 |
|
5035 | function setTranslate() {
|
5036 | var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate;
|
5037 | var newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate());
|
5038 | swiper.setTranslate(newTranslate);
|
5039 | swiper.updateActiveIndex();
|
5040 | swiper.updateSlidesClasses();
|
5041 | }
|
5042 |
|
5043 | var translated;
|
5044 |
|
5045 | if (swiper.params.freeMode) {
|
5046 | setTranslate();
|
5047 |
|
5048 | if (swiper.params.autoHeight) {
|
5049 | swiper.updateAutoHeight();
|
5050 | }
|
5051 | } else {
|
5052 | if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) {
|
5053 | translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true);
|
5054 | } else {
|
5055 | translated = swiper.slideTo(swiper.activeIndex, 0, false, true);
|
5056 | }
|
5057 |
|
5058 | if (!translated) {
|
5059 | setTranslate();
|
5060 | }
|
5061 | }
|
5062 |
|
5063 | if (params.watchOverflow && snapGrid !== swiper.snapGrid) {
|
5064 | swiper.checkOverflow();
|
5065 | }
|
5066 |
|
5067 | swiper.emit('update');
|
5068 | };
|
5069 |
|
5070 | _proto.changeDirection = function changeDirection(newDirection, needUpdate) {
|
5071 | if (needUpdate === void 0) {
|
5072 | needUpdate = true;
|
5073 | }
|
5074 |
|
5075 | var swiper = this;
|
5076 | var currentDirection = swiper.params.direction;
|
5077 |
|
5078 | if (!newDirection) {
|
5079 |
|
5080 | newDirection = currentDirection === 'horizontal' ? 'vertical' : 'horizontal';
|
5081 | }
|
5082 |
|
5083 | if (newDirection === currentDirection || newDirection !== 'horizontal' && newDirection !== 'vertical') {
|
5084 | return swiper;
|
5085 | }
|
5086 |
|
5087 | swiper.$el.removeClass("" + swiper.params.containerModifierClass + currentDirection).addClass("" + swiper.params.containerModifierClass + newDirection);
|
5088 | swiper.emitContainerClasses();
|
5089 | swiper.params.direction = newDirection;
|
5090 | swiper.slides.each(function (slideEl) {
|
5091 | if (newDirection === 'vertical') {
|
5092 | slideEl.style.width = '';
|
5093 | } else {
|
5094 | slideEl.style.height = '';
|
5095 | }
|
5096 | });
|
5097 | swiper.emit('changeDirection');
|
5098 | if (needUpdate) swiper.update();
|
5099 | return swiper;
|
5100 | };
|
5101 |
|
5102 | _proto.mount = function mount(el) {
|
5103 | var swiper = this;
|
5104 | if (swiper.mounted) return true;
|
5105 |
|
5106 | var $el = $(el || swiper.params.el);
|
5107 | el = $el[0];
|
5108 |
|
5109 | if (!el) {
|
5110 | return false;
|
5111 | }
|
5112 |
|
5113 | el.swiper = swiper;
|
5114 |
|
5115 | var $wrapperEl;
|
5116 |
|
5117 | if (el && el.shadowRoot && el.shadowRoot.querySelector) {
|
5118 | $wrapperEl = $(el.shadowRoot.querySelector("." + swiper.params.wrapperClass));
|
5119 |
|
5120 | $wrapperEl.children = function (options) {
|
5121 | return $el.children(options);
|
5122 | };
|
5123 | } else {
|
5124 | $wrapperEl = $el.children("." + swiper.params.wrapperClass);
|
5125 | }
|
5126 |
|
5127 | extend(swiper, {
|
5128 | $el: $el,
|
5129 | el: el,
|
5130 | $wrapperEl: $wrapperEl,
|
5131 | wrapperEl: $wrapperEl[0],
|
5132 | mounted: true,
|
5133 |
|
5134 | rtl: el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl',
|
5135 | rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'),
|
5136 | wrongRTL: $wrapperEl.css('display') === '-webkit-box'
|
5137 | });
|
5138 | return true;
|
5139 | };
|
5140 |
|
5141 | _proto.init = function init(el) {
|
5142 | var swiper = this;
|
5143 | if (swiper.initialized) return swiper;
|
5144 | var mounted = swiper.mount(el);
|
5145 | if (mounted === false) return swiper;
|
5146 | swiper.emit('beforeInit');
|
5147 |
|
5148 | if (swiper.params.breakpoints) {
|
5149 | swiper.setBreakpoint();
|
5150 | }
|
5151 |
|
5152 |
|
5153 | swiper.addClasses();
|
5154 |
|
5155 | if (swiper.params.loop) {
|
5156 | swiper.loopCreate();
|
5157 | }
|
5158 |
|
5159 |
|
5160 | swiper.updateSize();
|
5161 |
|
5162 | swiper.updateSlides();
|
5163 |
|
5164 | if (swiper.params.watchOverflow) {
|
5165 | swiper.checkOverflow();
|
5166 | }
|
5167 |
|
5168 |
|
5169 | if (swiper.params.grabCursor) {
|
5170 | swiper.setGrabCursor();
|
5171 | }
|
5172 |
|
5173 | if (swiper.params.preloadImages) {
|
5174 | swiper.preloadImages();
|
5175 | }
|
5176 |
|
5177 |
|
5178 | if (swiper.params.loop) {
|
5179 | swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit);
|
5180 | } else {
|
5181 | swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit);
|
5182 | }
|
5183 |
|
5184 |
|
5185 | swiper.attachEvents();
|
5186 |
|
5187 | swiper.initialized = true;
|
5188 |
|
5189 | swiper.emit('init');
|
5190 | swiper.emit('afterInit');
|
5191 | return swiper;
|
5192 | };
|
5193 |
|
5194 | _proto.destroy = function destroy(deleteInstance, cleanStyles) {
|
5195 | if (deleteInstance === void 0) {
|
5196 | deleteInstance = true;
|
5197 | }
|
5198 |
|
5199 | if (cleanStyles === void 0) {
|
5200 | cleanStyles = true;
|
5201 | }
|
5202 |
|
5203 | var swiper = this;
|
5204 | var params = swiper.params,
|
5205 | $el = swiper.$el,
|
5206 | $wrapperEl = swiper.$wrapperEl,
|
5207 | slides = swiper.slides;
|
5208 |
|
5209 | if (typeof swiper.params === 'undefined' || swiper.destroyed) {
|
5210 | return null;
|
5211 | }
|
5212 |
|
5213 | swiper.emit('beforeDestroy');
|
5214 |
|
5215 | swiper.initialized = false;
|
5216 |
|
5217 | swiper.detachEvents();
|
5218 |
|
5219 | if (params.loop) {
|
5220 | swiper.loopDestroy();
|
5221 | }
|
5222 |
|
5223 |
|
5224 | if (cleanStyles) {
|
5225 | swiper.removeClasses();
|
5226 | $el.removeAttr('style');
|
5227 | $wrapperEl.removeAttr('style');
|
5228 |
|
5229 | if (slides && slides.length) {
|
5230 | slides.removeClass([params.slideVisibleClass, params.slideActiveClass, params.slideNextClass, params.slidePrevClass].join(' ')).removeAttr('style').removeAttr('data-swiper-slide-index');
|
5231 | }
|
5232 | }
|
5233 |
|
5234 | swiper.emit('destroy');
|
5235 |
|
5236 | Object.keys(swiper.eventsListeners).forEach(function (eventName) {
|
5237 | swiper.off(eventName);
|
5238 | });
|
5239 |
|
5240 | if (deleteInstance !== false) {
|
5241 | swiper.$el[0].swiper = null;
|
5242 | deleteProps(swiper);
|
5243 | }
|
5244 |
|
5245 | swiper.destroyed = true;
|
5246 | return null;
|
5247 | };
|
5248 |
|
5249 | Swiper.extendDefaults = function extendDefaults(newDefaults) {
|
5250 | extend(extendedDefaults, newDefaults);
|
5251 | };
|
5252 |
|
5253 | Swiper.installModule = function installModule(module) {
|
5254 | if (!Swiper.prototype.modules) Swiper.prototype.modules = {};
|
5255 | var name = module.name || Object.keys(Swiper.prototype.modules).length + "_" + now();
|
5256 | Swiper.prototype.modules[name] = module;
|
5257 | };
|
5258 |
|
5259 | Swiper.use = function use(module) {
|
5260 | if (Array.isArray(module)) {
|
5261 | module.forEach(function (m) {
|
5262 | return Swiper.installModule(m);
|
5263 | });
|
5264 | return Swiper;
|
5265 | }
|
5266 |
|
5267 | Swiper.installModule(module);
|
5268 | return Swiper;
|
5269 | };
|
5270 |
|
5271 | _createClass(Swiper, null, [{
|
5272 | key: "extendedDefaults",
|
5273 | get: function get() {
|
5274 | return extendedDefaults;
|
5275 | }
|
5276 | }, {
|
5277 | key: "defaults",
|
5278 | get: function get() {
|
5279 | return defaults;
|
5280 | }
|
5281 | }]);
|
5282 |
|
5283 | return Swiper;
|
5284 | }();
|
5285 |
|
5286 | Object.keys(prototypes).forEach(function (prototypeGroup) {
|
5287 | Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) {
|
5288 | Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod];
|
5289 | });
|
5290 | });
|
5291 | Swiper.use([Resize, Observer$1]);
|
5292 |
|
5293 | var Virtual = {
|
5294 | update: function update(force) {
|
5295 | var swiper = this;
|
5296 | var _swiper$params = swiper.params,
|
5297 | slidesPerView = _swiper$params.slidesPerView,
|
5298 | slidesPerGroup = _swiper$params.slidesPerGroup,
|
5299 | centeredSlides = _swiper$params.centeredSlides;
|
5300 | var _swiper$params$virtua = swiper.params.virtual,
|
5301 | addSlidesBefore = _swiper$params$virtua.addSlidesBefore,
|
5302 | addSlidesAfter = _swiper$params$virtua.addSlidesAfter;
|
5303 | var _swiper$virtual = swiper.virtual,
|
5304 | previousFrom = _swiper$virtual.from,
|
5305 | previousTo = _swiper$virtual.to,
|
5306 | slides = _swiper$virtual.slides,
|
5307 | previousSlidesGrid = _swiper$virtual.slidesGrid,
|
5308 | renderSlide = _swiper$virtual.renderSlide,
|
5309 | previousOffset = _swiper$virtual.offset;
|
5310 | swiper.updateActiveIndex();
|
5311 | var activeIndex = swiper.activeIndex || 0;
|
5312 | var offsetProp;
|
5313 | if (swiper.rtlTranslate) offsetProp = 'right';else offsetProp = swiper.isHorizontal() ? 'left' : 'top';
|
5314 | var slidesAfter;
|
5315 | var slidesBefore;
|
5316 |
|
5317 | if (centeredSlides) {
|
5318 | slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter;
|
5319 | slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore;
|
5320 | } else {
|
5321 | slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesAfter;
|
5322 | slidesBefore = slidesPerGroup + addSlidesBefore;
|
5323 | }
|
5324 |
|
5325 | var from = Math.max((activeIndex || 0) - slidesBefore, 0);
|
5326 | var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1);
|
5327 | var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0);
|
5328 | extend(swiper.virtual, {
|
5329 | from: from,
|
5330 | to: to,
|
5331 | offset: offset,
|
5332 | slidesGrid: swiper.slidesGrid
|
5333 | });
|
5334 |
|
5335 | function onRendered() {
|
5336 | swiper.updateSlides();
|
5337 | swiper.updateProgress();
|
5338 | swiper.updateSlidesClasses();
|
5339 |
|
5340 | if (swiper.lazy && swiper.params.lazy.enabled) {
|
5341 | swiper.lazy.load();
|
5342 | }
|
5343 | }
|
5344 |
|
5345 | if (previousFrom === from && previousTo === to && !force) {
|
5346 | if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) {
|
5347 | swiper.slides.css(offsetProp, offset + "px");
|
5348 | }
|
5349 |
|
5350 | swiper.updateProgress();
|
5351 | return;
|
5352 | }
|
5353 |
|
5354 | if (swiper.params.virtual.renderExternal) {
|
5355 | swiper.params.virtual.renderExternal.call(swiper, {
|
5356 | offset: offset,
|
5357 | from: from,
|
5358 | to: to,
|
5359 | slides: function getSlides() {
|
5360 | var slidesToRender = [];
|
5361 |
|
5362 | for (var i = from; i <= to; i += 1) {
|
5363 | slidesToRender.push(slides[i]);
|
5364 | }
|
5365 |
|
5366 | return slidesToRender;
|
5367 | }()
|
5368 | });
|
5369 |
|
5370 | if (swiper.params.virtual.renderExternalUpdate) {
|
5371 | onRendered();
|
5372 | }
|
5373 |
|
5374 | return;
|
5375 | }
|
5376 |
|
5377 | var prependIndexes = [];
|
5378 | var appendIndexes = [];
|
5379 |
|
5380 | if (force) {
|
5381 | swiper.$wrapperEl.find("." + swiper.params.slideClass).remove();
|
5382 | } else {
|
5383 | for (var i = previousFrom; i <= previousTo; i += 1) {
|
5384 | if (i < from || i > to) {
|
5385 | swiper.$wrapperEl.find("." + swiper.params.slideClass + "[data-swiper-slide-index=\"" + i + "\"]").remove();
|
5386 | }
|
5387 | }
|
5388 | }
|
5389 |
|
5390 | for (var _i = 0; _i < slides.length; _i += 1) {
|
5391 | if (_i >= from && _i <= to) {
|
5392 | if (typeof previousTo === 'undefined' || force) {
|
5393 | appendIndexes.push(_i);
|
5394 | } else {
|
5395 | if (_i > previousTo) appendIndexes.push(_i);
|
5396 | if (_i < previousFrom) prependIndexes.push(_i);
|
5397 | }
|
5398 | }
|
5399 | }
|
5400 |
|
5401 | appendIndexes.forEach(function (index) {
|
5402 | swiper.$wrapperEl.append(renderSlide(slides[index], index));
|
5403 | });
|
5404 | prependIndexes.sort(function (a, b) {
|
5405 | return b - a;
|
5406 | }).forEach(function (index) {
|
5407 | swiper.$wrapperEl.prepend(renderSlide(slides[index], index));
|
5408 | });
|
5409 | swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, offset + "px");
|
5410 | onRendered();
|
5411 | },
|
5412 | renderSlide: function renderSlide(slide, index) {
|
5413 | var swiper = this;
|
5414 | var params = swiper.params.virtual;
|
5415 |
|
5416 | if (params.cache && swiper.virtual.cache[index]) {
|
5417 | return swiper.virtual.cache[index];
|
5418 | }
|
5419 |
|
5420 | var $slideEl = params.renderSlide ? $(params.renderSlide.call(swiper, slide, index)) : $("<div class=\"" + swiper.params.slideClass + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>");
|
5421 | if (!$slideEl.attr('data-swiper-slide-index')) $slideEl.attr('data-swiper-slide-index', index);
|
5422 | if (params.cache) swiper.virtual.cache[index] = $slideEl;
|
5423 | return $slideEl;
|
5424 | },
|
5425 | appendSlide: function appendSlide(slides) {
|
5426 | var swiper = this;
|
5427 |
|
5428 | if (typeof slides === 'object' && 'length' in slides) {
|
5429 | for (var i = 0; i < slides.length; i += 1) {
|
5430 | if (slides[i]) swiper.virtual.slides.push(slides[i]);
|
5431 | }
|
5432 | } else {
|
5433 | swiper.virtual.slides.push(slides);
|
5434 | }
|
5435 |
|
5436 | swiper.virtual.update(true);
|
5437 | },
|
5438 | prependSlide: function prependSlide(slides) {
|
5439 | var swiper = this;
|
5440 | var activeIndex = swiper.activeIndex;
|
5441 | var newActiveIndex = activeIndex + 1;
|
5442 | var numberOfNewSlides = 1;
|
5443 |
|
5444 | if (Array.isArray(slides)) {
|
5445 | for (var i = 0; i < slides.length; i += 1) {
|
5446 | if (slides[i]) swiper.virtual.slides.unshift(slides[i]);
|
5447 | }
|
5448 |
|
5449 | newActiveIndex = activeIndex + slides.length;
|
5450 | numberOfNewSlides = slides.length;
|
5451 | } else {
|
5452 | swiper.virtual.slides.unshift(slides);
|
5453 | }
|
5454 |
|
5455 | if (swiper.params.virtual.cache) {
|
5456 | var cache = swiper.virtual.cache;
|
5457 | var newCache = {};
|
5458 | Object.keys(cache).forEach(function (cachedIndex) {
|
5459 | var $cachedEl = cache[cachedIndex];
|
5460 | var cachedElIndex = $cachedEl.attr('data-swiper-slide-index');
|
5461 |
|
5462 | if (cachedElIndex) {
|
5463 | $cachedEl.attr('data-swiper-slide-index', parseInt(cachedElIndex, 10) + 1);
|
5464 | }
|
5465 |
|
5466 | newCache[parseInt(cachedIndex, 10) + numberOfNewSlides] = $cachedEl;
|
5467 | });
|
5468 | swiper.virtual.cache = newCache;
|
5469 | }
|
5470 |
|
5471 | swiper.virtual.update(true);
|
5472 | swiper.slideTo(newActiveIndex, 0);
|
5473 | },
|
5474 | removeSlide: function removeSlide(slidesIndexes) {
|
5475 | var swiper = this;
|
5476 | if (typeof slidesIndexes === 'undefined' || slidesIndexes === null) return;
|
5477 | var activeIndex = swiper.activeIndex;
|
5478 |
|
5479 | if (Array.isArray(slidesIndexes)) {
|
5480 | for (var i = slidesIndexes.length - 1; i >= 0; i -= 1) {
|
5481 | swiper.virtual.slides.splice(slidesIndexes[i], 1);
|
5482 |
|
5483 | if (swiper.params.virtual.cache) {
|
5484 | delete swiper.virtual.cache[slidesIndexes[i]];
|
5485 | }
|
5486 |
|
5487 | if (slidesIndexes[i] < activeIndex) activeIndex -= 1;
|
5488 | activeIndex = Math.max(activeIndex, 0);
|
5489 | }
|
5490 | } else {
|
5491 | swiper.virtual.slides.splice(slidesIndexes, 1);
|
5492 |
|
5493 | if (swiper.params.virtual.cache) {
|
5494 | delete swiper.virtual.cache[slidesIndexes];
|
5495 | }
|
5496 |
|
5497 | if (slidesIndexes < activeIndex) activeIndex -= 1;
|
5498 | activeIndex = Math.max(activeIndex, 0);
|
5499 | }
|
5500 |
|
5501 | swiper.virtual.update(true);
|
5502 | swiper.slideTo(activeIndex, 0);
|
5503 | },
|
5504 | removeAllSlides: function removeAllSlides() {
|
5505 | var swiper = this;
|
5506 | swiper.virtual.slides = [];
|
5507 |
|
5508 | if (swiper.params.virtual.cache) {
|
5509 | swiper.virtual.cache = {};
|
5510 | }
|
5511 |
|
5512 | swiper.virtual.update(true);
|
5513 | swiper.slideTo(0, 0);
|
5514 | }
|
5515 | };
|
5516 | var Virtual$1 = {
|
5517 | name: 'virtual',
|
5518 | params: {
|
5519 | virtual: {
|
5520 | enabled: false,
|
5521 | slides: [],
|
5522 | cache: true,
|
5523 | renderSlide: null,
|
5524 | renderExternal: null,
|
5525 | renderExternalUpdate: true,
|
5526 | addSlidesBefore: 0,
|
5527 | addSlidesAfter: 0
|
5528 | }
|
5529 | },
|
5530 | create: function create() {
|
5531 | var swiper = this;
|
5532 | bindModuleMethods(swiper, {
|
5533 | virtual: _extends({}, Virtual, {
|
5534 | slides: swiper.params.virtual.slides,
|
5535 | cache: {}
|
5536 | })
|
5537 | });
|
5538 | },
|
5539 | on: {
|
5540 | beforeInit: function beforeInit(swiper) {
|
5541 | if (!swiper.params.virtual.enabled) return;
|
5542 | swiper.classNames.push(swiper.params.containerModifierClass + "virtual");
|
5543 | var overwriteParams = {
|
5544 | watchSlidesProgress: true
|
5545 | };
|
5546 | extend(swiper.params, overwriteParams);
|
5547 | extend(swiper.originalParams, overwriteParams);
|
5548 |
|
5549 | if (!swiper.params.initialSlide) {
|
5550 | swiper.virtual.update();
|
5551 | }
|
5552 | },
|
5553 | setTranslate: function setTranslate(swiper) {
|
5554 | if (!swiper.params.virtual.enabled) return;
|
5555 | swiper.virtual.update();
|
5556 | }
|
5557 | }
|
5558 | };
|
5559 |
|
5560 | var Keyboard = {
|
5561 | handle: function handle(event) {
|
5562 | var swiper = this;
|
5563 | var window = getWindow();
|
5564 | var document = getDocument();
|
5565 | var rtl = swiper.rtlTranslate;
|
5566 | var e = event;
|
5567 | if (e.originalEvent) e = e.originalEvent;
|
5568 |
|
5569 | var kc = e.keyCode || e.charCode;
|
5570 | var pageUpDown = swiper.params.keyboard.pageUpDown;
|
5571 | var isPageUp = pageUpDown && kc === 33;
|
5572 | var isPageDown = pageUpDown && kc === 34;
|
5573 | var isArrowLeft = kc === 37;
|
5574 | var isArrowRight = kc === 39;
|
5575 | var isArrowUp = kc === 38;
|
5576 | var isArrowDown = kc === 40;
|
5577 |
|
5578 | if (!swiper.allowSlideNext && (swiper.isHorizontal() && isArrowRight || swiper.isVertical() && isArrowDown || isPageDown)) {
|
5579 | return false;
|
5580 | }
|
5581 |
|
5582 | if (!swiper.allowSlidePrev && (swiper.isHorizontal() && isArrowLeft || swiper.isVertical() && isArrowUp || isPageUp)) {
|
5583 | return false;
|
5584 | }
|
5585 |
|
5586 | if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
|
5587 | return undefined;
|
5588 | }
|
5589 |
|
5590 | if (document.activeElement && document.activeElement.nodeName && (document.activeElement.nodeName.toLowerCase() === 'input' || document.activeElement.nodeName.toLowerCase() === 'textarea')) {
|
5591 | return undefined;
|
5592 | }
|
5593 |
|
5594 | if (swiper.params.keyboard.onlyInViewport && (isPageUp || isPageDown || isArrowLeft || isArrowRight || isArrowUp || isArrowDown)) {
|
5595 | var inView = false;
|
5596 |
|
5597 | if (swiper.$el.parents("." + swiper.params.slideClass).length > 0 && swiper.$el.parents("." + swiper.params.slideActiveClass).length === 0) {
|
5598 | return undefined;
|
5599 | }
|
5600 |
|
5601 | var $el = swiper.$el;
|
5602 | var swiperWidth = $el[0].clientWidth;
|
5603 | var swiperHeight = $el[0].clientHeight;
|
5604 | var windowWidth = window.innerWidth;
|
5605 | var windowHeight = window.innerHeight;
|
5606 | var swiperOffset = swiper.$el.offset();
|
5607 | if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
|
5608 | var swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiperWidth, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiperHeight], [swiperOffset.left + swiperWidth, swiperOffset.top + swiperHeight]];
|
5609 |
|
5610 | for (var i = 0; i < swiperCoord.length; i += 1) {
|
5611 | var point = swiperCoord[i];
|
5612 |
|
5613 | if (point[0] >= 0 && point[0] <= windowWidth && point[1] >= 0 && point[1] <= windowHeight) {
|
5614 | if (point[0] === 0 && point[1] === 0) continue;
|
5615 |
|
5616 | inView = true;
|
5617 | }
|
5618 | }
|
5619 |
|
5620 | if (!inView) return undefined;
|
5621 | }
|
5622 |
|
5623 | if (swiper.isHorizontal()) {
|
5624 | if (isPageUp || isPageDown || isArrowLeft || isArrowRight) {
|
5625 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
5626 | }
|
5627 |
|
5628 | if ((isPageDown || isArrowRight) && !rtl || (isPageUp || isArrowLeft) && rtl) swiper.slideNext();
|
5629 | if ((isPageUp || isArrowLeft) && !rtl || (isPageDown || isArrowRight) && rtl) swiper.slidePrev();
|
5630 | } else {
|
5631 | if (isPageUp || isPageDown || isArrowUp || isArrowDown) {
|
5632 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
5633 | }
|
5634 |
|
5635 | if (isPageDown || isArrowDown) swiper.slideNext();
|
5636 | if (isPageUp || isArrowUp) swiper.slidePrev();
|
5637 | }
|
5638 |
|
5639 | swiper.emit('keyPress', kc);
|
5640 | return undefined;
|
5641 | },
|
5642 | enable: function enable() {
|
5643 | var swiper = this;
|
5644 | var document = getDocument();
|
5645 | if (swiper.keyboard.enabled) return;
|
5646 | $(document).on('keydown', swiper.keyboard.handle);
|
5647 | swiper.keyboard.enabled = true;
|
5648 | },
|
5649 | disable: function disable() {
|
5650 | var swiper = this;
|
5651 | var document = getDocument();
|
5652 | if (!swiper.keyboard.enabled) return;
|
5653 | $(document).off('keydown', swiper.keyboard.handle);
|
5654 | swiper.keyboard.enabled = false;
|
5655 | }
|
5656 | };
|
5657 | var Keyboard$1 = {
|
5658 | name: 'keyboard',
|
5659 | params: {
|
5660 | keyboard: {
|
5661 | enabled: false,
|
5662 | onlyInViewport: true,
|
5663 | pageUpDown: true
|
5664 | }
|
5665 | },
|
5666 | create: function create() {
|
5667 | var swiper = this;
|
5668 | bindModuleMethods(swiper, {
|
5669 | keyboard: _extends({
|
5670 | enabled: false
|
5671 | }, Keyboard)
|
5672 | });
|
5673 | },
|
5674 | on: {
|
5675 | init: function init(swiper) {
|
5676 | if (swiper.params.keyboard.enabled) {
|
5677 | swiper.keyboard.enable();
|
5678 | }
|
5679 | },
|
5680 | destroy: function destroy(swiper) {
|
5681 | if (swiper.keyboard.enabled) {
|
5682 | swiper.keyboard.disable();
|
5683 | }
|
5684 | }
|
5685 | }
|
5686 | };
|
5687 |
|
5688 | function isEventSupported() {
|
5689 | var document = getDocument();
|
5690 | var eventName = 'onwheel';
|
5691 | var isSupported = (eventName in document);
|
5692 |
|
5693 | if (!isSupported) {
|
5694 | var element = document.createElement('div');
|
5695 | element.setAttribute(eventName, 'return;');
|
5696 | isSupported = typeof element[eventName] === 'function';
|
5697 | }
|
5698 |
|
5699 | if (!isSupported && document.implementation && document.implementation.hasFeature &&
|
5700 |
|
5701 | document.implementation.hasFeature('', '') !== true) {
|
5702 |
|
5703 | isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
|
5704 | }
|
5705 |
|
5706 | return isSupported;
|
5707 | }
|
5708 |
|
5709 | var Mousewheel = {
|
5710 | lastScrollTime: now(),
|
5711 | lastEventBeforeSnap: undefined,
|
5712 | recentWheelEvents: [],
|
5713 | event: function event() {
|
5714 | var window = getWindow();
|
5715 | if (window.navigator.userAgent.indexOf('firefox') > -1) return 'DOMMouseScroll';
|
5716 | return isEventSupported() ? 'wheel' : 'mousewheel';
|
5717 | },
|
5718 | normalize: function normalize(e) {
|
5719 |
|
5720 | var PIXEL_STEP = 10;
|
5721 | var LINE_HEIGHT = 40;
|
5722 | var PAGE_HEIGHT = 800;
|
5723 | var sX = 0;
|
5724 | var sY = 0;
|
5725 |
|
5726 | var pX = 0;
|
5727 | var pY = 0;
|
5728 |
|
5729 |
|
5730 | if ('detail' in e) {
|
5731 | sY = e.detail;
|
5732 | }
|
5733 |
|
5734 | if ('wheelDelta' in e) {
|
5735 | sY = -e.wheelDelta / 120;
|
5736 | }
|
5737 |
|
5738 | if ('wheelDeltaY' in e) {
|
5739 | sY = -e.wheelDeltaY / 120;
|
5740 | }
|
5741 |
|
5742 | if ('wheelDeltaX' in e) {
|
5743 | sX = -e.wheelDeltaX / 120;
|
5744 | }
|
5745 |
|
5746 |
|
5747 | if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) {
|
5748 | sX = sY;
|
5749 | sY = 0;
|
5750 | }
|
5751 |
|
5752 | pX = sX * PIXEL_STEP;
|
5753 | pY = sY * PIXEL_STEP;
|
5754 |
|
5755 | if ('deltaY' in e) {
|
5756 | pY = e.deltaY;
|
5757 | }
|
5758 |
|
5759 | if ('deltaX' in e) {
|
5760 | pX = e.deltaX;
|
5761 | }
|
5762 |
|
5763 | if (e.shiftKey && !pX) {
|
5764 |
|
5765 | pX = pY;
|
5766 | pY = 0;
|
5767 | }
|
5768 |
|
5769 | if ((pX || pY) && e.deltaMode) {
|
5770 | if (e.deltaMode === 1) {
|
5771 |
|
5772 | pX *= LINE_HEIGHT;
|
5773 | pY *= LINE_HEIGHT;
|
5774 | } else {
|
5775 |
|
5776 | pX *= PAGE_HEIGHT;
|
5777 | pY *= PAGE_HEIGHT;
|
5778 | }
|
5779 | }
|
5780 |
|
5781 |
|
5782 | if (pX && !sX) {
|
5783 | sX = pX < 1 ? -1 : 1;
|
5784 | }
|
5785 |
|
5786 | if (pY && !sY) {
|
5787 | sY = pY < 1 ? -1 : 1;
|
5788 | }
|
5789 |
|
5790 | return {
|
5791 | spinX: sX,
|
5792 | spinY: sY,
|
5793 | pixelX: pX,
|
5794 | pixelY: pY
|
5795 | };
|
5796 | },
|
5797 | handleMouseEnter: function handleMouseEnter() {
|
5798 | var swiper = this;
|
5799 | swiper.mouseEntered = true;
|
5800 | },
|
5801 | handleMouseLeave: function handleMouseLeave() {
|
5802 | var swiper = this;
|
5803 | swiper.mouseEntered = false;
|
5804 | },
|
5805 | handle: function handle(event) {
|
5806 | var e = event;
|
5807 | var disableParentSwiper = true;
|
5808 | var swiper = this;
|
5809 | var params = swiper.params.mousewheel;
|
5810 |
|
5811 | if (swiper.params.cssMode) {
|
5812 | e.preventDefault();
|
5813 | }
|
5814 |
|
5815 | var target = swiper.$el;
|
5816 |
|
5817 | if (swiper.params.mousewheel.eventsTarget !== 'container') {
|
5818 | target = $(swiper.params.mousewheel.eventsTarget);
|
5819 | }
|
5820 |
|
5821 | if (!swiper.mouseEntered && !target[0].contains(e.target) && !params.releaseOnEdges) return true;
|
5822 | if (e.originalEvent) e = e.originalEvent;
|
5823 |
|
5824 | var delta = 0;
|
5825 | var rtlFactor = swiper.rtlTranslate ? -1 : 1;
|
5826 | var data = Mousewheel.normalize(e);
|
5827 |
|
5828 | if (params.forceToAxis) {
|
5829 | if (swiper.isHorizontal()) {
|
5830 | if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) delta = -data.pixelX * rtlFactor;else return true;
|
5831 | } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) delta = -data.pixelY;else return true;
|
5832 | } else {
|
5833 | delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY;
|
5834 | }
|
5835 |
|
5836 | if (delta === 0) return true;
|
5837 | if (params.invert) delta = -delta;
|
5838 |
|
5839 | var positions = swiper.getTranslate() + delta * params.sensitivity;
|
5840 | if (positions >= swiper.minTranslate()) positions = swiper.minTranslate();
|
5841 | if (positions <= swiper.maxTranslate()) positions = swiper.maxTranslate();
|
5842 |
|
5843 |
|
5844 |
|
5845 |
|
5846 |
|
5847 |
|
5848 |
|
5849 | disableParentSwiper = swiper.params.loop ? true : !(positions === swiper.minTranslate() || positions === swiper.maxTranslate());
|
5850 | if (disableParentSwiper && swiper.params.nested) e.stopPropagation();
|
5851 |
|
5852 | if (!swiper.params.freeMode) {
|
5853 |
|
5854 | var newEvent = {
|
5855 | time: now(),
|
5856 | delta: Math.abs(delta),
|
5857 | direction: Math.sign(delta),
|
5858 | raw: event
|
5859 | };
|
5860 |
|
5861 | var recentWheelEvents = swiper.mousewheel.recentWheelEvents;
|
5862 |
|
5863 | if (recentWheelEvents.length >= 2) {
|
5864 | recentWheelEvents.shift();
|
5865 | }
|
5866 |
|
5867 | var prevEvent = recentWheelEvents.length ? recentWheelEvents[recentWheelEvents.length - 1] : undefined;
|
5868 | recentWheelEvents.push(newEvent);
|
5869 |
|
5870 |
|
5871 |
|
5872 |
|
5873 |
|
5874 |
|
5875 | if (prevEvent) {
|
5876 | if (newEvent.direction !== prevEvent.direction || newEvent.delta > prevEvent.delta || newEvent.time > prevEvent.time + 150) {
|
5877 | swiper.mousewheel.animateSlider(newEvent);
|
5878 | }
|
5879 | } else {
|
5880 | swiper.mousewheel.animateSlider(newEvent);
|
5881 | }
|
5882 |
|
5883 |
|
5884 |
|
5885 | if (swiper.mousewheel.releaseScroll(newEvent)) {
|
5886 | return true;
|
5887 | }
|
5888 | } else {
|
5889 |
|
5890 |
|
5891 |
|
5892 |
|
5893 |
|
5894 | var _newEvent = {
|
5895 | time: now(),
|
5896 | delta: Math.abs(delta),
|
5897 | direction: Math.sign(delta)
|
5898 | };
|
5899 | var lastEventBeforeSnap = swiper.mousewheel.lastEventBeforeSnap;
|
5900 | var ignoreWheelEvents = lastEventBeforeSnap && _newEvent.time < lastEventBeforeSnap.time + 500 && _newEvent.delta <= lastEventBeforeSnap.delta && _newEvent.direction === lastEventBeforeSnap.direction;
|
5901 |
|
5902 | if (!ignoreWheelEvents) {
|
5903 | swiper.mousewheel.lastEventBeforeSnap = undefined;
|
5904 |
|
5905 | if (swiper.params.loop) {
|
5906 | swiper.loopFix();
|
5907 | }
|
5908 |
|
5909 | var position = swiper.getTranslate() + delta * params.sensitivity;
|
5910 | var wasBeginning = swiper.isBeginning;
|
5911 | var wasEnd = swiper.isEnd;
|
5912 | if (position >= swiper.minTranslate()) position = swiper.minTranslate();
|
5913 | if (position <= swiper.maxTranslate()) position = swiper.maxTranslate();
|
5914 | swiper.setTransition(0);
|
5915 | swiper.setTranslate(position);
|
5916 | swiper.updateProgress();
|
5917 | swiper.updateActiveIndex();
|
5918 | swiper.updateSlidesClasses();
|
5919 |
|
5920 | if (!wasBeginning && swiper.isBeginning || !wasEnd && swiper.isEnd) {
|
5921 | swiper.updateSlidesClasses();
|
5922 | }
|
5923 |
|
5924 | if (swiper.params.freeModeSticky) {
|
5925 |
|
5926 |
|
5927 |
|
5928 |
|
5929 |
|
5930 |
|
5931 |
|
5932 |
|
5933 |
|
5934 |
|
5935 |
|
5936 | clearTimeout(swiper.mousewheel.timeout);
|
5937 | swiper.mousewheel.timeout = undefined;
|
5938 | var _recentWheelEvents = swiper.mousewheel.recentWheelEvents;
|
5939 |
|
5940 | if (_recentWheelEvents.length >= 15) {
|
5941 | _recentWheelEvents.shift();
|
5942 |
|
5943 | }
|
5944 |
|
5945 | var _prevEvent = _recentWheelEvents.length ? _recentWheelEvents[_recentWheelEvents.length - 1] : undefined;
|
5946 |
|
5947 | var firstEvent = _recentWheelEvents[0];
|
5948 |
|
5949 | _recentWheelEvents.push(_newEvent);
|
5950 |
|
5951 | if (_prevEvent && (_newEvent.delta > _prevEvent.delta || _newEvent.direction !== _prevEvent.direction)) {
|
5952 |
|
5953 | _recentWheelEvents.splice(0);
|
5954 | } else if (_recentWheelEvents.length >= 15 && _newEvent.time - firstEvent.time < 500 && firstEvent.delta - _newEvent.delta >= 1 && _newEvent.delta <= 6) {
|
5955 |
|
5956 |
|
5957 |
|
5958 |
|
5959 |
|
5960 |
|
5961 | var snapToThreshold = delta > 0 ? 0.8 : 0.2;
|
5962 | swiper.mousewheel.lastEventBeforeSnap = _newEvent;
|
5963 |
|
5964 | _recentWheelEvents.splice(0);
|
5965 |
|
5966 | swiper.mousewheel.timeout = nextTick(function () {
|
5967 | swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
|
5968 | }, 0);
|
5969 | }
|
5970 |
|
5971 | if (!swiper.mousewheel.timeout) {
|
5972 |
|
5973 |
|
5974 |
|
5975 | swiper.mousewheel.timeout = nextTick(function () {
|
5976 | var snapToThreshold = 0.5;
|
5977 | swiper.mousewheel.lastEventBeforeSnap = _newEvent;
|
5978 |
|
5979 | _recentWheelEvents.splice(0);
|
5980 |
|
5981 | swiper.slideToClosest(swiper.params.speed, true, undefined, snapToThreshold);
|
5982 | }, 500);
|
5983 | }
|
5984 | }
|
5985 |
|
5986 |
|
5987 | if (!ignoreWheelEvents) swiper.emit('scroll', e);
|
5988 |
|
5989 | if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) swiper.autoplay.stop();
|
5990 |
|
5991 | if (position === swiper.minTranslate() || position === swiper.maxTranslate()) return true;
|
5992 | }
|
5993 | }
|
5994 |
|
5995 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
5996 | return false;
|
5997 | },
|
5998 | animateSlider: function animateSlider(newEvent) {
|
5999 | var swiper = this;
|
6000 | var window = getWindow();
|
6001 |
|
6002 | if (this.params.mousewheel.thresholdDelta && newEvent.delta < this.params.mousewheel.thresholdDelta) {
|
6003 |
|
6004 | return false;
|
6005 | }
|
6006 |
|
6007 | if (this.params.mousewheel.thresholdTime && now() - swiper.mousewheel.lastScrollTime < this.params.mousewheel.thresholdTime) {
|
6008 |
|
6009 | return false;
|
6010 | }
|
6011 |
|
6012 |
|
6013 |
|
6014 |
|
6015 | if (newEvent.delta >= 6 && now() - swiper.mousewheel.lastScrollTime < 60) {
|
6016 |
|
6017 | return true;
|
6018 | }
|
6019 |
|
6020 |
|
6021 |
|
6022 |
|
6023 |
|
6024 |
|
6025 |
|
6026 |
|
6027 |
|
6028 |
|
6029 |
|
6030 |
|
6031 |
|
6032 | if (newEvent.direction < 0) {
|
6033 | if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) {
|
6034 | swiper.slideNext();
|
6035 | swiper.emit('scroll', newEvent.raw);
|
6036 | }
|
6037 | } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) {
|
6038 | swiper.slidePrev();
|
6039 | swiper.emit('scroll', newEvent.raw);
|
6040 | }
|
6041 |
|
6042 |
|
6043 | swiper.mousewheel.lastScrollTime = new window.Date().getTime();
|
6044 |
|
6045 | return false;
|
6046 | },
|
6047 | releaseScroll: function releaseScroll(newEvent) {
|
6048 | var swiper = this;
|
6049 | var params = swiper.params.mousewheel;
|
6050 |
|
6051 | if (newEvent.direction < 0) {
|
6052 | if (swiper.isEnd && !swiper.params.loop && params.releaseOnEdges) {
|
6053 |
|
6054 | return true;
|
6055 | }
|
6056 | } else if (swiper.isBeginning && !swiper.params.loop && params.releaseOnEdges) {
|
6057 |
|
6058 | return true;
|
6059 | }
|
6060 |
|
6061 | return false;
|
6062 | },
|
6063 | enable: function enable() {
|
6064 | var swiper = this;
|
6065 | var event = Mousewheel.event();
|
6066 |
|
6067 | if (swiper.params.cssMode) {
|
6068 | swiper.wrapperEl.removeEventListener(event, swiper.mousewheel.handle);
|
6069 | return true;
|
6070 | }
|
6071 |
|
6072 | if (!event) return false;
|
6073 | if (swiper.mousewheel.enabled) return false;
|
6074 | var target = swiper.$el;
|
6075 |
|
6076 | if (swiper.params.mousewheel.eventsTarget !== 'container') {
|
6077 | target = $(swiper.params.mousewheel.eventsTarget);
|
6078 | }
|
6079 |
|
6080 | target.on('mouseenter', swiper.mousewheel.handleMouseEnter);
|
6081 | target.on('mouseleave', swiper.mousewheel.handleMouseLeave);
|
6082 | target.on(event, swiper.mousewheel.handle);
|
6083 | swiper.mousewheel.enabled = true;
|
6084 | return true;
|
6085 | },
|
6086 | disable: function disable() {
|
6087 | var swiper = this;
|
6088 | var event = Mousewheel.event();
|
6089 |
|
6090 | if (swiper.params.cssMode) {
|
6091 | swiper.wrapperEl.addEventListener(event, swiper.mousewheel.handle);
|
6092 | return true;
|
6093 | }
|
6094 |
|
6095 | if (!event) return false;
|
6096 | if (!swiper.mousewheel.enabled) return false;
|
6097 | var target = swiper.$el;
|
6098 |
|
6099 | if (swiper.params.mousewheel.eventsTarget !== 'container') {
|
6100 | target = $(swiper.params.mousewheel.eventsTarget);
|
6101 | }
|
6102 |
|
6103 | target.off(event, swiper.mousewheel.handle);
|
6104 | swiper.mousewheel.enabled = false;
|
6105 | return true;
|
6106 | }
|
6107 | };
|
6108 | var Mousewheel$1 = {
|
6109 | name: 'mousewheel',
|
6110 | params: {
|
6111 | mousewheel: {
|
6112 | enabled: false,
|
6113 | releaseOnEdges: false,
|
6114 | invert: false,
|
6115 | forceToAxis: false,
|
6116 | sensitivity: 1,
|
6117 | eventsTarget: 'container',
|
6118 | thresholdDelta: null,
|
6119 | thresholdTime: null
|
6120 | }
|
6121 | },
|
6122 | create: function create() {
|
6123 | var swiper = this;
|
6124 | bindModuleMethods(swiper, {
|
6125 | mousewheel: {
|
6126 | enabled: false,
|
6127 | lastScrollTime: now(),
|
6128 | lastEventBeforeSnap: undefined,
|
6129 | recentWheelEvents: [],
|
6130 | enable: Mousewheel.enable,
|
6131 | disable: Mousewheel.disable,
|
6132 | handle: Mousewheel.handle,
|
6133 | handleMouseEnter: Mousewheel.handleMouseEnter,
|
6134 | handleMouseLeave: Mousewheel.handleMouseLeave,
|
6135 | animateSlider: Mousewheel.animateSlider,
|
6136 | releaseScroll: Mousewheel.releaseScroll
|
6137 | }
|
6138 | });
|
6139 | },
|
6140 | on: {
|
6141 | init: function init(swiper) {
|
6142 | if (!swiper.params.mousewheel.enabled && swiper.params.cssMode) {
|
6143 | swiper.mousewheel.disable();
|
6144 | }
|
6145 |
|
6146 | if (swiper.params.mousewheel.enabled) swiper.mousewheel.enable();
|
6147 | },
|
6148 | destroy: function destroy(swiper) {
|
6149 | if (swiper.params.cssMode) {
|
6150 | swiper.mousewheel.enable();
|
6151 | }
|
6152 |
|
6153 | if (swiper.mousewheel.enabled) swiper.mousewheel.disable();
|
6154 | }
|
6155 | }
|
6156 | };
|
6157 |
|
6158 | var Navigation = {
|
6159 | toggleEl: function toggleEl($el, disabled) {
|
6160 | $el[disabled ? 'addClass' : 'removeClass'](this.params.navigation.disabledClass);
|
6161 | if ($el[0] && $el[0].tagName === 'BUTTON') $el[0].disabled = disabled;
|
6162 | },
|
6163 | update: function update() {
|
6164 |
|
6165 | var swiper = this;
|
6166 | var params = swiper.params.navigation;
|
6167 | var toggleEl = swiper.navigation.toggleEl;
|
6168 | if (swiper.params.loop) return;
|
6169 | var _swiper$navigation = swiper.navigation,
|
6170 | $nextEl = _swiper$navigation.$nextEl,
|
6171 | $prevEl = _swiper$navigation.$prevEl;
|
6172 |
|
6173 | if ($prevEl && $prevEl.length > 0) {
|
6174 | if (swiper.isBeginning) {
|
6175 | toggleEl($prevEl, true);
|
6176 | } else {
|
6177 | toggleEl($prevEl, false);
|
6178 | }
|
6179 |
|
6180 | $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
|
6181 | }
|
6182 |
|
6183 | if ($nextEl && $nextEl.length > 0) {
|
6184 | if (swiper.isEnd) {
|
6185 | toggleEl($nextEl, true);
|
6186 | } else {
|
6187 | toggleEl($nextEl, false);
|
6188 | }
|
6189 |
|
6190 | $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
|
6191 | }
|
6192 | },
|
6193 | onPrevClick: function onPrevClick(e) {
|
6194 | var swiper = this;
|
6195 | e.preventDefault();
|
6196 | if (swiper.isBeginning && !swiper.params.loop) return;
|
6197 | swiper.slidePrev();
|
6198 | },
|
6199 | onNextClick: function onNextClick(e) {
|
6200 | var swiper = this;
|
6201 | e.preventDefault();
|
6202 | if (swiper.isEnd && !swiper.params.loop) return;
|
6203 | swiper.slideNext();
|
6204 | },
|
6205 | init: function init() {
|
6206 | var swiper = this;
|
6207 | var params = swiper.params.navigation;
|
6208 | if (!(params.nextEl || params.prevEl)) return;
|
6209 | var $nextEl;
|
6210 | var $prevEl;
|
6211 |
|
6212 | if (params.nextEl) {
|
6213 | $nextEl = $(params.nextEl);
|
6214 |
|
6215 | if (swiper.params.uniqueNavElements && typeof params.nextEl === 'string' && $nextEl.length > 1 && swiper.$el.find(params.nextEl).length === 1) {
|
6216 | $nextEl = swiper.$el.find(params.nextEl);
|
6217 | }
|
6218 | }
|
6219 |
|
6220 | if (params.prevEl) {
|
6221 | $prevEl = $(params.prevEl);
|
6222 |
|
6223 | if (swiper.params.uniqueNavElements && typeof params.prevEl === 'string' && $prevEl.length > 1 && swiper.$el.find(params.prevEl).length === 1) {
|
6224 | $prevEl = swiper.$el.find(params.prevEl);
|
6225 | }
|
6226 | }
|
6227 |
|
6228 | if ($nextEl && $nextEl.length > 0) {
|
6229 | $nextEl.on('click', swiper.navigation.onNextClick);
|
6230 | }
|
6231 |
|
6232 | if ($prevEl && $prevEl.length > 0) {
|
6233 | $prevEl.on('click', swiper.navigation.onPrevClick);
|
6234 | }
|
6235 |
|
6236 | extend(swiper.navigation, {
|
6237 | $nextEl: $nextEl,
|
6238 | nextEl: $nextEl && $nextEl[0],
|
6239 | $prevEl: $prevEl,
|
6240 | prevEl: $prevEl && $prevEl[0]
|
6241 | });
|
6242 | },
|
6243 | destroy: function destroy() {
|
6244 | var swiper = this;
|
6245 | var _swiper$navigation2 = swiper.navigation,
|
6246 | $nextEl = _swiper$navigation2.$nextEl,
|
6247 | $prevEl = _swiper$navigation2.$prevEl;
|
6248 |
|
6249 | if ($nextEl && $nextEl.length) {
|
6250 | $nextEl.off('click', swiper.navigation.onNextClick);
|
6251 | $nextEl.removeClass(swiper.params.navigation.disabledClass);
|
6252 | }
|
6253 |
|
6254 | if ($prevEl && $prevEl.length) {
|
6255 | $prevEl.off('click', swiper.navigation.onPrevClick);
|
6256 | $prevEl.removeClass(swiper.params.navigation.disabledClass);
|
6257 | }
|
6258 | }
|
6259 | };
|
6260 | var Navigation$1 = {
|
6261 | name: 'navigation',
|
6262 | params: {
|
6263 | navigation: {
|
6264 | nextEl: null,
|
6265 | prevEl: null,
|
6266 | hideOnClick: false,
|
6267 | disabledClass: 'swiper-button-disabled',
|
6268 | hiddenClass: 'swiper-button-hidden',
|
6269 | lockClass: 'swiper-button-lock'
|
6270 | }
|
6271 | },
|
6272 | create: function create() {
|
6273 | var swiper = this;
|
6274 | bindModuleMethods(swiper, {
|
6275 | navigation: _extends({}, Navigation)
|
6276 | });
|
6277 | },
|
6278 | on: {
|
6279 | init: function init(swiper) {
|
6280 | swiper.navigation.init();
|
6281 | swiper.navigation.update();
|
6282 | },
|
6283 | toEdge: function toEdge(swiper) {
|
6284 | swiper.navigation.update();
|
6285 | },
|
6286 | fromEdge: function fromEdge(swiper) {
|
6287 | swiper.navigation.update();
|
6288 | },
|
6289 | destroy: function destroy(swiper) {
|
6290 | swiper.navigation.destroy();
|
6291 | },
|
6292 | click: function click(swiper, e) {
|
6293 | var _swiper$navigation3 = swiper.navigation,
|
6294 | $nextEl = _swiper$navigation3.$nextEl,
|
6295 | $prevEl = _swiper$navigation3.$prevEl;
|
6296 | var targetEl = e.target;
|
6297 |
|
6298 | if (swiper.params.navigation.hideOnClick && !$(targetEl).is($prevEl) && !$(targetEl).is($nextEl)) {
|
6299 | if (swiper.pagination && swiper.params.pagination && swiper.params.pagination.clickable && (swiper.pagination.el === targetEl || swiper.pagination.el.contains(targetEl))) return;
|
6300 | var isHidden;
|
6301 |
|
6302 | if ($nextEl) {
|
6303 | isHidden = $nextEl.hasClass(swiper.params.navigation.hiddenClass);
|
6304 | } else if ($prevEl) {
|
6305 | isHidden = $prevEl.hasClass(swiper.params.navigation.hiddenClass);
|
6306 | }
|
6307 |
|
6308 | if (isHidden === true) {
|
6309 | swiper.emit('navigationShow');
|
6310 | } else {
|
6311 | swiper.emit('navigationHide');
|
6312 | }
|
6313 |
|
6314 | if ($nextEl) {
|
6315 | $nextEl.toggleClass(swiper.params.navigation.hiddenClass);
|
6316 | }
|
6317 |
|
6318 | if ($prevEl) {
|
6319 | $prevEl.toggleClass(swiper.params.navigation.hiddenClass);
|
6320 | }
|
6321 | }
|
6322 | }
|
6323 | }
|
6324 | };
|
6325 |
|
6326 | var Pagination = {
|
6327 | update: function update() {
|
6328 |
|
6329 | var swiper = this;
|
6330 | var rtl = swiper.rtl;
|
6331 | var params = swiper.params.pagination;
|
6332 | if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return;
|
6333 | var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
|
6334 | var $el = swiper.pagination.$el;
|
6335 |
|
6336 | var current;
|
6337 | var total = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
|
6338 |
|
6339 | if (swiper.params.loop) {
|
6340 | current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup);
|
6341 |
|
6342 | if (current > slidesLength - 1 - swiper.loopedSlides * 2) {
|
6343 | current -= slidesLength - swiper.loopedSlides * 2;
|
6344 | }
|
6345 |
|
6346 | if (current > total - 1) current -= total;
|
6347 | if (current < 0 && swiper.params.paginationType !== 'bullets') current = total + current;
|
6348 | } else if (typeof swiper.snapIndex !== 'undefined') {
|
6349 | current = swiper.snapIndex;
|
6350 | } else {
|
6351 | current = swiper.activeIndex || 0;
|
6352 | }
|
6353 |
|
6354 |
|
6355 | if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) {
|
6356 | var bullets = swiper.pagination.bullets;
|
6357 | var firstIndex;
|
6358 | var lastIndex;
|
6359 | var midIndex;
|
6360 |
|
6361 | if (params.dynamicBullets) {
|
6362 | swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true);
|
6363 | $el.css(swiper.isHorizontal() ? 'width' : 'height', swiper.pagination.bulletSize * (params.dynamicMainBullets + 4) + "px");
|
6364 |
|
6365 | if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) {
|
6366 | swiper.pagination.dynamicBulletIndex += current - swiper.previousIndex;
|
6367 |
|
6368 | if (swiper.pagination.dynamicBulletIndex > params.dynamicMainBullets - 1) {
|
6369 | swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1;
|
6370 | } else if (swiper.pagination.dynamicBulletIndex < 0) {
|
6371 | swiper.pagination.dynamicBulletIndex = 0;
|
6372 | }
|
6373 | }
|
6374 |
|
6375 | firstIndex = current - swiper.pagination.dynamicBulletIndex;
|
6376 | lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
|
6377 | midIndex = (lastIndex + firstIndex) / 2;
|
6378 | }
|
6379 |
|
6380 | bullets.removeClass(params.bulletActiveClass + " " + params.bulletActiveClass + "-next " + params.bulletActiveClass + "-next-next " + params.bulletActiveClass + "-prev " + params.bulletActiveClass + "-prev-prev " + params.bulletActiveClass + "-main");
|
6381 |
|
6382 | if ($el.length > 1) {
|
6383 | bullets.each(function (bullet) {
|
6384 | var $bullet = $(bullet);
|
6385 | var bulletIndex = $bullet.index();
|
6386 |
|
6387 | if (bulletIndex === current) {
|
6388 | $bullet.addClass(params.bulletActiveClass);
|
6389 | }
|
6390 |
|
6391 | if (params.dynamicBullets) {
|
6392 | if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) {
|
6393 | $bullet.addClass(params.bulletActiveClass + "-main");
|
6394 | }
|
6395 |
|
6396 | if (bulletIndex === firstIndex) {
|
6397 | $bullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev");
|
6398 | }
|
6399 |
|
6400 | if (bulletIndex === lastIndex) {
|
6401 | $bullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next");
|
6402 | }
|
6403 | }
|
6404 | });
|
6405 | } else {
|
6406 | var $bullet = bullets.eq(current);
|
6407 | var bulletIndex = $bullet.index();
|
6408 | $bullet.addClass(params.bulletActiveClass);
|
6409 |
|
6410 | if (params.dynamicBullets) {
|
6411 | var $firstDisplayedBullet = bullets.eq(firstIndex);
|
6412 | var $lastDisplayedBullet = bullets.eq(lastIndex);
|
6413 |
|
6414 | for (var i = firstIndex; i <= lastIndex; i += 1) {
|
6415 | bullets.eq(i).addClass(params.bulletActiveClass + "-main");
|
6416 | }
|
6417 |
|
6418 | if (swiper.params.loop) {
|
6419 | if (bulletIndex >= bullets.length - params.dynamicMainBullets) {
|
6420 | for (var _i = params.dynamicMainBullets; _i >= 0; _i -= 1) {
|
6421 | bullets.eq(bullets.length - _i).addClass(params.bulletActiveClass + "-main");
|
6422 | }
|
6423 |
|
6424 | bullets.eq(bullets.length - params.dynamicMainBullets - 1).addClass(params.bulletActiveClass + "-prev");
|
6425 | } else {
|
6426 | $firstDisplayedBullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev");
|
6427 | $lastDisplayedBullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next");
|
6428 | }
|
6429 | } else {
|
6430 | $firstDisplayedBullet.prev().addClass(params.bulletActiveClass + "-prev").prev().addClass(params.bulletActiveClass + "-prev-prev");
|
6431 | $lastDisplayedBullet.next().addClass(params.bulletActiveClass + "-next").next().addClass(params.bulletActiveClass + "-next-next");
|
6432 | }
|
6433 | }
|
6434 | }
|
6435 |
|
6436 | if (params.dynamicBullets) {
|
6437 | var dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4);
|
6438 | var bulletsOffset = (swiper.pagination.bulletSize * dynamicBulletsLength - swiper.pagination.bulletSize) / 2 - midIndex * swiper.pagination.bulletSize;
|
6439 | var offsetProp = rtl ? 'right' : 'left';
|
6440 | bullets.css(swiper.isHorizontal() ? offsetProp : 'top', bulletsOffset + "px");
|
6441 | }
|
6442 | }
|
6443 |
|
6444 | if (params.type === 'fraction') {
|
6445 | $el.find(classesToSelector(params.currentClass)).text(params.formatFractionCurrent(current + 1));
|
6446 | $el.find(classesToSelector(params.totalClass)).text(params.formatFractionTotal(total));
|
6447 | }
|
6448 |
|
6449 | if (params.type === 'progressbar') {
|
6450 | var progressbarDirection;
|
6451 |
|
6452 | if (params.progressbarOpposite) {
|
6453 | progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal';
|
6454 | } else {
|
6455 | progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical';
|
6456 | }
|
6457 |
|
6458 | var scale = (current + 1) / total;
|
6459 | var scaleX = 1;
|
6460 | var scaleY = 1;
|
6461 |
|
6462 | if (progressbarDirection === 'horizontal') {
|
6463 | scaleX = scale;
|
6464 | } else {
|
6465 | scaleY = scale;
|
6466 | }
|
6467 |
|
6468 | $el.find(classesToSelector(params.progressbarFillClass)).transform("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")").transition(swiper.params.speed);
|
6469 | }
|
6470 |
|
6471 | if (params.type === 'custom' && params.renderCustom) {
|
6472 | $el.html(params.renderCustom(swiper, current + 1, total));
|
6473 | swiper.emit('paginationRender', $el[0]);
|
6474 | } else {
|
6475 | swiper.emit('paginationUpdate', $el[0]);
|
6476 | }
|
6477 |
|
6478 | $el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass);
|
6479 | },
|
6480 | render: function render() {
|
6481 |
|
6482 | var swiper = this;
|
6483 | var params = swiper.params.pagination;
|
6484 | if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return;
|
6485 | var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length;
|
6486 | var $el = swiper.pagination.$el;
|
6487 | var paginationHTML = '';
|
6488 |
|
6489 | if (params.type === 'bullets') {
|
6490 | var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - swiper.loopedSlides * 2) / swiper.params.slidesPerGroup) : swiper.snapGrid.length;
|
6491 |
|
6492 | if (swiper.params.freeMode && !swiper.params.loop && numberOfBullets > slidesLength) {
|
6493 | numberOfBullets = slidesLength;
|
6494 | }
|
6495 |
|
6496 | for (var i = 0; i < numberOfBullets; i += 1) {
|
6497 | if (params.renderBullet) {
|
6498 | paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass);
|
6499 | } else {
|
6500 | paginationHTML += "<" + params.bulletElement + " class=\"" + params.bulletClass + "\"></" + params.bulletElement + ">";
|
6501 | }
|
6502 | }
|
6503 |
|
6504 | $el.html(paginationHTML);
|
6505 | swiper.pagination.bullets = $el.find(classesToSelector(params.bulletClass));
|
6506 | }
|
6507 |
|
6508 | if (params.type === 'fraction') {
|
6509 | if (params.renderFraction) {
|
6510 | paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass);
|
6511 | } else {
|
6512 | paginationHTML = "<span class=\"" + params.currentClass + "\"></span>" + ' / ' + ("<span class=\"" + params.totalClass + "\"></span>");
|
6513 | }
|
6514 |
|
6515 | $el.html(paginationHTML);
|
6516 | }
|
6517 |
|
6518 | if (params.type === 'progressbar') {
|
6519 | if (params.renderProgressbar) {
|
6520 | paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass);
|
6521 | } else {
|
6522 | paginationHTML = "<span class=\"" + params.progressbarFillClass + "\"></span>";
|
6523 | }
|
6524 |
|
6525 | $el.html(paginationHTML);
|
6526 | }
|
6527 |
|
6528 | if (params.type !== 'custom') {
|
6529 | swiper.emit('paginationRender', swiper.pagination.$el[0]);
|
6530 | }
|
6531 | },
|
6532 | init: function init() {
|
6533 | var swiper = this;
|
6534 | var params = swiper.params.pagination;
|
6535 | if (!params.el) return;
|
6536 | var $el = $(params.el);
|
6537 | if ($el.length === 0) return;
|
6538 |
|
6539 | if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1) {
|
6540 | $el = swiper.$el.find(params.el);
|
6541 | }
|
6542 |
|
6543 | if (params.type === 'bullets' && params.clickable) {
|
6544 | $el.addClass(params.clickableClass);
|
6545 | }
|
6546 |
|
6547 | $el.addClass(params.modifierClass + params.type);
|
6548 |
|
6549 | if (params.type === 'bullets' && params.dynamicBullets) {
|
6550 | $el.addClass("" + params.modifierClass + params.type + "-dynamic");
|
6551 | swiper.pagination.dynamicBulletIndex = 0;
|
6552 |
|
6553 | if (params.dynamicMainBullets < 1) {
|
6554 | params.dynamicMainBullets = 1;
|
6555 | }
|
6556 | }
|
6557 |
|
6558 | if (params.type === 'progressbar' && params.progressbarOpposite) {
|
6559 | $el.addClass(params.progressbarOppositeClass);
|
6560 | }
|
6561 |
|
6562 | if (params.clickable) {
|
6563 | $el.on('click', classesToSelector(params.bulletClass), function onClick(e) {
|
6564 | e.preventDefault();
|
6565 | var index = $(this).index() * swiper.params.slidesPerGroup;
|
6566 | if (swiper.params.loop) index += swiper.loopedSlides;
|
6567 | swiper.slideTo(index);
|
6568 | });
|
6569 | }
|
6570 |
|
6571 | extend(swiper.pagination, {
|
6572 | $el: $el,
|
6573 | el: $el[0]
|
6574 | });
|
6575 | },
|
6576 | destroy: function destroy() {
|
6577 | var swiper = this;
|
6578 | var params = swiper.params.pagination;
|
6579 | if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) return;
|
6580 | var $el = swiper.pagination.$el;
|
6581 | $el.removeClass(params.hiddenClass);
|
6582 | $el.removeClass(params.modifierClass + params.type);
|
6583 | if (swiper.pagination.bullets) swiper.pagination.bullets.removeClass(params.bulletActiveClass);
|
6584 |
|
6585 | if (params.clickable) {
|
6586 | $el.off('click', classesToSelector(params.bulletClass));
|
6587 | }
|
6588 | }
|
6589 | };
|
6590 | var Pagination$1 = {
|
6591 | name: 'pagination',
|
6592 | params: {
|
6593 | pagination: {
|
6594 | el: null,
|
6595 | bulletElement: 'span',
|
6596 | clickable: false,
|
6597 | hideOnClick: false,
|
6598 | renderBullet: null,
|
6599 | renderProgressbar: null,
|
6600 | renderFraction: null,
|
6601 | renderCustom: null,
|
6602 | progressbarOpposite: false,
|
6603 | type: 'bullets',
|
6604 |
|
6605 | dynamicBullets: false,
|
6606 | dynamicMainBullets: 1,
|
6607 | formatFractionCurrent: function formatFractionCurrent(number) {
|
6608 | return number;
|
6609 | },
|
6610 | formatFractionTotal: function formatFractionTotal(number) {
|
6611 | return number;
|
6612 | },
|
6613 | bulletClass: 'swiper-pagination-bullet',
|
6614 | bulletActiveClass: 'swiper-pagination-bullet-active',
|
6615 | modifierClass: 'swiper-pagination-',
|
6616 |
|
6617 | currentClass: 'swiper-pagination-current',
|
6618 | totalClass: 'swiper-pagination-total',
|
6619 | hiddenClass: 'swiper-pagination-hidden',
|
6620 | progressbarFillClass: 'swiper-pagination-progressbar-fill',
|
6621 | progressbarOppositeClass: 'swiper-pagination-progressbar-opposite',
|
6622 | clickableClass: 'swiper-pagination-clickable',
|
6623 |
|
6624 | lockClass: 'swiper-pagination-lock'
|
6625 | }
|
6626 | },
|
6627 | create: function create() {
|
6628 | var swiper = this;
|
6629 | bindModuleMethods(swiper, {
|
6630 | pagination: _extends({
|
6631 | dynamicBulletIndex: 0
|
6632 | }, Pagination)
|
6633 | });
|
6634 | },
|
6635 | on: {
|
6636 | init: function init(swiper) {
|
6637 | swiper.pagination.init();
|
6638 | swiper.pagination.render();
|
6639 | swiper.pagination.update();
|
6640 | },
|
6641 | activeIndexChange: function activeIndexChange(swiper) {
|
6642 | if (swiper.params.loop) {
|
6643 | swiper.pagination.update();
|
6644 | } else if (typeof swiper.snapIndex === 'undefined') {
|
6645 | swiper.pagination.update();
|
6646 | }
|
6647 | },
|
6648 | snapIndexChange: function snapIndexChange(swiper) {
|
6649 | if (!swiper.params.loop) {
|
6650 | swiper.pagination.update();
|
6651 | }
|
6652 | },
|
6653 | slidesLengthChange: function slidesLengthChange(swiper) {
|
6654 | if (swiper.params.loop) {
|
6655 | swiper.pagination.render();
|
6656 | swiper.pagination.update();
|
6657 | }
|
6658 | },
|
6659 | snapGridLengthChange: function snapGridLengthChange(swiper) {
|
6660 | if (!swiper.params.loop) {
|
6661 | swiper.pagination.render();
|
6662 | swiper.pagination.update();
|
6663 | }
|
6664 | },
|
6665 | destroy: function destroy(swiper) {
|
6666 | swiper.pagination.destroy();
|
6667 | },
|
6668 | click: function click(swiper, e) {
|
6669 | var targetEl = e.target;
|
6670 |
|
6671 | if (swiper.params.pagination.el && swiper.params.pagination.hideOnClick && swiper.pagination.$el.length > 0 && !$(targetEl).hasClass(swiper.params.pagination.bulletClass)) {
|
6672 | if (swiper.navigation && (swiper.navigation.nextEl && targetEl === swiper.navigation.nextEl || swiper.navigation.prevEl && targetEl === swiper.navigation.prevEl)) return;
|
6673 | var isHidden = swiper.pagination.$el.hasClass(swiper.params.pagination.hiddenClass);
|
6674 |
|
6675 | if (isHidden === true) {
|
6676 | swiper.emit('paginationShow');
|
6677 | } else {
|
6678 | swiper.emit('paginationHide');
|
6679 | }
|
6680 |
|
6681 | swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass);
|
6682 | }
|
6683 | }
|
6684 | }
|
6685 | };
|
6686 |
|
6687 | var Scrollbar = {
|
6688 | setTranslate: function setTranslate() {
|
6689 | var swiper = this;
|
6690 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
6691 | var scrollbar = swiper.scrollbar,
|
6692 | rtl = swiper.rtlTranslate,
|
6693 | progress = swiper.progress;
|
6694 | var dragSize = scrollbar.dragSize,
|
6695 | trackSize = scrollbar.trackSize,
|
6696 | $dragEl = scrollbar.$dragEl,
|
6697 | $el = scrollbar.$el;
|
6698 | var params = swiper.params.scrollbar;
|
6699 | var newSize = dragSize;
|
6700 | var newPos = (trackSize - dragSize) * progress;
|
6701 |
|
6702 | if (rtl) {
|
6703 | newPos = -newPos;
|
6704 |
|
6705 | if (newPos > 0) {
|
6706 | newSize = dragSize - newPos;
|
6707 | newPos = 0;
|
6708 | } else if (-newPos + dragSize > trackSize) {
|
6709 | newSize = trackSize + newPos;
|
6710 | }
|
6711 | } else if (newPos < 0) {
|
6712 | newSize = dragSize + newPos;
|
6713 | newPos = 0;
|
6714 | } else if (newPos + dragSize > trackSize) {
|
6715 | newSize = trackSize - newPos;
|
6716 | }
|
6717 |
|
6718 | if (swiper.isHorizontal()) {
|
6719 | $dragEl.transform("translate3d(" + newPos + "px, 0, 0)");
|
6720 | $dragEl[0].style.width = newSize + "px";
|
6721 | } else {
|
6722 | $dragEl.transform("translate3d(0px, " + newPos + "px, 0)");
|
6723 | $dragEl[0].style.height = newSize + "px";
|
6724 | }
|
6725 |
|
6726 | if (params.hide) {
|
6727 | clearTimeout(swiper.scrollbar.timeout);
|
6728 | $el[0].style.opacity = 1;
|
6729 | swiper.scrollbar.timeout = setTimeout(function () {
|
6730 | $el[0].style.opacity = 0;
|
6731 | $el.transition(400);
|
6732 | }, 1000);
|
6733 | }
|
6734 | },
|
6735 | setTransition: function setTransition(duration) {
|
6736 | var swiper = this;
|
6737 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
6738 | swiper.scrollbar.$dragEl.transition(duration);
|
6739 | },
|
6740 | updateSize: function updateSize() {
|
6741 | var swiper = this;
|
6742 | if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) return;
|
6743 | var scrollbar = swiper.scrollbar;
|
6744 | var $dragEl = scrollbar.$dragEl,
|
6745 | $el = scrollbar.$el;
|
6746 | $dragEl[0].style.width = '';
|
6747 | $dragEl[0].style.height = '';
|
6748 | var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight;
|
6749 | var divider = swiper.size / swiper.virtualSize;
|
6750 | var moveDivider = divider * (trackSize / swiper.size);
|
6751 | var dragSize;
|
6752 |
|
6753 | if (swiper.params.scrollbar.dragSize === 'auto') {
|
6754 | dragSize = trackSize * divider;
|
6755 | } else {
|
6756 | dragSize = parseInt(swiper.params.scrollbar.dragSize, 10);
|
6757 | }
|
6758 |
|
6759 | if (swiper.isHorizontal()) {
|
6760 | $dragEl[0].style.width = dragSize + "px";
|
6761 | } else {
|
6762 | $dragEl[0].style.height = dragSize + "px";
|
6763 | }
|
6764 |
|
6765 | if (divider >= 1) {
|
6766 | $el[0].style.display = 'none';
|
6767 | } else {
|
6768 | $el[0].style.display = '';
|
6769 | }
|
6770 |
|
6771 | if (swiper.params.scrollbar.hide) {
|
6772 | $el[0].style.opacity = 0;
|
6773 | }
|
6774 |
|
6775 | extend(scrollbar, {
|
6776 | trackSize: trackSize,
|
6777 | divider: divider,
|
6778 | moveDivider: moveDivider,
|
6779 | dragSize: dragSize
|
6780 | });
|
6781 | scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass);
|
6782 | },
|
6783 | getPointerPosition: function getPointerPosition(e) {
|
6784 | var swiper = this;
|
6785 |
|
6786 | if (swiper.isHorizontal()) {
|
6787 | return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientX : e.clientX;
|
6788 | }
|
6789 |
|
6790 | return e.type === 'touchstart' || e.type === 'touchmove' ? e.targetTouches[0].clientY : e.clientY;
|
6791 | },
|
6792 | setDragPosition: function setDragPosition(e) {
|
6793 | var swiper = this;
|
6794 | var scrollbar = swiper.scrollbar,
|
6795 | rtl = swiper.rtlTranslate;
|
6796 | var $el = scrollbar.$el,
|
6797 | dragSize = scrollbar.dragSize,
|
6798 | trackSize = scrollbar.trackSize,
|
6799 | dragStartPos = scrollbar.dragStartPos;
|
6800 | var positionRatio;
|
6801 | positionRatio = (scrollbar.getPointerPosition(e) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragStartPos !== null ? dragStartPos : dragSize / 2)) / (trackSize - dragSize);
|
6802 | positionRatio = Math.max(Math.min(positionRatio, 1), 0);
|
6803 |
|
6804 | if (rtl) {
|
6805 | positionRatio = 1 - positionRatio;
|
6806 | }
|
6807 |
|
6808 | var position = swiper.minTranslate() + (swiper.maxTranslate() - swiper.minTranslate()) * positionRatio;
|
6809 | swiper.updateProgress(position);
|
6810 | swiper.setTranslate(position);
|
6811 | swiper.updateActiveIndex();
|
6812 | swiper.updateSlidesClasses();
|
6813 | },
|
6814 | onDragStart: function onDragStart(e) {
|
6815 | var swiper = this;
|
6816 | var params = swiper.params.scrollbar;
|
6817 | var scrollbar = swiper.scrollbar,
|
6818 | $wrapperEl = swiper.$wrapperEl;
|
6819 | var $el = scrollbar.$el,
|
6820 | $dragEl = scrollbar.$dragEl;
|
6821 | swiper.scrollbar.isTouched = true;
|
6822 | swiper.scrollbar.dragStartPos = e.target === $dragEl[0] || e.target === $dragEl ? scrollbar.getPointerPosition(e) - e.target.getBoundingClientRect()[swiper.isHorizontal() ? 'left' : 'top'] : null;
|
6823 | e.preventDefault();
|
6824 | e.stopPropagation();
|
6825 | $wrapperEl.transition(100);
|
6826 | $dragEl.transition(100);
|
6827 | scrollbar.setDragPosition(e);
|
6828 | clearTimeout(swiper.scrollbar.dragTimeout);
|
6829 | $el.transition(0);
|
6830 |
|
6831 | if (params.hide) {
|
6832 | $el.css('opacity', 1);
|
6833 | }
|
6834 |
|
6835 | if (swiper.params.cssMode) {
|
6836 | swiper.$wrapperEl.css('scroll-snap-type', 'none');
|
6837 | }
|
6838 |
|
6839 | swiper.emit('scrollbarDragStart', e);
|
6840 | },
|
6841 | onDragMove: function onDragMove(e) {
|
6842 | var swiper = this;
|
6843 | var scrollbar = swiper.scrollbar,
|
6844 | $wrapperEl = swiper.$wrapperEl;
|
6845 | var $el = scrollbar.$el,
|
6846 | $dragEl = scrollbar.$dragEl;
|
6847 | if (!swiper.scrollbar.isTouched) return;
|
6848 | if (e.preventDefault) e.preventDefault();else e.returnValue = false;
|
6849 | scrollbar.setDragPosition(e);
|
6850 | $wrapperEl.transition(0);
|
6851 | $el.transition(0);
|
6852 | $dragEl.transition(0);
|
6853 | swiper.emit('scrollbarDragMove', e);
|
6854 | },
|
6855 | onDragEnd: function onDragEnd(e) {
|
6856 | var swiper = this;
|
6857 | var params = swiper.params.scrollbar;
|
6858 | var scrollbar = swiper.scrollbar,
|
6859 | $wrapperEl = swiper.$wrapperEl;
|
6860 | var $el = scrollbar.$el;
|
6861 | if (!swiper.scrollbar.isTouched) return;
|
6862 | swiper.scrollbar.isTouched = false;
|
6863 |
|
6864 | if (swiper.params.cssMode) {
|
6865 | swiper.$wrapperEl.css('scroll-snap-type', '');
|
6866 | $wrapperEl.transition('');
|
6867 | }
|
6868 |
|
6869 | if (params.hide) {
|
6870 | clearTimeout(swiper.scrollbar.dragTimeout);
|
6871 | swiper.scrollbar.dragTimeout = nextTick(function () {
|
6872 | $el.css('opacity', 0);
|
6873 | $el.transition(400);
|
6874 | }, 1000);
|
6875 | }
|
6876 |
|
6877 | swiper.emit('scrollbarDragEnd', e);
|
6878 |
|
6879 | if (params.snapOnRelease) {
|
6880 | swiper.slideToClosest();
|
6881 | }
|
6882 | },
|
6883 | enableDraggable: function enableDraggable() {
|
6884 | var swiper = this;
|
6885 | if (!swiper.params.scrollbar.el) return;
|
6886 | var document = getDocument();
|
6887 | var scrollbar = swiper.scrollbar,
|
6888 | touchEventsTouch = swiper.touchEventsTouch,
|
6889 | touchEventsDesktop = swiper.touchEventsDesktop,
|
6890 | params = swiper.params,
|
6891 | support = swiper.support;
|
6892 | var $el = scrollbar.$el;
|
6893 | var target = $el[0];
|
6894 | var activeListener = support.passiveListener && params.passiveListeners ? {
|
6895 | passive: false,
|
6896 | capture: false
|
6897 | } : false;
|
6898 | var passiveListener = support.passiveListener && params.passiveListeners ? {
|
6899 | passive: true,
|
6900 | capture: false
|
6901 | } : false;
|
6902 | if (!target) return;
|
6903 |
|
6904 | if (!support.touch) {
|
6905 | target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
|
6906 | document.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
|
6907 | document.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
|
6908 | } else {
|
6909 | target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
|
6910 | target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
|
6911 | target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
|
6912 | }
|
6913 | },
|
6914 | disableDraggable: function disableDraggable() {
|
6915 | var swiper = this;
|
6916 | if (!swiper.params.scrollbar.el) return;
|
6917 | var document = getDocument();
|
6918 | var scrollbar = swiper.scrollbar,
|
6919 | touchEventsTouch = swiper.touchEventsTouch,
|
6920 | touchEventsDesktop = swiper.touchEventsDesktop,
|
6921 | params = swiper.params,
|
6922 | support = swiper.support;
|
6923 | var $el = scrollbar.$el;
|
6924 | var target = $el[0];
|
6925 | var activeListener = support.passiveListener && params.passiveListeners ? {
|
6926 | passive: false,
|
6927 | capture: false
|
6928 | } : false;
|
6929 | var passiveListener = support.passiveListener && params.passiveListeners ? {
|
6930 | passive: true,
|
6931 | capture: false
|
6932 | } : false;
|
6933 | if (!target) return;
|
6934 |
|
6935 | if (!support.touch) {
|
6936 | target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener);
|
6937 | document.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener);
|
6938 | document.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener);
|
6939 | } else {
|
6940 | target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener);
|
6941 | target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener);
|
6942 | target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener);
|
6943 | }
|
6944 | },
|
6945 | init: function init() {
|
6946 | var swiper = this;
|
6947 | if (!swiper.params.scrollbar.el) return;
|
6948 | var scrollbar = swiper.scrollbar,
|
6949 | $swiperEl = swiper.$el;
|
6950 | var params = swiper.params.scrollbar;
|
6951 | var $el = $(params.el);
|
6952 |
|
6953 | if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) {
|
6954 | $el = $swiperEl.find(params.el);
|
6955 | }
|
6956 |
|
6957 | var $dragEl = $el.find("." + swiper.params.scrollbar.dragClass);
|
6958 |
|
6959 | if ($dragEl.length === 0) {
|
6960 | $dragEl = $("<div class=\"" + swiper.params.scrollbar.dragClass + "\"></div>");
|
6961 | $el.append($dragEl);
|
6962 | }
|
6963 |
|
6964 | extend(scrollbar, {
|
6965 | $el: $el,
|
6966 | el: $el[0],
|
6967 | $dragEl: $dragEl,
|
6968 | dragEl: $dragEl[0]
|
6969 | });
|
6970 |
|
6971 | if (params.draggable) {
|
6972 | scrollbar.enableDraggable();
|
6973 | }
|
6974 | },
|
6975 | destroy: function destroy() {
|
6976 | var swiper = this;
|
6977 | swiper.scrollbar.disableDraggable();
|
6978 | }
|
6979 | };
|
6980 | var Scrollbar$1 = {
|
6981 | name: 'scrollbar',
|
6982 | params: {
|
6983 | scrollbar: {
|
6984 | el: null,
|
6985 | dragSize: 'auto',
|
6986 | hide: false,
|
6987 | draggable: false,
|
6988 | snapOnRelease: true,
|
6989 | lockClass: 'swiper-scrollbar-lock',
|
6990 | dragClass: 'swiper-scrollbar-drag'
|
6991 | }
|
6992 | },
|
6993 | create: function create() {
|
6994 | var swiper = this;
|
6995 | bindModuleMethods(swiper, {
|
6996 | scrollbar: _extends({
|
6997 | isTouched: false,
|
6998 | timeout: null,
|
6999 | dragTimeout: null
|
7000 | }, Scrollbar)
|
7001 | });
|
7002 | },
|
7003 | on: {
|
7004 | init: function init(swiper) {
|
7005 | swiper.scrollbar.init();
|
7006 | swiper.scrollbar.updateSize();
|
7007 | swiper.scrollbar.setTranslate();
|
7008 | },
|
7009 | update: function update(swiper) {
|
7010 | swiper.scrollbar.updateSize();
|
7011 | },
|
7012 | resize: function resize(swiper) {
|
7013 | swiper.scrollbar.updateSize();
|
7014 | },
|
7015 | observerUpdate: function observerUpdate(swiper) {
|
7016 | swiper.scrollbar.updateSize();
|
7017 | },
|
7018 | setTranslate: function setTranslate(swiper) {
|
7019 | swiper.scrollbar.setTranslate();
|
7020 | },
|
7021 | setTransition: function setTransition(swiper, duration) {
|
7022 | swiper.scrollbar.setTransition(duration);
|
7023 | },
|
7024 | destroy: function destroy(swiper) {
|
7025 | swiper.scrollbar.destroy();
|
7026 | }
|
7027 | }
|
7028 | };
|
7029 |
|
7030 | var Parallax = {
|
7031 | setTransform: function setTransform(el, progress) {
|
7032 | var swiper = this;
|
7033 | var rtl = swiper.rtl;
|
7034 | var $el = $(el);
|
7035 | var rtlFactor = rtl ? -1 : 1;
|
7036 | var p = $el.attr('data-swiper-parallax') || '0';
|
7037 | var x = $el.attr('data-swiper-parallax-x');
|
7038 | var y = $el.attr('data-swiper-parallax-y');
|
7039 | var scale = $el.attr('data-swiper-parallax-scale');
|
7040 | var opacity = $el.attr('data-swiper-parallax-opacity');
|
7041 |
|
7042 | if (x || y) {
|
7043 | x = x || '0';
|
7044 | y = y || '0';
|
7045 | } else if (swiper.isHorizontal()) {
|
7046 | x = p;
|
7047 | y = '0';
|
7048 | } else {
|
7049 | y = p;
|
7050 | x = '0';
|
7051 | }
|
7052 |
|
7053 | if (x.indexOf('%') >= 0) {
|
7054 | x = parseInt(x, 10) * progress * rtlFactor + "%";
|
7055 | } else {
|
7056 | x = x * progress * rtlFactor + "px";
|
7057 | }
|
7058 |
|
7059 | if (y.indexOf('%') >= 0) {
|
7060 | y = parseInt(y, 10) * progress + "%";
|
7061 | } else {
|
7062 | y = y * progress + "px";
|
7063 | }
|
7064 |
|
7065 | if (typeof opacity !== 'undefined' && opacity !== null) {
|
7066 | var currentOpacity = opacity - (opacity - 1) * (1 - Math.abs(progress));
|
7067 | $el[0].style.opacity = currentOpacity;
|
7068 | }
|
7069 |
|
7070 | if (typeof scale === 'undefined' || scale === null) {
|
7071 | $el.transform("translate3d(" + x + ", " + y + ", 0px)");
|
7072 | } else {
|
7073 | var currentScale = scale - (scale - 1) * (1 - Math.abs(progress));
|
7074 | $el.transform("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")");
|
7075 | }
|
7076 | },
|
7077 | setTranslate: function setTranslate() {
|
7078 | var swiper = this;
|
7079 | var $el = swiper.$el,
|
7080 | slides = swiper.slides,
|
7081 | progress = swiper.progress,
|
7082 | snapGrid = swiper.snapGrid;
|
7083 | $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (el) {
|
7084 | swiper.parallax.setTransform(el, progress);
|
7085 | });
|
7086 | slides.each(function (slideEl, slideIndex) {
|
7087 | var slideProgress = slideEl.progress;
|
7088 |
|
7089 | if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') {
|
7090 | slideProgress += Math.ceil(slideIndex / 2) - progress * (snapGrid.length - 1);
|
7091 | }
|
7092 |
|
7093 | slideProgress = Math.min(Math.max(slideProgress, -1), 1);
|
7094 | $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (el) {
|
7095 | swiper.parallax.setTransform(el, slideProgress);
|
7096 | });
|
7097 | });
|
7098 | },
|
7099 | setTransition: function setTransition(duration) {
|
7100 | if (duration === void 0) {
|
7101 | duration = this.params.speed;
|
7102 | }
|
7103 |
|
7104 | var swiper = this;
|
7105 | var $el = swiper.$el;
|
7106 | $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y], [data-swiper-parallax-opacity], [data-swiper-parallax-scale]').each(function (parallaxEl) {
|
7107 | var $parallaxEl = $(parallaxEl);
|
7108 | var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration;
|
7109 | if (duration === 0) parallaxDuration = 0;
|
7110 | $parallaxEl.transition(parallaxDuration);
|
7111 | });
|
7112 | }
|
7113 | };
|
7114 | var Parallax$1 = {
|
7115 | name: 'parallax',
|
7116 | params: {
|
7117 | parallax: {
|
7118 | enabled: false
|
7119 | }
|
7120 | },
|
7121 | create: function create() {
|
7122 | var swiper = this;
|
7123 | bindModuleMethods(swiper, {
|
7124 | parallax: _extends({}, Parallax)
|
7125 | });
|
7126 | },
|
7127 | on: {
|
7128 | beforeInit: function beforeInit(swiper) {
|
7129 | if (!swiper.params.parallax.enabled) return;
|
7130 | swiper.params.watchSlidesProgress = true;
|
7131 | swiper.originalParams.watchSlidesProgress = true;
|
7132 | },
|
7133 | init: function init(swiper) {
|
7134 | if (!swiper.params.parallax.enabled) return;
|
7135 | swiper.parallax.setTranslate();
|
7136 | },
|
7137 | setTranslate: function setTranslate(swiper) {
|
7138 | if (!swiper.params.parallax.enabled) return;
|
7139 | swiper.parallax.setTranslate();
|
7140 | },
|
7141 | setTransition: function setTransition(swiper, duration) {
|
7142 | if (!swiper.params.parallax.enabled) return;
|
7143 | swiper.parallax.setTransition(duration);
|
7144 | }
|
7145 | }
|
7146 | };
|
7147 |
|
7148 | var Zoom = {
|
7149 |
|
7150 | getDistanceBetweenTouches: function getDistanceBetweenTouches(e) {
|
7151 | if (e.targetTouches.length < 2) return 1;
|
7152 | var x1 = e.targetTouches[0].pageX;
|
7153 | var y1 = e.targetTouches[0].pageY;
|
7154 | var x2 = e.targetTouches[1].pageX;
|
7155 | var y2 = e.targetTouches[1].pageY;
|
7156 | var distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
|
7157 | return distance;
|
7158 | },
|
7159 |
|
7160 | onGestureStart: function onGestureStart(e) {
|
7161 | var swiper = this;
|
7162 | var support = swiper.support;
|
7163 | var params = swiper.params.zoom;
|
7164 | var zoom = swiper.zoom;
|
7165 | var gesture = zoom.gesture;
|
7166 | zoom.fakeGestureTouched = false;
|
7167 | zoom.fakeGestureMoved = false;
|
7168 |
|
7169 | if (!support.gestures) {
|
7170 | if (e.type !== 'touchstart' || e.type === 'touchstart' && e.targetTouches.length < 2) {
|
7171 | return;
|
7172 | }
|
7173 |
|
7174 | zoom.fakeGestureTouched = true;
|
7175 | gesture.scaleStart = Zoom.getDistanceBetweenTouches(e);
|
7176 | }
|
7177 |
|
7178 | if (!gesture.$slideEl || !gesture.$slideEl.length) {
|
7179 | gesture.$slideEl = $(e.target).closest("." + swiper.params.slideClass);
|
7180 | if (gesture.$slideEl.length === 0) gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
|
7181 | gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target');
|
7182 | gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass);
|
7183 | gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
|
7184 |
|
7185 | if (gesture.$imageWrapEl.length === 0) {
|
7186 | gesture.$imageEl = undefined;
|
7187 | return;
|
7188 | }
|
7189 | }
|
7190 |
|
7191 | if (gesture.$imageEl) {
|
7192 | gesture.$imageEl.transition(0);
|
7193 | }
|
7194 |
|
7195 | swiper.zoom.isScaling = true;
|
7196 | },
|
7197 | onGestureChange: function onGestureChange(e) {
|
7198 | var swiper = this;
|
7199 | var support = swiper.support;
|
7200 | var params = swiper.params.zoom;
|
7201 | var zoom = swiper.zoom;
|
7202 | var gesture = zoom.gesture;
|
7203 |
|
7204 | if (!support.gestures) {
|
7205 | if (e.type !== 'touchmove' || e.type === 'touchmove' && e.targetTouches.length < 2) {
|
7206 | return;
|
7207 | }
|
7208 |
|
7209 | zoom.fakeGestureMoved = true;
|
7210 | gesture.scaleMove = Zoom.getDistanceBetweenTouches(e);
|
7211 | }
|
7212 |
|
7213 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) {
|
7214 | if (e.type === 'gesturechange') zoom.onGestureStart(e);
|
7215 | return;
|
7216 | }
|
7217 |
|
7218 | if (support.gestures) {
|
7219 | zoom.scale = e.scale * zoom.currentScale;
|
7220 | } else {
|
7221 | zoom.scale = gesture.scaleMove / gesture.scaleStart * zoom.currentScale;
|
7222 | }
|
7223 |
|
7224 | if (zoom.scale > gesture.maxRatio) {
|
7225 | zoom.scale = gesture.maxRatio - 1 + Math.pow(zoom.scale - gesture.maxRatio + 1, 0.5);
|
7226 | }
|
7227 |
|
7228 | if (zoom.scale < params.minRatio) {
|
7229 | zoom.scale = params.minRatio + 1 - Math.pow(params.minRatio - zoom.scale + 1, 0.5);
|
7230 | }
|
7231 |
|
7232 | gesture.$imageEl.transform("translate3d(0,0,0) scale(" + zoom.scale + ")");
|
7233 | },
|
7234 | onGestureEnd: function onGestureEnd(e) {
|
7235 | var swiper = this;
|
7236 | var device = swiper.device;
|
7237 | var support = swiper.support;
|
7238 | var params = swiper.params.zoom;
|
7239 | var zoom = swiper.zoom;
|
7240 | var gesture = zoom.gesture;
|
7241 |
|
7242 | if (!support.gestures) {
|
7243 | if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) {
|
7244 | return;
|
7245 | }
|
7246 |
|
7247 | if (e.type !== 'touchend' || e.type === 'touchend' && e.changedTouches.length < 2 && !device.android) {
|
7248 | return;
|
7249 | }
|
7250 |
|
7251 | zoom.fakeGestureTouched = false;
|
7252 | zoom.fakeGestureMoved = false;
|
7253 | }
|
7254 |
|
7255 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
7256 | zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio);
|
7257 | gesture.$imageEl.transition(swiper.params.speed).transform("translate3d(0,0,0) scale(" + zoom.scale + ")");
|
7258 | zoom.currentScale = zoom.scale;
|
7259 | zoom.isScaling = false;
|
7260 | if (zoom.scale === 1) gesture.$slideEl = undefined;
|
7261 | },
|
7262 | onTouchStart: function onTouchStart(e) {
|
7263 | var swiper = this;
|
7264 | var device = swiper.device;
|
7265 | var zoom = swiper.zoom;
|
7266 | var gesture = zoom.gesture,
|
7267 | image = zoom.image;
|
7268 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
7269 | if (image.isTouched) return;
|
7270 | if (device.android && e.cancelable) e.preventDefault();
|
7271 | image.isTouched = true;
|
7272 | image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX;
|
7273 | image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY;
|
7274 | },
|
7275 | onTouchMove: function onTouchMove(e) {
|
7276 | var swiper = this;
|
7277 | var zoom = swiper.zoom;
|
7278 | var gesture = zoom.gesture,
|
7279 | image = zoom.image,
|
7280 | velocity = zoom.velocity;
|
7281 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
7282 | swiper.allowClick = false;
|
7283 | if (!image.isTouched || !gesture.$slideEl) return;
|
7284 |
|
7285 | if (!image.isMoved) {
|
7286 | image.width = gesture.$imageEl[0].offsetWidth;
|
7287 | image.height = gesture.$imageEl[0].offsetHeight;
|
7288 | image.startX = getTranslate(gesture.$imageWrapEl[0], 'x') || 0;
|
7289 | image.startY = getTranslate(gesture.$imageWrapEl[0], 'y') || 0;
|
7290 | gesture.slideWidth = gesture.$slideEl[0].offsetWidth;
|
7291 | gesture.slideHeight = gesture.$slideEl[0].offsetHeight;
|
7292 | gesture.$imageWrapEl.transition(0);
|
7293 |
|
7294 | if (swiper.rtl) {
|
7295 | image.startX = -image.startX;
|
7296 | image.startY = -image.startY;
|
7297 | }
|
7298 | }
|
7299 |
|
7300 |
|
7301 | var scaledWidth = image.width * zoom.scale;
|
7302 | var scaledHeight = image.height * zoom.scale;
|
7303 | if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) return;
|
7304 | image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
|
7305 | image.maxX = -image.minX;
|
7306 | image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
|
7307 | image.maxY = -image.minY;
|
7308 | image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX;
|
7309 | image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY;
|
7310 |
|
7311 | if (!image.isMoved && !zoom.isScaling) {
|
7312 | if (swiper.isHorizontal() && (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x || Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x)) {
|
7313 | image.isTouched = false;
|
7314 | return;
|
7315 | }
|
7316 |
|
7317 | if (!swiper.isHorizontal() && (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y || Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y)) {
|
7318 | image.isTouched = false;
|
7319 | return;
|
7320 | }
|
7321 | }
|
7322 |
|
7323 | if (e.cancelable) {
|
7324 | e.preventDefault();
|
7325 | }
|
7326 |
|
7327 | e.stopPropagation();
|
7328 | image.isMoved = true;
|
7329 | image.currentX = image.touchesCurrent.x - image.touchesStart.x + image.startX;
|
7330 | image.currentY = image.touchesCurrent.y - image.touchesStart.y + image.startY;
|
7331 |
|
7332 | if (image.currentX < image.minX) {
|
7333 | image.currentX = image.minX + 1 - Math.pow(image.minX - image.currentX + 1, 0.8);
|
7334 | }
|
7335 |
|
7336 | if (image.currentX > image.maxX) {
|
7337 | image.currentX = image.maxX - 1 + Math.pow(image.currentX - image.maxX + 1, 0.8);
|
7338 | }
|
7339 |
|
7340 | if (image.currentY < image.minY) {
|
7341 | image.currentY = image.minY + 1 - Math.pow(image.minY - image.currentY + 1, 0.8);
|
7342 | }
|
7343 |
|
7344 | if (image.currentY > image.maxY) {
|
7345 | image.currentY = image.maxY - 1 + Math.pow(image.currentY - image.maxY + 1, 0.8);
|
7346 | }
|
7347 |
|
7348 |
|
7349 | if (!velocity.prevPositionX) velocity.prevPositionX = image.touchesCurrent.x;
|
7350 | if (!velocity.prevPositionY) velocity.prevPositionY = image.touchesCurrent.y;
|
7351 | if (!velocity.prevTime) velocity.prevTime = Date.now();
|
7352 | velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2;
|
7353 | velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2;
|
7354 | if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) velocity.x = 0;
|
7355 | if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) velocity.y = 0;
|
7356 | velocity.prevPositionX = image.touchesCurrent.x;
|
7357 | velocity.prevPositionY = image.touchesCurrent.y;
|
7358 | velocity.prevTime = Date.now();
|
7359 | gesture.$imageWrapEl.transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)");
|
7360 | },
|
7361 | onTouchEnd: function onTouchEnd() {
|
7362 | var swiper = this;
|
7363 | var zoom = swiper.zoom;
|
7364 | var gesture = zoom.gesture,
|
7365 | image = zoom.image,
|
7366 | velocity = zoom.velocity;
|
7367 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
7368 |
|
7369 | if (!image.isTouched || !image.isMoved) {
|
7370 | image.isTouched = false;
|
7371 | image.isMoved = false;
|
7372 | return;
|
7373 | }
|
7374 |
|
7375 | image.isTouched = false;
|
7376 | image.isMoved = false;
|
7377 | var momentumDurationX = 300;
|
7378 | var momentumDurationY = 300;
|
7379 | var momentumDistanceX = velocity.x * momentumDurationX;
|
7380 | var newPositionX = image.currentX + momentumDistanceX;
|
7381 | var momentumDistanceY = velocity.y * momentumDurationY;
|
7382 | var newPositionY = image.currentY + momentumDistanceY;
|
7383 |
|
7384 | if (velocity.x !== 0) momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x);
|
7385 | if (velocity.y !== 0) momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y);
|
7386 | var momentumDuration = Math.max(momentumDurationX, momentumDurationY);
|
7387 | image.currentX = newPositionX;
|
7388 | image.currentY = newPositionY;
|
7389 |
|
7390 | var scaledWidth = image.width * zoom.scale;
|
7391 | var scaledHeight = image.height * zoom.scale;
|
7392 | image.minX = Math.min(gesture.slideWidth / 2 - scaledWidth / 2, 0);
|
7393 | image.maxX = -image.minX;
|
7394 | image.minY = Math.min(gesture.slideHeight / 2 - scaledHeight / 2, 0);
|
7395 | image.maxY = -image.minY;
|
7396 | image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX);
|
7397 | image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY);
|
7398 | gesture.$imageWrapEl.transition(momentumDuration).transform("translate3d(" + image.currentX + "px, " + image.currentY + "px,0)");
|
7399 | },
|
7400 | onTransitionEnd: function onTransitionEnd() {
|
7401 | var swiper = this;
|
7402 | var zoom = swiper.zoom;
|
7403 | var gesture = zoom.gesture;
|
7404 |
|
7405 | if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) {
|
7406 | if (gesture.$imageEl) {
|
7407 | gesture.$imageEl.transform('translate3d(0,0,0) scale(1)');
|
7408 | }
|
7409 |
|
7410 | if (gesture.$imageWrapEl) {
|
7411 | gesture.$imageWrapEl.transform('translate3d(0,0,0)');
|
7412 | }
|
7413 |
|
7414 | zoom.scale = 1;
|
7415 | zoom.currentScale = 1;
|
7416 | gesture.$slideEl = undefined;
|
7417 | gesture.$imageEl = undefined;
|
7418 | gesture.$imageWrapEl = undefined;
|
7419 | }
|
7420 | },
|
7421 |
|
7422 | toggle: function toggle(e) {
|
7423 | var swiper = this;
|
7424 | var zoom = swiper.zoom;
|
7425 |
|
7426 | if (zoom.scale && zoom.scale !== 1) {
|
7427 |
|
7428 | zoom.out();
|
7429 | } else {
|
7430 |
|
7431 | zoom.in(e);
|
7432 | }
|
7433 | },
|
7434 | in: function _in(e) {
|
7435 | var swiper = this;
|
7436 | var window = getWindow();
|
7437 | var zoom = swiper.zoom;
|
7438 | var params = swiper.params.zoom;
|
7439 | var gesture = zoom.gesture,
|
7440 | image = zoom.image;
|
7441 |
|
7442 | if (!gesture.$slideEl) {
|
7443 | if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
|
7444 | gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass);
|
7445 | } else {
|
7446 | gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
|
7447 | }
|
7448 |
|
7449 | gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target');
|
7450 | gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass);
|
7451 | }
|
7452 |
|
7453 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
7454 | gesture.$slideEl.addClass("" + params.zoomedSlideClass);
|
7455 | var touchX;
|
7456 | var touchY;
|
7457 | var offsetX;
|
7458 | var offsetY;
|
7459 | var diffX;
|
7460 | var diffY;
|
7461 | var translateX;
|
7462 | var translateY;
|
7463 | var imageWidth;
|
7464 | var imageHeight;
|
7465 | var scaledWidth;
|
7466 | var scaledHeight;
|
7467 | var translateMinX;
|
7468 | var translateMinY;
|
7469 | var translateMaxX;
|
7470 | var translateMaxY;
|
7471 | var slideWidth;
|
7472 | var slideHeight;
|
7473 |
|
7474 | if (typeof image.touchesStart.x === 'undefined' && e) {
|
7475 | touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX;
|
7476 | touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY;
|
7477 | } else {
|
7478 | touchX = image.touchesStart.x;
|
7479 | touchY = image.touchesStart.y;
|
7480 | }
|
7481 |
|
7482 | zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
|
7483 | zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio;
|
7484 |
|
7485 | if (e) {
|
7486 | slideWidth = gesture.$slideEl[0].offsetWidth;
|
7487 | slideHeight = gesture.$slideEl[0].offsetHeight;
|
7488 | offsetX = gesture.$slideEl.offset().left + window.scrollX;
|
7489 | offsetY = gesture.$slideEl.offset().top + window.scrollY;
|
7490 | diffX = offsetX + slideWidth / 2 - touchX;
|
7491 | diffY = offsetY + slideHeight / 2 - touchY;
|
7492 | imageWidth = gesture.$imageEl[0].offsetWidth;
|
7493 | imageHeight = gesture.$imageEl[0].offsetHeight;
|
7494 | scaledWidth = imageWidth * zoom.scale;
|
7495 | scaledHeight = imageHeight * zoom.scale;
|
7496 | translateMinX = Math.min(slideWidth / 2 - scaledWidth / 2, 0);
|
7497 | translateMinY = Math.min(slideHeight / 2 - scaledHeight / 2, 0);
|
7498 | translateMaxX = -translateMinX;
|
7499 | translateMaxY = -translateMinY;
|
7500 | translateX = diffX * zoom.scale;
|
7501 | translateY = diffY * zoom.scale;
|
7502 |
|
7503 | if (translateX < translateMinX) {
|
7504 | translateX = translateMinX;
|
7505 | }
|
7506 |
|
7507 | if (translateX > translateMaxX) {
|
7508 | translateX = translateMaxX;
|
7509 | }
|
7510 |
|
7511 | if (translateY < translateMinY) {
|
7512 | translateY = translateMinY;
|
7513 | }
|
7514 |
|
7515 | if (translateY > translateMaxY) {
|
7516 | translateY = translateMaxY;
|
7517 | }
|
7518 | } else {
|
7519 | translateX = 0;
|
7520 | translateY = 0;
|
7521 | }
|
7522 |
|
7523 | gesture.$imageWrapEl.transition(300).transform("translate3d(" + translateX + "px, " + translateY + "px,0)");
|
7524 | gesture.$imageEl.transition(300).transform("translate3d(0,0,0) scale(" + zoom.scale + ")");
|
7525 | },
|
7526 | out: function out() {
|
7527 | var swiper = this;
|
7528 | var zoom = swiper.zoom;
|
7529 | var params = swiper.params.zoom;
|
7530 | var gesture = zoom.gesture;
|
7531 |
|
7532 | if (!gesture.$slideEl) {
|
7533 | if (swiper.params.virtual && swiper.params.virtual.enabled && swiper.virtual) {
|
7534 | gesture.$slideEl = swiper.$wrapperEl.children("." + swiper.params.slideActiveClass);
|
7535 | } else {
|
7536 | gesture.$slideEl = swiper.slides.eq(swiper.activeIndex);
|
7537 | }
|
7538 |
|
7539 | gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas, picture, .swiper-zoom-target');
|
7540 | gesture.$imageWrapEl = gesture.$imageEl.parent("." + params.containerClass);
|
7541 | }
|
7542 |
|
7543 | if (!gesture.$imageEl || gesture.$imageEl.length === 0) return;
|
7544 | zoom.scale = 1;
|
7545 | zoom.currentScale = 1;
|
7546 | gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)');
|
7547 | gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)');
|
7548 | gesture.$slideEl.removeClass("" + params.zoomedSlideClass);
|
7549 | gesture.$slideEl = undefined;
|
7550 | },
|
7551 | toggleGestures: function toggleGestures(method) {
|
7552 | var swiper = this;
|
7553 | var zoom = swiper.zoom;
|
7554 | var selector = zoom.slideSelector,
|
7555 | passive = zoom.passiveListener;
|
7556 | swiper.$wrapperEl[method]('gesturestart', selector, zoom.onGestureStart, passive);
|
7557 | swiper.$wrapperEl[method]('gesturechange', selector, zoom.onGestureChange, passive);
|
7558 | swiper.$wrapperEl[method]('gestureend', selector, zoom.onGestureEnd, passive);
|
7559 | },
|
7560 | enableGestures: function enableGestures() {
|
7561 | if (this.zoom.gesturesEnabled) return;
|
7562 | this.zoom.gesturesEnabled = true;
|
7563 | this.zoom.toggleGestures('on');
|
7564 | },
|
7565 | disableGestures: function disableGestures() {
|
7566 | if (!this.zoom.gesturesEnabled) return;
|
7567 | this.zoom.gesturesEnabled = false;
|
7568 | this.zoom.toggleGestures('off');
|
7569 | },
|
7570 |
|
7571 | enable: function enable() {
|
7572 | var swiper = this;
|
7573 | var support = swiper.support;
|
7574 | var zoom = swiper.zoom;
|
7575 | if (zoom.enabled) return;
|
7576 | zoom.enabled = true;
|
7577 | var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
|
7578 | passive: true,
|
7579 | capture: false
|
7580 | } : false;
|
7581 | var activeListenerWithCapture = support.passiveListener ? {
|
7582 | passive: false,
|
7583 | capture: true
|
7584 | } : true;
|
7585 | var slideSelector = "." + swiper.params.slideClass;
|
7586 | swiper.zoom.passiveListener = passiveListener;
|
7587 | swiper.zoom.slideSelector = slideSelector;
|
7588 |
|
7589 | if (support.gestures) {
|
7590 | swiper.$wrapperEl.on(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener);
|
7591 | swiper.$wrapperEl.on(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener);
|
7592 | } else if (swiper.touchEvents.start === 'touchstart') {
|
7593 | swiper.$wrapperEl.on(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener);
|
7594 | swiper.$wrapperEl.on(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture);
|
7595 | swiper.$wrapperEl.on(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener);
|
7596 |
|
7597 | if (swiper.touchEvents.cancel) {
|
7598 | swiper.$wrapperEl.on(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener);
|
7599 | }
|
7600 | }
|
7601 |
|
7602 |
|
7603 | swiper.$wrapperEl.on(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture);
|
7604 | },
|
7605 | disable: function disable() {
|
7606 | var swiper = this;
|
7607 | var zoom = swiper.zoom;
|
7608 | if (!zoom.enabled) return;
|
7609 | var support = swiper.support;
|
7610 | swiper.zoom.enabled = false;
|
7611 | var passiveListener = swiper.touchEvents.start === 'touchstart' && support.passiveListener && swiper.params.passiveListeners ? {
|
7612 | passive: true,
|
7613 | capture: false
|
7614 | } : false;
|
7615 | var activeListenerWithCapture = support.passiveListener ? {
|
7616 | passive: false,
|
7617 | capture: true
|
7618 | } : true;
|
7619 | var slideSelector = "." + swiper.params.slideClass;
|
7620 |
|
7621 | if (support.gestures) {
|
7622 | swiper.$wrapperEl.off(swiper.touchEvents.start, swiper.zoom.enableGestures, passiveListener);
|
7623 | swiper.$wrapperEl.off(swiper.touchEvents.end, swiper.zoom.disableGestures, passiveListener);
|
7624 | } else if (swiper.touchEvents.start === 'touchstart') {
|
7625 | swiper.$wrapperEl.off(swiper.touchEvents.start, slideSelector, zoom.onGestureStart, passiveListener);
|
7626 | swiper.$wrapperEl.off(swiper.touchEvents.move, slideSelector, zoom.onGestureChange, activeListenerWithCapture);
|
7627 | swiper.$wrapperEl.off(swiper.touchEvents.end, slideSelector, zoom.onGestureEnd, passiveListener);
|
7628 |
|
7629 | if (swiper.touchEvents.cancel) {
|
7630 | swiper.$wrapperEl.off(swiper.touchEvents.cancel, slideSelector, zoom.onGestureEnd, passiveListener);
|
7631 | }
|
7632 | }
|
7633 |
|
7634 |
|
7635 | swiper.$wrapperEl.off(swiper.touchEvents.move, "." + swiper.params.zoom.containerClass, zoom.onTouchMove, activeListenerWithCapture);
|
7636 | }
|
7637 | };
|
7638 | var Zoom$1 = {
|
7639 | name: 'zoom',
|
7640 | params: {
|
7641 | zoom: {
|
7642 | enabled: false,
|
7643 | maxRatio: 3,
|
7644 | minRatio: 1,
|
7645 | toggle: true,
|
7646 | containerClass: 'swiper-zoom-container',
|
7647 | zoomedSlideClass: 'swiper-slide-zoomed'
|
7648 | }
|
7649 | },
|
7650 | create: function create() {
|
7651 | var swiper = this;
|
7652 | bindModuleMethods(swiper, {
|
7653 | zoom: _extends({
|
7654 | enabled: false,
|
7655 | scale: 1,
|
7656 | currentScale: 1,
|
7657 | isScaling: false,
|
7658 | gesture: {
|
7659 | $slideEl: undefined,
|
7660 | slideWidth: undefined,
|
7661 | slideHeight: undefined,
|
7662 | $imageEl: undefined,
|
7663 | $imageWrapEl: undefined,
|
7664 | maxRatio: 3
|
7665 | },
|
7666 | image: {
|
7667 | isTouched: undefined,
|
7668 | isMoved: undefined,
|
7669 | currentX: undefined,
|
7670 | currentY: undefined,
|
7671 | minX: undefined,
|
7672 | minY: undefined,
|
7673 | maxX: undefined,
|
7674 | maxY: undefined,
|
7675 | width: undefined,
|
7676 | height: undefined,
|
7677 | startX: undefined,
|
7678 | startY: undefined,
|
7679 | touchesStart: {},
|
7680 | touchesCurrent: {}
|
7681 | },
|
7682 | velocity: {
|
7683 | x: undefined,
|
7684 | y: undefined,
|
7685 | prevPositionX: undefined,
|
7686 | prevPositionY: undefined,
|
7687 | prevTime: undefined
|
7688 | }
|
7689 | }, Zoom)
|
7690 | });
|
7691 | var scale = 1;
|
7692 | Object.defineProperty(swiper.zoom, 'scale', {
|
7693 | get: function get() {
|
7694 | return scale;
|
7695 | },
|
7696 | set: function set(value) {
|
7697 | if (scale !== value) {
|
7698 | var imageEl = swiper.zoom.gesture.$imageEl ? swiper.zoom.gesture.$imageEl[0] : undefined;
|
7699 | var slideEl = swiper.zoom.gesture.$slideEl ? swiper.zoom.gesture.$slideEl[0] : undefined;
|
7700 | swiper.emit('zoomChange', value, imageEl, slideEl);
|
7701 | }
|
7702 |
|
7703 | scale = value;
|
7704 | }
|
7705 | });
|
7706 | },
|
7707 | on: {
|
7708 | init: function init(swiper) {
|
7709 | if (swiper.params.zoom.enabled) {
|
7710 | swiper.zoom.enable();
|
7711 | }
|
7712 | },
|
7713 | destroy: function destroy(swiper) {
|
7714 | swiper.zoom.disable();
|
7715 | },
|
7716 | touchStart: function touchStart(swiper, e) {
|
7717 | if (!swiper.zoom.enabled) return;
|
7718 | swiper.zoom.onTouchStart(e);
|
7719 | },
|
7720 | touchEnd: function touchEnd(swiper, e) {
|
7721 | if (!swiper.zoom.enabled) return;
|
7722 | swiper.zoom.onTouchEnd(e);
|
7723 | },
|
7724 | doubleTap: function doubleTap(swiper, e) {
|
7725 | if (!swiper.animating && swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) {
|
7726 | swiper.zoom.toggle(e);
|
7727 | }
|
7728 | },
|
7729 | transitionEnd: function transitionEnd(swiper) {
|
7730 | if (swiper.zoom.enabled && swiper.params.zoom.enabled) {
|
7731 | swiper.zoom.onTransitionEnd();
|
7732 | }
|
7733 | },
|
7734 | slideChange: function slideChange(swiper) {
|
7735 | if (swiper.zoom.enabled && swiper.params.zoom.enabled && swiper.params.cssMode) {
|
7736 | swiper.zoom.onTransitionEnd();
|
7737 | }
|
7738 | }
|
7739 | }
|
7740 | };
|
7741 |
|
7742 | var Lazy = {
|
7743 | loadInSlide: function loadInSlide(index, loadInDuplicate) {
|
7744 | if (loadInDuplicate === void 0) {
|
7745 | loadInDuplicate = true;
|
7746 | }
|
7747 |
|
7748 | var swiper = this;
|
7749 | var params = swiper.params.lazy;
|
7750 | if (typeof index === 'undefined') return;
|
7751 | if (swiper.slides.length === 0) return;
|
7752 | var isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
7753 | var $slideEl = isVirtual ? swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-swiper-slide-index=\"" + index + "\"]") : swiper.slides.eq(index);
|
7754 | var $images = $slideEl.find("." + params.elementClass + ":not(." + params.loadedClass + "):not(." + params.loadingClass + ")");
|
7755 |
|
7756 | if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) {
|
7757 | $images.push($slideEl[0]);
|
7758 | }
|
7759 |
|
7760 | if ($images.length === 0) return;
|
7761 | $images.each(function (imageEl) {
|
7762 | var $imageEl = $(imageEl);
|
7763 | $imageEl.addClass(params.loadingClass);
|
7764 | var background = $imageEl.attr('data-background');
|
7765 | var src = $imageEl.attr('data-src');
|
7766 | var srcset = $imageEl.attr('data-srcset');
|
7767 | var sizes = $imageEl.attr('data-sizes');
|
7768 | var $pictureEl = $imageEl.parent('picture');
|
7769 | swiper.loadImage($imageEl[0], src || background, srcset, sizes, false, function () {
|
7770 | if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper && !swiper.params || swiper.destroyed) return;
|
7771 |
|
7772 | if (background) {
|
7773 | $imageEl.css('background-image', "url(\"" + background + "\")");
|
7774 | $imageEl.removeAttr('data-background');
|
7775 | } else {
|
7776 | if (srcset) {
|
7777 | $imageEl.attr('srcset', srcset);
|
7778 | $imageEl.removeAttr('data-srcset');
|
7779 | }
|
7780 |
|
7781 | if (sizes) {
|
7782 | $imageEl.attr('sizes', sizes);
|
7783 | $imageEl.removeAttr('data-sizes');
|
7784 | }
|
7785 |
|
7786 | if ($pictureEl.length) {
|
7787 | $pictureEl.children('source').each(function (sourceEl) {
|
7788 | var $source = $(sourceEl);
|
7789 |
|
7790 | if ($source.attr('data-srcset')) {
|
7791 | $source.attr('srcset', $source.attr('data-srcset'));
|
7792 | $source.removeAttr('data-srcset');
|
7793 | }
|
7794 | });
|
7795 | }
|
7796 |
|
7797 | if (src) {
|
7798 | $imageEl.attr('src', src);
|
7799 | $imageEl.removeAttr('data-src');
|
7800 | }
|
7801 | }
|
7802 |
|
7803 | $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass);
|
7804 | $slideEl.find("." + params.preloaderClass).remove();
|
7805 |
|
7806 | if (swiper.params.loop && loadInDuplicate) {
|
7807 | var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index');
|
7808 |
|
7809 | if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) {
|
7810 | var originalSlide = swiper.$wrapperEl.children("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + swiper.params.slideDuplicateClass + ")");
|
7811 | swiper.lazy.loadInSlide(originalSlide.index(), false);
|
7812 | } else {
|
7813 | var duplicatedSlide = swiper.$wrapperEl.children("." + swiper.params.slideDuplicateClass + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]");
|
7814 | swiper.lazy.loadInSlide(duplicatedSlide.index(), false);
|
7815 | }
|
7816 | }
|
7817 |
|
7818 | swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]);
|
7819 |
|
7820 | if (swiper.params.autoHeight) {
|
7821 | swiper.updateAutoHeight();
|
7822 | }
|
7823 | });
|
7824 | swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]);
|
7825 | });
|
7826 | },
|
7827 | load: function load() {
|
7828 | var swiper = this;
|
7829 | var $wrapperEl = swiper.$wrapperEl,
|
7830 | swiperParams = swiper.params,
|
7831 | slides = swiper.slides,
|
7832 | activeIndex = swiper.activeIndex;
|
7833 | var isVirtual = swiper.virtual && swiperParams.virtual.enabled;
|
7834 | var params = swiperParams.lazy;
|
7835 | var slidesPerView = swiperParams.slidesPerView;
|
7836 |
|
7837 | if (slidesPerView === 'auto') {
|
7838 | slidesPerView = 0;
|
7839 | }
|
7840 |
|
7841 | function slideExist(index) {
|
7842 | if (isVirtual) {
|
7843 | if ($wrapperEl.children("." + swiperParams.slideClass + "[data-swiper-slide-index=\"" + index + "\"]").length) {
|
7844 | return true;
|
7845 | }
|
7846 | } else if (slides[index]) return true;
|
7847 |
|
7848 | return false;
|
7849 | }
|
7850 |
|
7851 | function slideIndex(slideEl) {
|
7852 | if (isVirtual) {
|
7853 | return $(slideEl).attr('data-swiper-slide-index');
|
7854 | }
|
7855 |
|
7856 | return $(slideEl).index();
|
7857 | }
|
7858 |
|
7859 | if (!swiper.lazy.initialImageLoaded) swiper.lazy.initialImageLoaded = true;
|
7860 |
|
7861 | if (swiper.params.watchSlidesVisibility) {
|
7862 | $wrapperEl.children("." + swiperParams.slideVisibleClass).each(function (slideEl) {
|
7863 | var index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index();
|
7864 | swiper.lazy.loadInSlide(index);
|
7865 | });
|
7866 | } else if (slidesPerView > 1) {
|
7867 | for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) {
|
7868 | if (slideExist(i)) swiper.lazy.loadInSlide(i);
|
7869 | }
|
7870 | } else {
|
7871 | swiper.lazy.loadInSlide(activeIndex);
|
7872 | }
|
7873 |
|
7874 | if (params.loadPrevNext) {
|
7875 | if (slidesPerView > 1 || params.loadPrevNextAmount && params.loadPrevNextAmount > 1) {
|
7876 | var amount = params.loadPrevNextAmount;
|
7877 | var spv = slidesPerView;
|
7878 | var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length);
|
7879 | var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0);
|
7880 |
|
7881 | for (var _i = activeIndex + slidesPerView; _i < maxIndex; _i += 1) {
|
7882 | if (slideExist(_i)) swiper.lazy.loadInSlide(_i);
|
7883 | }
|
7884 |
|
7885 |
|
7886 | for (var _i2 = minIndex; _i2 < activeIndex; _i2 += 1) {
|
7887 | if (slideExist(_i2)) swiper.lazy.loadInSlide(_i2);
|
7888 | }
|
7889 | } else {
|
7890 | var nextSlide = $wrapperEl.children("." + swiperParams.slideNextClass);
|
7891 | if (nextSlide.length > 0) swiper.lazy.loadInSlide(slideIndex(nextSlide));
|
7892 | var prevSlide = $wrapperEl.children("." + swiperParams.slidePrevClass);
|
7893 | if (prevSlide.length > 0) swiper.lazy.loadInSlide(slideIndex(prevSlide));
|
7894 | }
|
7895 | }
|
7896 | },
|
7897 | checkInViewOnLoad: function checkInViewOnLoad() {
|
7898 | var window = getWindow();
|
7899 | var swiper = this;
|
7900 | if (!swiper || swiper.destroyed) return;
|
7901 | var $scrollElement = swiper.params.lazy.scrollingElement ? $(swiper.params.lazy.scrollingElement) : $(window);
|
7902 | var isWindow = $scrollElement[0] === window;
|
7903 | var scrollElementWidth = isWindow ? window.innerWidth : $scrollElement[0].offsetWidth;
|
7904 | var scrollElementHeight = isWindow ? window.innerHeight : $scrollElement[0].offsetHeight;
|
7905 | var swiperOffset = swiper.$el.offset();
|
7906 | var rtl = swiper.rtlTranslate;
|
7907 | var inView = false;
|
7908 | if (rtl) swiperOffset.left -= swiper.$el[0].scrollLeft;
|
7909 | var swiperCoord = [[swiperOffset.left, swiperOffset.top], [swiperOffset.left + swiper.width, swiperOffset.top], [swiperOffset.left, swiperOffset.top + swiper.height], [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height]];
|
7910 |
|
7911 | for (var i = 0; i < swiperCoord.length; i += 1) {
|
7912 | var point = swiperCoord[i];
|
7913 |
|
7914 | if (point[0] >= 0 && point[0] <= scrollElementWidth && point[1] >= 0 && point[1] <= scrollElementHeight) {
|
7915 | if (point[0] === 0 && point[1] === 0) continue;
|
7916 |
|
7917 | inView = true;
|
7918 | }
|
7919 | }
|
7920 |
|
7921 | if (inView) {
|
7922 | swiper.lazy.load();
|
7923 | $scrollElement.off('scroll', swiper.lazy.checkInViewOnLoad);
|
7924 | } else if (!swiper.lazy.scrollHandlerAttached) {
|
7925 | swiper.lazy.scrollHandlerAttached = true;
|
7926 | $scrollElement.on('scroll', swiper.lazy.checkInViewOnLoad);
|
7927 | }
|
7928 | }
|
7929 | };
|
7930 | var Lazy$1 = {
|
7931 | name: 'lazy',
|
7932 | params: {
|
7933 | lazy: {
|
7934 | checkInView: false,
|
7935 | enabled: false,
|
7936 | loadPrevNext: false,
|
7937 | loadPrevNextAmount: 1,
|
7938 | loadOnTransitionStart: false,
|
7939 | scrollingElement: '',
|
7940 | elementClass: 'swiper-lazy',
|
7941 | loadingClass: 'swiper-lazy-loading',
|
7942 | loadedClass: 'swiper-lazy-loaded',
|
7943 | preloaderClass: 'swiper-lazy-preloader'
|
7944 | }
|
7945 | },
|
7946 | create: function create() {
|
7947 | var swiper = this;
|
7948 | bindModuleMethods(swiper, {
|
7949 | lazy: _extends({
|
7950 | initialImageLoaded: false
|
7951 | }, Lazy)
|
7952 | });
|
7953 | },
|
7954 | on: {
|
7955 | beforeInit: function beforeInit(swiper) {
|
7956 | if (swiper.params.lazy.enabled && swiper.params.preloadImages) {
|
7957 | swiper.params.preloadImages = false;
|
7958 | }
|
7959 | },
|
7960 | init: function init(swiper) {
|
7961 | if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) {
|
7962 | if (swiper.params.lazy.checkInView) {
|
7963 | swiper.lazy.checkInViewOnLoad();
|
7964 | } else {
|
7965 | swiper.lazy.load();
|
7966 | }
|
7967 | }
|
7968 | },
|
7969 | scroll: function scroll(swiper) {
|
7970 | if (swiper.params.freeMode && !swiper.params.freeModeSticky) {
|
7971 | swiper.lazy.load();
|
7972 | }
|
7973 | },
|
7974 | 'scrollbarDragMove resize _freeModeNoMomentumRelease': function lazyLoad(swiper) {
|
7975 | if (swiper.params.lazy.enabled) {
|
7976 | swiper.lazy.load();
|
7977 | }
|
7978 | },
|
7979 | transitionStart: function transitionStart(swiper) {
|
7980 | if (swiper.params.lazy.enabled) {
|
7981 | if (swiper.params.lazy.loadOnTransitionStart || !swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded) {
|
7982 | swiper.lazy.load();
|
7983 | }
|
7984 | }
|
7985 | },
|
7986 | transitionEnd: function transitionEnd(swiper) {
|
7987 | if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) {
|
7988 | swiper.lazy.load();
|
7989 | }
|
7990 | },
|
7991 | slideChange: function slideChange(swiper) {
|
7992 | if (swiper.params.lazy.enabled && swiper.params.cssMode) {
|
7993 | swiper.lazy.load();
|
7994 | }
|
7995 | }
|
7996 | }
|
7997 | };
|
7998 |
|
7999 | var Controller = {
|
8000 | LinearSpline: function LinearSpline(x, y) {
|
8001 | var binarySearch = function search() {
|
8002 | var maxIndex;
|
8003 | var minIndex;
|
8004 | var guess;
|
8005 | return function (array, val) {
|
8006 | minIndex = -1;
|
8007 | maxIndex = array.length;
|
8008 |
|
8009 | while (maxIndex - minIndex > 1) {
|
8010 | guess = maxIndex + minIndex >> 1;
|
8011 |
|
8012 | if (array[guess] <= val) {
|
8013 | minIndex = guess;
|
8014 | } else {
|
8015 | maxIndex = guess;
|
8016 | }
|
8017 | }
|
8018 |
|
8019 | return maxIndex;
|
8020 | };
|
8021 | }();
|
8022 |
|
8023 | this.x = x;
|
8024 | this.y = y;
|
8025 | this.lastIndex = x.length - 1;
|
8026 |
|
8027 |
|
8028 |
|
8029 | var i1;
|
8030 | var i3;
|
8031 |
|
8032 | this.interpolate = function interpolate(x2) {
|
8033 | if (!x2) return 0;
|
8034 |
|
8035 | i3 = binarySearch(this.x, x2);
|
8036 | i1 = i3 - 1;
|
8037 |
|
8038 |
|
8039 | return (x2 - this.x[i1]) * (this.y[i3] - this.y[i1]) / (this.x[i3] - this.x[i1]) + this.y[i1];
|
8040 | };
|
8041 |
|
8042 | return this;
|
8043 | },
|
8044 |
|
8045 | getInterpolateFunction: function getInterpolateFunction(c) {
|
8046 | var swiper = this;
|
8047 |
|
8048 | if (!swiper.controller.spline) {
|
8049 | swiper.controller.spline = swiper.params.loop ? new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) : new Controller.LinearSpline(swiper.snapGrid, c.snapGrid);
|
8050 | }
|
8051 | },
|
8052 | setTranslate: function setTranslate(_setTranslate, byController) {
|
8053 | var swiper = this;
|
8054 | var controlled = swiper.controller.control;
|
8055 | var multiplier;
|
8056 | var controlledTranslate;
|
8057 | var Swiper = swiper.constructor;
|
8058 |
|
8059 | function setControlledTranslate(c) {
|
8060 |
|
8061 |
|
8062 |
|
8063 |
|
8064 | var translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate;
|
8065 |
|
8066 | if (swiper.params.controller.by === 'slide') {
|
8067 | swiper.controller.getInterpolateFunction(c);
|
8068 |
|
8069 |
|
8070 | controlledTranslate = -swiper.controller.spline.interpolate(-translate);
|
8071 | }
|
8072 |
|
8073 | if (!controlledTranslate || swiper.params.controller.by === 'container') {
|
8074 | multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate());
|
8075 | controlledTranslate = (translate - swiper.minTranslate()) * multiplier + c.minTranslate();
|
8076 | }
|
8077 |
|
8078 | if (swiper.params.controller.inverse) {
|
8079 | controlledTranslate = c.maxTranslate() - controlledTranslate;
|
8080 | }
|
8081 |
|
8082 | c.updateProgress(controlledTranslate);
|
8083 | c.setTranslate(controlledTranslate, swiper);
|
8084 | c.updateActiveIndex();
|
8085 | c.updateSlidesClasses();
|
8086 | }
|
8087 |
|
8088 | if (Array.isArray(controlled)) {
|
8089 | for (var i = 0; i < controlled.length; i += 1) {
|
8090 | if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
|
8091 | setControlledTranslate(controlled[i]);
|
8092 | }
|
8093 | }
|
8094 | } else if (controlled instanceof Swiper && byController !== controlled) {
|
8095 | setControlledTranslate(controlled);
|
8096 | }
|
8097 | },
|
8098 | setTransition: function setTransition(duration, byController) {
|
8099 | var swiper = this;
|
8100 | var Swiper = swiper.constructor;
|
8101 | var controlled = swiper.controller.control;
|
8102 | var i;
|
8103 |
|
8104 | function setControlledTransition(c) {
|
8105 | c.setTransition(duration, swiper);
|
8106 |
|
8107 | if (duration !== 0) {
|
8108 | c.transitionStart();
|
8109 |
|
8110 | if (c.params.autoHeight) {
|
8111 | nextTick(function () {
|
8112 | c.updateAutoHeight();
|
8113 | });
|
8114 | }
|
8115 |
|
8116 | c.$wrapperEl.transitionEnd(function () {
|
8117 | if (!controlled) return;
|
8118 |
|
8119 | if (c.params.loop && swiper.params.controller.by === 'slide') {
|
8120 | c.loopFix();
|
8121 | }
|
8122 |
|
8123 | c.transitionEnd();
|
8124 | });
|
8125 | }
|
8126 | }
|
8127 |
|
8128 | if (Array.isArray(controlled)) {
|
8129 | for (i = 0; i < controlled.length; i += 1) {
|
8130 | if (controlled[i] !== byController && controlled[i] instanceof Swiper) {
|
8131 | setControlledTransition(controlled[i]);
|
8132 | }
|
8133 | }
|
8134 | } else if (controlled instanceof Swiper && byController !== controlled) {
|
8135 | setControlledTransition(controlled);
|
8136 | }
|
8137 | }
|
8138 | };
|
8139 | var Controller$1 = {
|
8140 | name: 'controller',
|
8141 | params: {
|
8142 | controller: {
|
8143 | control: undefined,
|
8144 | inverse: false,
|
8145 | by: 'slide'
|
8146 |
|
8147 | }
|
8148 | },
|
8149 | create: function create() {
|
8150 | var swiper = this;
|
8151 | bindModuleMethods(swiper, {
|
8152 | controller: _extends({
|
8153 | control: swiper.params.controller.control
|
8154 | }, Controller)
|
8155 | });
|
8156 | },
|
8157 | on: {
|
8158 | update: function update(swiper) {
|
8159 | if (!swiper.controller.control) return;
|
8160 |
|
8161 | if (swiper.controller.spline) {
|
8162 | swiper.controller.spline = undefined;
|
8163 | delete swiper.controller.spline;
|
8164 | }
|
8165 | },
|
8166 | resize: function resize(swiper) {
|
8167 | if (!swiper.controller.control) return;
|
8168 |
|
8169 | if (swiper.controller.spline) {
|
8170 | swiper.controller.spline = undefined;
|
8171 | delete swiper.controller.spline;
|
8172 | }
|
8173 | },
|
8174 | observerUpdate: function observerUpdate(swiper) {
|
8175 | if (!swiper.controller.control) return;
|
8176 |
|
8177 | if (swiper.controller.spline) {
|
8178 | swiper.controller.spline = undefined;
|
8179 | delete swiper.controller.spline;
|
8180 | }
|
8181 | },
|
8182 | setTranslate: function setTranslate(swiper, translate, byController) {
|
8183 | if (!swiper.controller.control) return;
|
8184 | swiper.controller.setTranslate(translate, byController);
|
8185 | },
|
8186 | setTransition: function setTransition(swiper, duration, byController) {
|
8187 | if (!swiper.controller.control) return;
|
8188 | swiper.controller.setTransition(duration, byController);
|
8189 | }
|
8190 | }
|
8191 | };
|
8192 |
|
8193 | var A11y = {
|
8194 | getRandomNumber: function getRandomNumber(size) {
|
8195 | if (size === void 0) {
|
8196 | size = 16;
|
8197 | }
|
8198 |
|
8199 | var randomChar = function randomChar() {
|
8200 | return Math.round(16 * Math.random()).toString(16);
|
8201 | };
|
8202 |
|
8203 | return 'x'.repeat(size).replace(/x/g, randomChar);
|
8204 | },
|
8205 | makeElFocusable: function makeElFocusable($el) {
|
8206 | $el.attr('tabIndex', '0');
|
8207 | return $el;
|
8208 | },
|
8209 | makeElNotFocusable: function makeElNotFocusable($el) {
|
8210 | $el.attr('tabIndex', '-1');
|
8211 | return $el;
|
8212 | },
|
8213 | addElRole: function addElRole($el, role) {
|
8214 | $el.attr('role', role);
|
8215 | return $el;
|
8216 | },
|
8217 | addElRoleDescription: function addElRoleDescription($el, description) {
|
8218 | $el.attr('aria-roledescription', description);
|
8219 | return $el;
|
8220 | },
|
8221 | addElControls: function addElControls($el, controls) {
|
8222 | $el.attr('aria-controls', controls);
|
8223 | return $el;
|
8224 | },
|
8225 | addElLabel: function addElLabel($el, label) {
|
8226 | $el.attr('aria-label', label);
|
8227 | return $el;
|
8228 | },
|
8229 | addElId: function addElId($el, id) {
|
8230 | $el.attr('id', id);
|
8231 | return $el;
|
8232 | },
|
8233 | addElLive: function addElLive($el, live) {
|
8234 | $el.attr('aria-live', live);
|
8235 | return $el;
|
8236 | },
|
8237 | disableEl: function disableEl($el) {
|
8238 | $el.attr('aria-disabled', true);
|
8239 | return $el;
|
8240 | },
|
8241 | enableEl: function enableEl($el) {
|
8242 | $el.attr('aria-disabled', false);
|
8243 | return $el;
|
8244 | },
|
8245 | onEnterOrSpaceKey: function onEnterOrSpaceKey(e) {
|
8246 | if (e.keyCode !== 13 && e.keyCode !== 32) return;
|
8247 | var swiper = this;
|
8248 | var params = swiper.params.a11y;
|
8249 | var $targetEl = $(e.target);
|
8250 |
|
8251 | if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) {
|
8252 | if (!(swiper.isEnd && !swiper.params.loop)) {
|
8253 | swiper.slideNext();
|
8254 | }
|
8255 |
|
8256 | if (swiper.isEnd) {
|
8257 | swiper.a11y.notify(params.lastSlideMessage);
|
8258 | } else {
|
8259 | swiper.a11y.notify(params.nextSlideMessage);
|
8260 | }
|
8261 | }
|
8262 |
|
8263 | if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) {
|
8264 | if (!(swiper.isBeginning && !swiper.params.loop)) {
|
8265 | swiper.slidePrev();
|
8266 | }
|
8267 |
|
8268 | if (swiper.isBeginning) {
|
8269 | swiper.a11y.notify(params.firstSlideMessage);
|
8270 | } else {
|
8271 | swiper.a11y.notify(params.prevSlideMessage);
|
8272 | }
|
8273 | }
|
8274 |
|
8275 | if (swiper.pagination && $targetEl.is(classesToSelector(swiper.params.pagination.bulletClass))) {
|
8276 | $targetEl[0].click();
|
8277 | }
|
8278 | },
|
8279 | notify: function notify(message) {
|
8280 | var swiper = this;
|
8281 | var notification = swiper.a11y.liveRegion;
|
8282 | if (notification.length === 0) return;
|
8283 | notification.html('');
|
8284 | notification.html(message);
|
8285 | },
|
8286 | updateNavigation: function updateNavigation() {
|
8287 | var swiper = this;
|
8288 | if (swiper.params.loop || !swiper.navigation) return;
|
8289 | var _swiper$navigation = swiper.navigation,
|
8290 | $nextEl = _swiper$navigation.$nextEl,
|
8291 | $prevEl = _swiper$navigation.$prevEl;
|
8292 |
|
8293 | if ($prevEl && $prevEl.length > 0) {
|
8294 | if (swiper.isBeginning) {
|
8295 | swiper.a11y.disableEl($prevEl);
|
8296 | swiper.a11y.makeElNotFocusable($prevEl);
|
8297 | } else {
|
8298 | swiper.a11y.enableEl($prevEl);
|
8299 | swiper.a11y.makeElFocusable($prevEl);
|
8300 | }
|
8301 | }
|
8302 |
|
8303 | if ($nextEl && $nextEl.length > 0) {
|
8304 | if (swiper.isEnd) {
|
8305 | swiper.a11y.disableEl($nextEl);
|
8306 | swiper.a11y.makeElNotFocusable($nextEl);
|
8307 | } else {
|
8308 | swiper.a11y.enableEl($nextEl);
|
8309 | swiper.a11y.makeElFocusable($nextEl);
|
8310 | }
|
8311 | }
|
8312 | },
|
8313 | updatePagination: function updatePagination() {
|
8314 | var swiper = this;
|
8315 | var params = swiper.params.a11y;
|
8316 |
|
8317 | if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) {
|
8318 | swiper.pagination.bullets.each(function (bulletEl) {
|
8319 | var $bulletEl = $(bulletEl);
|
8320 | swiper.a11y.makeElFocusable($bulletEl);
|
8321 |
|
8322 | if (!swiper.params.pagination.renderBullet) {
|
8323 | swiper.a11y.addElRole($bulletEl, 'button');
|
8324 | swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/\{\{index\}\}/, $bulletEl.index() + 1));
|
8325 | }
|
8326 | });
|
8327 | }
|
8328 | },
|
8329 | init: function init() {
|
8330 | var swiper = this;
|
8331 | var params = swiper.params.a11y;
|
8332 | swiper.$el.append(swiper.a11y.liveRegion);
|
8333 |
|
8334 | var $containerEl = swiper.$el;
|
8335 |
|
8336 | if (params.containerRoleDescriptionMessage) {
|
8337 | swiper.a11y.addElRoleDescription($containerEl, params.containerRoleDescriptionMessage);
|
8338 | }
|
8339 |
|
8340 | if (params.containerMessage) {
|
8341 | swiper.a11y.addElLabel($containerEl, params.containerMessage);
|
8342 | }
|
8343 |
|
8344 |
|
8345 | var $wrapperEl = swiper.$wrapperEl;
|
8346 | var wrapperId = $wrapperEl.attr('id') || "swiper-wrapper-" + swiper.a11y.getRandomNumber(16);
|
8347 | var live;
|
8348 | swiper.a11y.addElId($wrapperEl, wrapperId);
|
8349 |
|
8350 | if (swiper.params.autoplay && swiper.params.autoplay.enabled) {
|
8351 | live = 'off';
|
8352 | } else {
|
8353 | live = 'polite';
|
8354 | }
|
8355 |
|
8356 | swiper.a11y.addElLive($wrapperEl, live);
|
8357 |
|
8358 | if (params.itemRoleDescriptionMessage) {
|
8359 | swiper.a11y.addElRoleDescription($(swiper.slides), params.itemRoleDescriptionMessage);
|
8360 | }
|
8361 |
|
8362 | swiper.a11y.addElRole($(swiper.slides), 'group');
|
8363 | swiper.slides.each(function (slideEl) {
|
8364 | var $slideEl = $(slideEl);
|
8365 | var ariaLabelMessage = params.slideLabelMessage.replace(/\{\{index\}\}/, $slideEl.index() + 1).replace(/\{\{slidesLength\}\}/, swiper.slides.length);
|
8366 | swiper.a11y.addElLabel($slideEl, ariaLabelMessage);
|
8367 | });
|
8368 |
|
8369 | var $nextEl;
|
8370 | var $prevEl;
|
8371 |
|
8372 | if (swiper.navigation && swiper.navigation.$nextEl) {
|
8373 | $nextEl = swiper.navigation.$nextEl;
|
8374 | }
|
8375 |
|
8376 | if (swiper.navigation && swiper.navigation.$prevEl) {
|
8377 | $prevEl = swiper.navigation.$prevEl;
|
8378 | }
|
8379 |
|
8380 | if ($nextEl && $nextEl.length) {
|
8381 | swiper.a11y.makeElFocusable($nextEl);
|
8382 |
|
8383 | if ($nextEl[0].tagName !== 'BUTTON') {
|
8384 | swiper.a11y.addElRole($nextEl, 'button');
|
8385 | $nextEl.on('keydown', swiper.a11y.onEnterOrSpaceKey);
|
8386 | }
|
8387 |
|
8388 | swiper.a11y.addElLabel($nextEl, params.nextSlideMessage);
|
8389 | swiper.a11y.addElControls($nextEl, wrapperId);
|
8390 | }
|
8391 |
|
8392 | if ($prevEl && $prevEl.length) {
|
8393 | swiper.a11y.makeElFocusable($prevEl);
|
8394 |
|
8395 | if ($prevEl[0].tagName !== 'BUTTON') {
|
8396 | swiper.a11y.addElRole($prevEl, 'button');
|
8397 | $prevEl.on('keydown', swiper.a11y.onEnterOrSpaceKey);
|
8398 | }
|
8399 |
|
8400 | swiper.a11y.addElLabel($prevEl, params.prevSlideMessage);
|
8401 | swiper.a11y.addElControls($prevEl, wrapperId);
|
8402 | }
|
8403 |
|
8404 |
|
8405 | if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) {
|
8406 | swiper.pagination.$el.on('keydown', classesToSelector(swiper.params.pagination.bulletClass), swiper.a11y.onEnterOrSpaceKey);
|
8407 | }
|
8408 | },
|
8409 | destroy: function destroy() {
|
8410 | var swiper = this;
|
8411 | if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) swiper.a11y.liveRegion.remove();
|
8412 | var $nextEl;
|
8413 | var $prevEl;
|
8414 |
|
8415 | if (swiper.navigation && swiper.navigation.$nextEl) {
|
8416 | $nextEl = swiper.navigation.$nextEl;
|
8417 | }
|
8418 |
|
8419 | if (swiper.navigation && swiper.navigation.$prevEl) {
|
8420 | $prevEl = swiper.navigation.$prevEl;
|
8421 | }
|
8422 |
|
8423 | if ($nextEl) {
|
8424 | $nextEl.off('keydown', swiper.a11y.onEnterOrSpaceKey);
|
8425 | }
|
8426 |
|
8427 | if ($prevEl) {
|
8428 | $prevEl.off('keydown', swiper.a11y.onEnterOrSpaceKey);
|
8429 | }
|
8430 |
|
8431 |
|
8432 | if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) {
|
8433 | swiper.pagination.$el.off('keydown', classesToSelector(swiper.params.pagination.bulletClass), swiper.a11y.onEnterOrSpaceKey);
|
8434 | }
|
8435 | }
|
8436 | };
|
8437 | var A11y$1 = {
|
8438 | name: 'a11y',
|
8439 | params: {
|
8440 | a11y: {
|
8441 | enabled: true,
|
8442 | notificationClass: 'swiper-notification',
|
8443 | prevSlideMessage: 'Previous slide',
|
8444 | nextSlideMessage: 'Next slide',
|
8445 | firstSlideMessage: 'This is the first slide',
|
8446 | lastSlideMessage: 'This is the last slide',
|
8447 | paginationBulletMessage: 'Go to slide {{index}}',
|
8448 | slideLabelMessage: '{{index}} / {{slidesLength}}',
|
8449 | containerMessage: null,
|
8450 | containerRoleDescriptionMessage: null,
|
8451 | itemRoleDescriptionMessage: null
|
8452 | }
|
8453 | },
|
8454 | create: function create() {
|
8455 | var swiper = this;
|
8456 | bindModuleMethods(swiper, {
|
8457 | a11y: _extends({}, A11y, {
|
8458 | liveRegion: $("<span class=\"" + swiper.params.a11y.notificationClass + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>")
|
8459 | })
|
8460 | });
|
8461 | },
|
8462 | on: {
|
8463 | afterInit: function afterInit(swiper) {
|
8464 | if (!swiper.params.a11y.enabled) return;
|
8465 | swiper.a11y.init();
|
8466 | swiper.a11y.updateNavigation();
|
8467 | },
|
8468 | toEdge: function toEdge(swiper) {
|
8469 | if (!swiper.params.a11y.enabled) return;
|
8470 | swiper.a11y.updateNavigation();
|
8471 | },
|
8472 | fromEdge: function fromEdge(swiper) {
|
8473 | if (!swiper.params.a11y.enabled) return;
|
8474 | swiper.a11y.updateNavigation();
|
8475 | },
|
8476 | paginationUpdate: function paginationUpdate(swiper) {
|
8477 | if (!swiper.params.a11y.enabled) return;
|
8478 | swiper.a11y.updatePagination();
|
8479 | },
|
8480 | destroy: function destroy(swiper) {
|
8481 | if (!swiper.params.a11y.enabled) return;
|
8482 | swiper.a11y.destroy();
|
8483 | }
|
8484 | }
|
8485 | };
|
8486 |
|
8487 | var History = {
|
8488 | init: function init() {
|
8489 | var swiper = this;
|
8490 | var window = getWindow();
|
8491 | if (!swiper.params.history) return;
|
8492 |
|
8493 | if (!window.history || !window.history.pushState) {
|
8494 | swiper.params.history.enabled = false;
|
8495 | swiper.params.hashNavigation.enabled = true;
|
8496 | return;
|
8497 | }
|
8498 |
|
8499 | var history = swiper.history;
|
8500 | history.initialized = true;
|
8501 | history.paths = History.getPathValues(swiper.params.url);
|
8502 | if (!history.paths.key && !history.paths.value) return;
|
8503 | history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit);
|
8504 |
|
8505 | if (!swiper.params.history.replaceState) {
|
8506 | window.addEventListener('popstate', swiper.history.setHistoryPopState);
|
8507 | }
|
8508 | },
|
8509 | destroy: function destroy() {
|
8510 | var swiper = this;
|
8511 | var window = getWindow();
|
8512 |
|
8513 | if (!swiper.params.history.replaceState) {
|
8514 | window.removeEventListener('popstate', swiper.history.setHistoryPopState);
|
8515 | }
|
8516 | },
|
8517 | setHistoryPopState: function setHistoryPopState() {
|
8518 | var swiper = this;
|
8519 | swiper.history.paths = History.getPathValues(swiper.params.url);
|
8520 | swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false);
|
8521 | },
|
8522 | getPathValues: function getPathValues(urlOverride) {
|
8523 | var window = getWindow();
|
8524 | var location;
|
8525 |
|
8526 | if (urlOverride) {
|
8527 | location = new URL(urlOverride);
|
8528 | } else {
|
8529 | location = window.location;
|
8530 | }
|
8531 |
|
8532 | var pathArray = location.pathname.slice(1).split('/').filter(function (part) {
|
8533 | return part !== '';
|
8534 | });
|
8535 | var total = pathArray.length;
|
8536 | var key = pathArray[total - 2];
|
8537 | var value = pathArray[total - 1];
|
8538 | return {
|
8539 | key: key,
|
8540 | value: value
|
8541 | };
|
8542 | },
|
8543 | setHistory: function setHistory(key, index) {
|
8544 | var swiper = this;
|
8545 | var window = getWindow();
|
8546 | if (!swiper.history.initialized || !swiper.params.history.enabled) return;
|
8547 | var location;
|
8548 |
|
8549 | if (swiper.params.url) {
|
8550 | location = new URL(swiper.params.url);
|
8551 | } else {
|
8552 | location = window.location;
|
8553 | }
|
8554 |
|
8555 | var slide = swiper.slides.eq(index);
|
8556 | var value = History.slugify(slide.attr('data-history'));
|
8557 |
|
8558 | if (!location.pathname.includes(key)) {
|
8559 | value = key + "/" + value;
|
8560 | }
|
8561 |
|
8562 | var currentState = window.history.state;
|
8563 |
|
8564 | if (currentState && currentState.value === value) {
|
8565 | return;
|
8566 | }
|
8567 |
|
8568 | if (swiper.params.history.replaceState) {
|
8569 | window.history.replaceState({
|
8570 | value: value
|
8571 | }, null, value);
|
8572 | } else {
|
8573 | window.history.pushState({
|
8574 | value: value
|
8575 | }, null, value);
|
8576 | }
|
8577 | },
|
8578 | slugify: function slugify(text) {
|
8579 | return text.toString().replace(/\s+/g, '-').replace(/[^\w-]+/g, '').replace(/--+/g, '-').replace(/^-+/, '').replace(/-+$/, '');
|
8580 | },
|
8581 | scrollToSlide: function scrollToSlide(speed, value, runCallbacks) {
|
8582 | var swiper = this;
|
8583 |
|
8584 | if (value) {
|
8585 | for (var i = 0, length = swiper.slides.length; i < length; i += 1) {
|
8586 | var slide = swiper.slides.eq(i);
|
8587 | var slideHistory = History.slugify(slide.attr('data-history'));
|
8588 |
|
8589 | if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) {
|
8590 | var index = slide.index();
|
8591 | swiper.slideTo(index, speed, runCallbacks);
|
8592 | }
|
8593 | }
|
8594 | } else {
|
8595 | swiper.slideTo(0, speed, runCallbacks);
|
8596 | }
|
8597 | }
|
8598 | };
|
8599 | var History$1 = {
|
8600 | name: 'history',
|
8601 | params: {
|
8602 | history: {
|
8603 | enabled: false,
|
8604 | replaceState: false,
|
8605 | key: 'slides'
|
8606 | }
|
8607 | },
|
8608 | create: function create() {
|
8609 | var swiper = this;
|
8610 | bindModuleMethods(swiper, {
|
8611 | history: _extends({}, History)
|
8612 | });
|
8613 | },
|
8614 | on: {
|
8615 | init: function init(swiper) {
|
8616 | if (swiper.params.history.enabled) {
|
8617 | swiper.history.init();
|
8618 | }
|
8619 | },
|
8620 | destroy: function destroy(swiper) {
|
8621 | if (swiper.params.history.enabled) {
|
8622 | swiper.history.destroy();
|
8623 | }
|
8624 | },
|
8625 | transitionEnd: function transitionEnd(swiper) {
|
8626 | if (swiper.history.initialized) {
|
8627 | swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex);
|
8628 | }
|
8629 | },
|
8630 | slideChange: function slideChange(swiper) {
|
8631 | if (swiper.history.initialized && swiper.params.cssMode) {
|
8632 | swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex);
|
8633 | }
|
8634 | }
|
8635 | }
|
8636 | };
|
8637 |
|
8638 | var HashNavigation = {
|
8639 | onHashCange: function onHashCange() {
|
8640 | var swiper = this;
|
8641 | var document = getDocument();
|
8642 | swiper.emit('hashChange');
|
8643 | var newHash = document.location.hash.replace('#', '');
|
8644 | var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash');
|
8645 |
|
8646 | if (newHash !== activeSlideHash) {
|
8647 | var newIndex = swiper.$wrapperEl.children("." + swiper.params.slideClass + "[data-hash=\"" + newHash + "\"]").index();
|
8648 | if (typeof newIndex === 'undefined') return;
|
8649 | swiper.slideTo(newIndex);
|
8650 | }
|
8651 | },
|
8652 | setHash: function setHash() {
|
8653 | var swiper = this;
|
8654 | var window = getWindow();
|
8655 | var document = getDocument();
|
8656 | if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) return;
|
8657 |
|
8658 | if (swiper.params.hashNavigation.replaceState && window.history && window.history.replaceState) {
|
8659 | window.history.replaceState(null, null, "#" + swiper.slides.eq(swiper.activeIndex).attr('data-hash') || '');
|
8660 | swiper.emit('hashSet');
|
8661 | } else {
|
8662 | var slide = swiper.slides.eq(swiper.activeIndex);
|
8663 | var hash = slide.attr('data-hash') || slide.attr('data-history');
|
8664 | document.location.hash = hash || '';
|
8665 | swiper.emit('hashSet');
|
8666 | }
|
8667 | },
|
8668 | init: function init() {
|
8669 | var swiper = this;
|
8670 | var document = getDocument();
|
8671 | var window = getWindow();
|
8672 | if (!swiper.params.hashNavigation.enabled || swiper.params.history && swiper.params.history.enabled) return;
|
8673 | swiper.hashNavigation.initialized = true;
|
8674 | var hash = document.location.hash.replace('#', '');
|
8675 |
|
8676 | if (hash) {
|
8677 | var speed = 0;
|
8678 |
|
8679 | for (var i = 0, length = swiper.slides.length; i < length; i += 1) {
|
8680 | var slide = swiper.slides.eq(i);
|
8681 | var slideHash = slide.attr('data-hash') || slide.attr('data-history');
|
8682 |
|
8683 | if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) {
|
8684 | var index = slide.index();
|
8685 | swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true);
|
8686 | }
|
8687 | }
|
8688 | }
|
8689 |
|
8690 | if (swiper.params.hashNavigation.watchState) {
|
8691 | $(window).on('hashchange', swiper.hashNavigation.onHashCange);
|
8692 | }
|
8693 | },
|
8694 | destroy: function destroy() {
|
8695 | var swiper = this;
|
8696 | var window = getWindow();
|
8697 |
|
8698 | if (swiper.params.hashNavigation.watchState) {
|
8699 | $(window).off('hashchange', swiper.hashNavigation.onHashCange);
|
8700 | }
|
8701 | }
|
8702 | };
|
8703 | var HashNavigation$1 = {
|
8704 | name: 'hash-navigation',
|
8705 | params: {
|
8706 | hashNavigation: {
|
8707 | enabled: false,
|
8708 | replaceState: false,
|
8709 | watchState: false
|
8710 | }
|
8711 | },
|
8712 | create: function create() {
|
8713 | var swiper = this;
|
8714 | bindModuleMethods(swiper, {
|
8715 | hashNavigation: _extends({
|
8716 | initialized: false
|
8717 | }, HashNavigation)
|
8718 | });
|
8719 | },
|
8720 | on: {
|
8721 | init: function init(swiper) {
|
8722 | if (swiper.params.hashNavigation.enabled) {
|
8723 | swiper.hashNavigation.init();
|
8724 | }
|
8725 | },
|
8726 | destroy: function destroy(swiper) {
|
8727 | if (swiper.params.hashNavigation.enabled) {
|
8728 | swiper.hashNavigation.destroy();
|
8729 | }
|
8730 | },
|
8731 | transitionEnd: function transitionEnd(swiper) {
|
8732 | if (swiper.hashNavigation.initialized) {
|
8733 | swiper.hashNavigation.setHash();
|
8734 | }
|
8735 | },
|
8736 | slideChange: function slideChange(swiper) {
|
8737 | if (swiper.hashNavigation.initialized && swiper.params.cssMode) {
|
8738 | swiper.hashNavigation.setHash();
|
8739 | }
|
8740 | }
|
8741 | }
|
8742 | };
|
8743 |
|
8744 | var Autoplay = {
|
8745 | run: function run() {
|
8746 | var swiper = this;
|
8747 | var $activeSlideEl = swiper.slides.eq(swiper.activeIndex);
|
8748 | var delay = swiper.params.autoplay.delay;
|
8749 |
|
8750 | if ($activeSlideEl.attr('data-swiper-autoplay')) {
|
8751 | delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay;
|
8752 | }
|
8753 |
|
8754 | clearTimeout(swiper.autoplay.timeout);
|
8755 | swiper.autoplay.timeout = nextTick(function () {
|
8756 | var autoplayResult;
|
8757 |
|
8758 | if (swiper.params.autoplay.reverseDirection) {
|
8759 | if (swiper.params.loop) {
|
8760 | swiper.loopFix();
|
8761 | autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
|
8762 | swiper.emit('autoplay');
|
8763 | } else if (!swiper.isBeginning) {
|
8764 | autoplayResult = swiper.slidePrev(swiper.params.speed, true, true);
|
8765 | swiper.emit('autoplay');
|
8766 | } else if (!swiper.params.autoplay.stopOnLastSlide) {
|
8767 | autoplayResult = swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true);
|
8768 | swiper.emit('autoplay');
|
8769 | } else {
|
8770 | swiper.autoplay.stop();
|
8771 | }
|
8772 | } else if (swiper.params.loop) {
|
8773 | swiper.loopFix();
|
8774 | autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
|
8775 | swiper.emit('autoplay');
|
8776 | } else if (!swiper.isEnd) {
|
8777 | autoplayResult = swiper.slideNext(swiper.params.speed, true, true);
|
8778 | swiper.emit('autoplay');
|
8779 | } else if (!swiper.params.autoplay.stopOnLastSlide) {
|
8780 | autoplayResult = swiper.slideTo(0, swiper.params.speed, true, true);
|
8781 | swiper.emit('autoplay');
|
8782 | } else {
|
8783 | swiper.autoplay.stop();
|
8784 | }
|
8785 |
|
8786 | if (swiper.params.cssMode && swiper.autoplay.running) swiper.autoplay.run();else if (autoplayResult === false) {
|
8787 | swiper.autoplay.run();
|
8788 | }
|
8789 | }, delay);
|
8790 | },
|
8791 | start: function start() {
|
8792 | var swiper = this;
|
8793 | if (typeof swiper.autoplay.timeout !== 'undefined') return false;
|
8794 | if (swiper.autoplay.running) return false;
|
8795 | swiper.autoplay.running = true;
|
8796 | swiper.emit('autoplayStart');
|
8797 | swiper.autoplay.run();
|
8798 | return true;
|
8799 | },
|
8800 | stop: function stop() {
|
8801 | var swiper = this;
|
8802 | if (!swiper.autoplay.running) return false;
|
8803 | if (typeof swiper.autoplay.timeout === 'undefined') return false;
|
8804 |
|
8805 | if (swiper.autoplay.timeout) {
|
8806 | clearTimeout(swiper.autoplay.timeout);
|
8807 | swiper.autoplay.timeout = undefined;
|
8808 | }
|
8809 |
|
8810 | swiper.autoplay.running = false;
|
8811 | swiper.emit('autoplayStop');
|
8812 | return true;
|
8813 | },
|
8814 | pause: function pause(speed) {
|
8815 | var swiper = this;
|
8816 | if (!swiper.autoplay.running) return;
|
8817 | if (swiper.autoplay.paused) return;
|
8818 | if (swiper.autoplay.timeout) clearTimeout(swiper.autoplay.timeout);
|
8819 | swiper.autoplay.paused = true;
|
8820 |
|
8821 | if (speed === 0 || !swiper.params.autoplay.waitForTransition) {
|
8822 | swiper.autoplay.paused = false;
|
8823 | swiper.autoplay.run();
|
8824 | } else {
|
8825 | swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd);
|
8826 | swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
|
8827 | }
|
8828 | },
|
8829 | onVisibilityChange: function onVisibilityChange() {
|
8830 | var swiper = this;
|
8831 | var document = getDocument();
|
8832 |
|
8833 | if (document.visibilityState === 'hidden' && swiper.autoplay.running) {
|
8834 | swiper.autoplay.pause();
|
8835 | }
|
8836 |
|
8837 | if (document.visibilityState === 'visible' && swiper.autoplay.paused) {
|
8838 | swiper.autoplay.run();
|
8839 | swiper.autoplay.paused = false;
|
8840 | }
|
8841 | },
|
8842 | onTransitionEnd: function onTransitionEnd(e) {
|
8843 | var swiper = this;
|
8844 | if (!swiper || swiper.destroyed || !swiper.$wrapperEl) return;
|
8845 | if (e.target !== swiper.$wrapperEl[0]) return;
|
8846 | swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd);
|
8847 | swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd);
|
8848 | swiper.autoplay.paused = false;
|
8849 |
|
8850 | if (!swiper.autoplay.running) {
|
8851 | swiper.autoplay.stop();
|
8852 | } else {
|
8853 | swiper.autoplay.run();
|
8854 | }
|
8855 | }
|
8856 | };
|
8857 | var Autoplay$1 = {
|
8858 | name: 'autoplay',
|
8859 | params: {
|
8860 | autoplay: {
|
8861 | enabled: false,
|
8862 | delay: 3000,
|
8863 | waitForTransition: true,
|
8864 | disableOnInteraction: true,
|
8865 | stopOnLastSlide: false,
|
8866 | reverseDirection: false
|
8867 | }
|
8868 | },
|
8869 | create: function create() {
|
8870 | var swiper = this;
|
8871 | bindModuleMethods(swiper, {
|
8872 | autoplay: _extends({}, Autoplay, {
|
8873 | running: false,
|
8874 | paused: false
|
8875 | })
|
8876 | });
|
8877 | },
|
8878 | on: {
|
8879 | init: function init(swiper) {
|
8880 | if (swiper.params.autoplay.enabled) {
|
8881 | swiper.autoplay.start();
|
8882 | var document = getDocument();
|
8883 | document.addEventListener('visibilitychange', swiper.autoplay.onVisibilityChange);
|
8884 | }
|
8885 | },
|
8886 | beforeTransitionStart: function beforeTransitionStart(swiper, speed, internal) {
|
8887 | if (swiper.autoplay.running) {
|
8888 | if (internal || !swiper.params.autoplay.disableOnInteraction) {
|
8889 | swiper.autoplay.pause(speed);
|
8890 | } else {
|
8891 | swiper.autoplay.stop();
|
8892 | }
|
8893 | }
|
8894 | },
|
8895 | sliderFirstMove: function sliderFirstMove(swiper) {
|
8896 | if (swiper.autoplay.running) {
|
8897 | if (swiper.params.autoplay.disableOnInteraction) {
|
8898 | swiper.autoplay.stop();
|
8899 | } else {
|
8900 | swiper.autoplay.pause();
|
8901 | }
|
8902 | }
|
8903 | },
|
8904 | touchEnd: function touchEnd(swiper) {
|
8905 | if (swiper.params.cssMode && swiper.autoplay.paused && !swiper.params.autoplay.disableOnInteraction) {
|
8906 | swiper.autoplay.run();
|
8907 | }
|
8908 | },
|
8909 | destroy: function destroy(swiper) {
|
8910 | if (swiper.autoplay.running) {
|
8911 | swiper.autoplay.stop();
|
8912 | }
|
8913 |
|
8914 | var document = getDocument();
|
8915 | document.removeEventListener('visibilitychange', swiper.autoplay.onVisibilityChange);
|
8916 | }
|
8917 | }
|
8918 | };
|
8919 |
|
8920 | var Fade = {
|
8921 | setTranslate: function setTranslate() {
|
8922 | var swiper = this;
|
8923 | var slides = swiper.slides;
|
8924 |
|
8925 | for (var i = 0; i < slides.length; i += 1) {
|
8926 | var $slideEl = swiper.slides.eq(i);
|
8927 | var offset = $slideEl[0].swiperSlideOffset;
|
8928 | var tx = -offset;
|
8929 | if (!swiper.params.virtualTranslate) tx -= swiper.translate;
|
8930 | var ty = 0;
|
8931 |
|
8932 | if (!swiper.isHorizontal()) {
|
8933 | ty = tx;
|
8934 | tx = 0;
|
8935 | }
|
8936 |
|
8937 | var slideOpacity = swiper.params.fadeEffect.crossFade ? Math.max(1 - Math.abs($slideEl[0].progress), 0) : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0);
|
8938 | $slideEl.css({
|
8939 | opacity: slideOpacity
|
8940 | }).transform("translate3d(" + tx + "px, " + ty + "px, 0px)");
|
8941 | }
|
8942 | },
|
8943 | setTransition: function setTransition(duration) {
|
8944 | var swiper = this;
|
8945 | var slides = swiper.slides,
|
8946 | $wrapperEl = swiper.$wrapperEl;
|
8947 | slides.transition(duration);
|
8948 |
|
8949 | if (swiper.params.virtualTranslate && duration !== 0) {
|
8950 | var eventTriggered = false;
|
8951 | slides.transitionEnd(function () {
|
8952 | if (eventTriggered) return;
|
8953 | if (!swiper || swiper.destroyed) return;
|
8954 | eventTriggered = true;
|
8955 | swiper.animating = false;
|
8956 | var triggerEvents = ['webkitTransitionEnd', 'transitionend'];
|
8957 |
|
8958 | for (var i = 0; i < triggerEvents.length; i += 1) {
|
8959 | $wrapperEl.trigger(triggerEvents[i]);
|
8960 | }
|
8961 | });
|
8962 | }
|
8963 | }
|
8964 | };
|
8965 | var EffectFade = {
|
8966 | name: 'effect-fade',
|
8967 | params: {
|
8968 | fadeEffect: {
|
8969 | crossFade: false
|
8970 | }
|
8971 | },
|
8972 | create: function create() {
|
8973 | var swiper = this;
|
8974 | bindModuleMethods(swiper, {
|
8975 | fadeEffect: _extends({}, Fade)
|
8976 | });
|
8977 | },
|
8978 | on: {
|
8979 | beforeInit: function beforeInit(swiper) {
|
8980 | if (swiper.params.effect !== 'fade') return;
|
8981 | swiper.classNames.push(swiper.params.containerModifierClass + "fade");
|
8982 | var overwriteParams = {
|
8983 | slidesPerView: 1,
|
8984 | slidesPerColumn: 1,
|
8985 | slidesPerGroup: 1,
|
8986 | watchSlidesProgress: true,
|
8987 | spaceBetween: 0,
|
8988 | virtualTranslate: true
|
8989 | };
|
8990 | extend(swiper.params, overwriteParams);
|
8991 | extend(swiper.originalParams, overwriteParams);
|
8992 | },
|
8993 | setTranslate: function setTranslate(swiper) {
|
8994 | if (swiper.params.effect !== 'fade') return;
|
8995 | swiper.fadeEffect.setTranslate();
|
8996 | },
|
8997 | setTransition: function setTransition(swiper, duration) {
|
8998 | if (swiper.params.effect !== 'fade') return;
|
8999 | swiper.fadeEffect.setTransition(duration);
|
9000 | }
|
9001 | }
|
9002 | };
|
9003 |
|
9004 | var Cube = {
|
9005 | setTranslate: function setTranslate() {
|
9006 | var swiper = this;
|
9007 | var $el = swiper.$el,
|
9008 | $wrapperEl = swiper.$wrapperEl,
|
9009 | slides = swiper.slides,
|
9010 | swiperWidth = swiper.width,
|
9011 | swiperHeight = swiper.height,
|
9012 | rtl = swiper.rtlTranslate,
|
9013 | swiperSize = swiper.size,
|
9014 | browser = swiper.browser;
|
9015 | var params = swiper.params.cubeEffect;
|
9016 | var isHorizontal = swiper.isHorizontal();
|
9017 | var isVirtual = swiper.virtual && swiper.params.virtual.enabled;
|
9018 | var wrapperRotate = 0;
|
9019 | var $cubeShadowEl;
|
9020 |
|
9021 | if (params.shadow) {
|
9022 | if (isHorizontal) {
|
9023 | $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow');
|
9024 |
|
9025 | if ($cubeShadowEl.length === 0) {
|
9026 | $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
|
9027 | $wrapperEl.append($cubeShadowEl);
|
9028 | }
|
9029 |
|
9030 | $cubeShadowEl.css({
|
9031 | height: swiperWidth + "px"
|
9032 | });
|
9033 | } else {
|
9034 | $cubeShadowEl = $el.find('.swiper-cube-shadow');
|
9035 |
|
9036 | if ($cubeShadowEl.length === 0) {
|
9037 | $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>');
|
9038 | $el.append($cubeShadowEl);
|
9039 | }
|
9040 | }
|
9041 | }
|
9042 |
|
9043 | for (var i = 0; i < slides.length; i += 1) {
|
9044 | var $slideEl = slides.eq(i);
|
9045 | var slideIndex = i;
|
9046 |
|
9047 | if (isVirtual) {
|
9048 | slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10);
|
9049 | }
|
9050 |
|
9051 | var slideAngle = slideIndex * 90;
|
9052 | var round = Math.floor(slideAngle / 360);
|
9053 |
|
9054 | if (rtl) {
|
9055 | slideAngle = -slideAngle;
|
9056 | round = Math.floor(-slideAngle / 360);
|
9057 | }
|
9058 |
|
9059 | var progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
|
9060 | var tx = 0;
|
9061 | var ty = 0;
|
9062 | var tz = 0;
|
9063 |
|
9064 | if (slideIndex % 4 === 0) {
|
9065 | tx = -round * 4 * swiperSize;
|
9066 | tz = 0;
|
9067 | } else if ((slideIndex - 1) % 4 === 0) {
|
9068 | tx = 0;
|
9069 | tz = -round * 4 * swiperSize;
|
9070 | } else if ((slideIndex - 2) % 4 === 0) {
|
9071 | tx = swiperSize + round * 4 * swiperSize;
|
9072 | tz = swiperSize;
|
9073 | } else if ((slideIndex - 3) % 4 === 0) {
|
9074 | tx = -swiperSize;
|
9075 | tz = 3 * swiperSize + swiperSize * 4 * round;
|
9076 | }
|
9077 |
|
9078 | if (rtl) {
|
9079 | tx = -tx;
|
9080 | }
|
9081 |
|
9082 | if (!isHorizontal) {
|
9083 | ty = tx;
|
9084 | tx = 0;
|
9085 | }
|
9086 |
|
9087 | var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)";
|
9088 |
|
9089 | if (progress <= 1 && progress > -1) {
|
9090 | wrapperRotate = slideIndex * 90 + progress * 90;
|
9091 | if (rtl) wrapperRotate = -slideIndex * 90 - progress * 90;
|
9092 | }
|
9093 |
|
9094 | $slideEl.transform(transform);
|
9095 |
|
9096 | if (params.slideShadows) {
|
9097 |
|
9098 | var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
|
9099 | var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
|
9100 |
|
9101 | if (shadowBefore.length === 0) {
|
9102 | shadowBefore = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>");
|
9103 | $slideEl.append(shadowBefore);
|
9104 | }
|
9105 |
|
9106 | if (shadowAfter.length === 0) {
|
9107 | shadowAfter = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>");
|
9108 | $slideEl.append(shadowAfter);
|
9109 | }
|
9110 |
|
9111 | if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
|
9112 | if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
|
9113 | }
|
9114 | }
|
9115 |
|
9116 | $wrapperEl.css({
|
9117 | '-webkit-transform-origin': "50% 50% -" + swiperSize / 2 + "px",
|
9118 | '-moz-transform-origin': "50% 50% -" + swiperSize / 2 + "px",
|
9119 | '-ms-transform-origin': "50% 50% -" + swiperSize / 2 + "px",
|
9120 | 'transform-origin': "50% 50% -" + swiperSize / 2 + "px"
|
9121 | });
|
9122 |
|
9123 | if (params.shadow) {
|
9124 | if (isHorizontal) {
|
9125 | $cubeShadowEl.transform("translate3d(0px, " + (swiperWidth / 2 + params.shadowOffset) + "px, " + -swiperWidth / 2 + "px) rotateX(90deg) rotateZ(0deg) scale(" + params.shadowScale + ")");
|
9126 | } else {
|
9127 | var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
|
9128 | var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
|
9129 | var scale1 = params.shadowScale;
|
9130 | var scale2 = params.shadowScale / multiplier;
|
9131 | var offset = params.shadowOffset;
|
9132 | $cubeShadowEl.transform("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + (swiperHeight / 2 + offset) + "px, " + -swiperHeight / 2 / scale2 + "px) rotateX(-90deg)");
|
9133 | }
|
9134 | }
|
9135 |
|
9136 | var zFactor = browser.isSafari || browser.isWebView ? -swiperSize / 2 : 0;
|
9137 | $wrapperEl.transform("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)");
|
9138 | },
|
9139 | setTransition: function setTransition(duration) {
|
9140 | var swiper = this;
|
9141 | var $el = swiper.$el,
|
9142 | slides = swiper.slides;
|
9143 | slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
|
9144 |
|
9145 | if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) {
|
9146 | $el.find('.swiper-cube-shadow').transition(duration);
|
9147 | }
|
9148 | }
|
9149 | };
|
9150 | var EffectCube = {
|
9151 | name: 'effect-cube',
|
9152 | params: {
|
9153 | cubeEffect: {
|
9154 | slideShadows: true,
|
9155 | shadow: true,
|
9156 | shadowOffset: 20,
|
9157 | shadowScale: 0.94
|
9158 | }
|
9159 | },
|
9160 | create: function create() {
|
9161 | var swiper = this;
|
9162 | bindModuleMethods(swiper, {
|
9163 | cubeEffect: _extends({}, Cube)
|
9164 | });
|
9165 | },
|
9166 | on: {
|
9167 | beforeInit: function beforeInit(swiper) {
|
9168 | if (swiper.params.effect !== 'cube') return;
|
9169 | swiper.classNames.push(swiper.params.containerModifierClass + "cube");
|
9170 | swiper.classNames.push(swiper.params.containerModifierClass + "3d");
|
9171 | var overwriteParams = {
|
9172 | slidesPerView: 1,
|
9173 | slidesPerColumn: 1,
|
9174 | slidesPerGroup: 1,
|
9175 | watchSlidesProgress: true,
|
9176 | resistanceRatio: 0,
|
9177 | spaceBetween: 0,
|
9178 | centeredSlides: false,
|
9179 | virtualTranslate: true
|
9180 | };
|
9181 | extend(swiper.params, overwriteParams);
|
9182 | extend(swiper.originalParams, overwriteParams);
|
9183 | },
|
9184 | setTranslate: function setTranslate(swiper) {
|
9185 | if (swiper.params.effect !== 'cube') return;
|
9186 | swiper.cubeEffect.setTranslate();
|
9187 | },
|
9188 | setTransition: function setTransition(swiper, duration) {
|
9189 | if (swiper.params.effect !== 'cube') return;
|
9190 | swiper.cubeEffect.setTransition(duration);
|
9191 | }
|
9192 | }
|
9193 | };
|
9194 |
|
9195 | var Flip = {
|
9196 | setTranslate: function setTranslate() {
|
9197 | var swiper = this;
|
9198 | var slides = swiper.slides,
|
9199 | rtl = swiper.rtlTranslate;
|
9200 |
|
9201 | for (var i = 0; i < slides.length; i += 1) {
|
9202 | var $slideEl = slides.eq(i);
|
9203 | var progress = $slideEl[0].progress;
|
9204 |
|
9205 | if (swiper.params.flipEffect.limitRotation) {
|
9206 | progress = Math.max(Math.min($slideEl[0].progress, 1), -1);
|
9207 | }
|
9208 |
|
9209 | var offset = $slideEl[0].swiperSlideOffset;
|
9210 | var rotate = -180 * progress;
|
9211 | var rotateY = rotate;
|
9212 | var rotateX = 0;
|
9213 | var tx = -offset;
|
9214 | var ty = 0;
|
9215 |
|
9216 | if (!swiper.isHorizontal()) {
|
9217 | ty = tx;
|
9218 | tx = 0;
|
9219 | rotateX = -rotateY;
|
9220 | rotateY = 0;
|
9221 | } else if (rtl) {
|
9222 | rotateY = -rotateY;
|
9223 | }
|
9224 |
|
9225 | $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length;
|
9226 |
|
9227 | if (swiper.params.flipEffect.slideShadows) {
|
9228 |
|
9229 | var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
|
9230 | var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
|
9231 |
|
9232 | if (shadowBefore.length === 0) {
|
9233 | shadowBefore = $("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>");
|
9234 | $slideEl.append(shadowBefore);
|
9235 | }
|
9236 |
|
9237 | if (shadowAfter.length === 0) {
|
9238 | shadowAfter = $("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>");
|
9239 | $slideEl.append(shadowAfter);
|
9240 | }
|
9241 |
|
9242 | if (shadowBefore.length) shadowBefore[0].style.opacity = Math.max(-progress, 0);
|
9243 | if (shadowAfter.length) shadowAfter[0].style.opacity = Math.max(progress, 0);
|
9244 | }
|
9245 |
|
9246 | $slideEl.transform("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)");
|
9247 | }
|
9248 | },
|
9249 | setTransition: function setTransition(duration) {
|
9250 | var swiper = this;
|
9251 | var slides = swiper.slides,
|
9252 | activeIndex = swiper.activeIndex,
|
9253 | $wrapperEl = swiper.$wrapperEl;
|
9254 | slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
|
9255 |
|
9256 | if (swiper.params.virtualTranslate && duration !== 0) {
|
9257 | var eventTriggered = false;
|
9258 |
|
9259 | slides.eq(activeIndex).transitionEnd(function onTransitionEnd() {
|
9260 | if (eventTriggered) return;
|
9261 | if (!swiper || swiper.destroyed) return;
|
9262 |
|
9263 | eventTriggered = true;
|
9264 | swiper.animating = false;
|
9265 | var triggerEvents = ['webkitTransitionEnd', 'transitionend'];
|
9266 |
|
9267 | for (var i = 0; i < triggerEvents.length; i += 1) {
|
9268 | $wrapperEl.trigger(triggerEvents[i]);
|
9269 | }
|
9270 | });
|
9271 | }
|
9272 | }
|
9273 | };
|
9274 | var EffectFlip = {
|
9275 | name: 'effect-flip',
|
9276 | params: {
|
9277 | flipEffect: {
|
9278 | slideShadows: true,
|
9279 | limitRotation: true
|
9280 | }
|
9281 | },
|
9282 | create: function create() {
|
9283 | var swiper = this;
|
9284 | bindModuleMethods(swiper, {
|
9285 | flipEffect: _extends({}, Flip)
|
9286 | });
|
9287 | },
|
9288 | on: {
|
9289 | beforeInit: function beforeInit(swiper) {
|
9290 | if (swiper.params.effect !== 'flip') return;
|
9291 | swiper.classNames.push(swiper.params.containerModifierClass + "flip");
|
9292 | swiper.classNames.push(swiper.params.containerModifierClass + "3d");
|
9293 | var overwriteParams = {
|
9294 | slidesPerView: 1,
|
9295 | slidesPerColumn: 1,
|
9296 | slidesPerGroup: 1,
|
9297 | watchSlidesProgress: true,
|
9298 | spaceBetween: 0,
|
9299 | virtualTranslate: true
|
9300 | };
|
9301 | extend(swiper.params, overwriteParams);
|
9302 | extend(swiper.originalParams, overwriteParams);
|
9303 | },
|
9304 | setTranslate: function setTranslate(swiper) {
|
9305 | if (swiper.params.effect !== 'flip') return;
|
9306 | swiper.flipEffect.setTranslate();
|
9307 | },
|
9308 | setTransition: function setTransition(swiper, duration) {
|
9309 | if (swiper.params.effect !== 'flip') return;
|
9310 | swiper.flipEffect.setTransition(duration);
|
9311 | }
|
9312 | }
|
9313 | };
|
9314 |
|
9315 | var Coverflow = {
|
9316 | setTranslate: function setTranslate() {
|
9317 | var swiper = this;
|
9318 | var swiperWidth = swiper.width,
|
9319 | swiperHeight = swiper.height,
|
9320 | slides = swiper.slides,
|
9321 | slidesSizesGrid = swiper.slidesSizesGrid;
|
9322 | var params = swiper.params.coverflowEffect;
|
9323 | var isHorizontal = swiper.isHorizontal();
|
9324 | var transform = swiper.translate;
|
9325 | var center = isHorizontal ? -transform + swiperWidth / 2 : -transform + swiperHeight / 2;
|
9326 | var rotate = isHorizontal ? params.rotate : -params.rotate;
|
9327 | var translate = params.depth;
|
9328 |
|
9329 | for (var i = 0, length = slides.length; i < length; i += 1) {
|
9330 | var $slideEl = slides.eq(i);
|
9331 | var slideSize = slidesSizesGrid[i];
|
9332 | var slideOffset = $slideEl[0].swiperSlideOffset;
|
9333 | var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * params.modifier;
|
9334 | var rotateY = isHorizontal ? rotate * offsetMultiplier : 0;
|
9335 | var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier;
|
9336 |
|
9337 | var translateZ = -translate * Math.abs(offsetMultiplier);
|
9338 | var stretch = params.stretch;
|
9339 |
|
9340 | if (typeof stretch === 'string' && stretch.indexOf('%') !== -1) {
|
9341 | stretch = parseFloat(params.stretch) / 100 * slideSize;
|
9342 | }
|
9343 |
|
9344 | var translateY = isHorizontal ? 0 : stretch * offsetMultiplier;
|
9345 | var translateX = isHorizontal ? stretch * offsetMultiplier : 0;
|
9346 | var scale = 1 - (1 - params.scale) * Math.abs(offsetMultiplier);
|
9347 |
|
9348 | if (Math.abs(translateX) < 0.001) translateX = 0;
|
9349 | if (Math.abs(translateY) < 0.001) translateY = 0;
|
9350 | if (Math.abs(translateZ) < 0.001) translateZ = 0;
|
9351 | if (Math.abs(rotateY) < 0.001) rotateY = 0;
|
9352 | if (Math.abs(rotateX) < 0.001) rotateX = 0;
|
9353 | if (Math.abs(scale) < 0.001) scale = 0;
|
9354 | var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg) scale(" + scale + ")";
|
9355 | $slideEl.transform(slideTransform);
|
9356 | $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
|
9357 |
|
9358 | if (params.slideShadows) {
|
9359 |
|
9360 | var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top');
|
9361 | var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom');
|
9362 |
|
9363 | if ($shadowBeforeEl.length === 0) {
|
9364 | $shadowBeforeEl = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>");
|
9365 | $slideEl.append($shadowBeforeEl);
|
9366 | }
|
9367 |
|
9368 | if ($shadowAfterEl.length === 0) {
|
9369 | $shadowAfterEl = $("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>");
|
9370 | $slideEl.append($shadowAfterEl);
|
9371 | }
|
9372 |
|
9373 | if ($shadowBeforeEl.length) $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0;
|
9374 | if ($shadowAfterEl.length) $shadowAfterEl[0].style.opacity = -offsetMultiplier > 0 ? -offsetMultiplier : 0;
|
9375 | }
|
9376 | }
|
9377 | },
|
9378 | setTransition: function setTransition(duration) {
|
9379 | var swiper = this;
|
9380 | swiper.slides.transition(duration).find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left').transition(duration);
|
9381 | }
|
9382 | };
|
9383 | var EffectCoverflow = {
|
9384 | name: 'effect-coverflow',
|
9385 | params: {
|
9386 | coverflowEffect: {
|
9387 | rotate: 50,
|
9388 | stretch: 0,
|
9389 | depth: 100,
|
9390 | scale: 1,
|
9391 | modifier: 1,
|
9392 | slideShadows: true
|
9393 | }
|
9394 | },
|
9395 | create: function create() {
|
9396 | var swiper = this;
|
9397 | bindModuleMethods(swiper, {
|
9398 | coverflowEffect: _extends({}, Coverflow)
|
9399 | });
|
9400 | },
|
9401 | on: {
|
9402 | beforeInit: function beforeInit(swiper) {
|
9403 | if (swiper.params.effect !== 'coverflow') return;
|
9404 | swiper.classNames.push(swiper.params.containerModifierClass + "coverflow");
|
9405 | swiper.classNames.push(swiper.params.containerModifierClass + "3d");
|
9406 | swiper.params.watchSlidesProgress = true;
|
9407 | swiper.originalParams.watchSlidesProgress = true;
|
9408 | },
|
9409 | setTranslate: function setTranslate(swiper) {
|
9410 | if (swiper.params.effect !== 'coverflow') return;
|
9411 | swiper.coverflowEffect.setTranslate();
|
9412 | },
|
9413 | setTransition: function setTransition(swiper, duration) {
|
9414 | if (swiper.params.effect !== 'coverflow') return;
|
9415 | swiper.coverflowEffect.setTransition(duration);
|
9416 | }
|
9417 | }
|
9418 | };
|
9419 |
|
9420 | var Thumbs = {
|
9421 | init: function init() {
|
9422 | var swiper = this;
|
9423 | var thumbsParams = swiper.params.thumbs;
|
9424 | if (swiper.thumbs.initialized) return false;
|
9425 | swiper.thumbs.initialized = true;
|
9426 | var SwiperClass = swiper.constructor;
|
9427 |
|
9428 | if (thumbsParams.swiper instanceof SwiperClass) {
|
9429 | swiper.thumbs.swiper = thumbsParams.swiper;
|
9430 | extend(swiper.thumbs.swiper.originalParams, {
|
9431 | watchSlidesProgress: true,
|
9432 | slideToClickedSlide: false
|
9433 | });
|
9434 | extend(swiper.thumbs.swiper.params, {
|
9435 | watchSlidesProgress: true,
|
9436 | slideToClickedSlide: false
|
9437 | });
|
9438 | } else if (isObject(thumbsParams.swiper)) {
|
9439 | swiper.thumbs.swiper = new SwiperClass(extend({}, thumbsParams.swiper, {
|
9440 | watchSlidesVisibility: true,
|
9441 | watchSlidesProgress: true,
|
9442 | slideToClickedSlide: false
|
9443 | }));
|
9444 | swiper.thumbs.swiperCreated = true;
|
9445 | }
|
9446 |
|
9447 | swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass);
|
9448 | swiper.thumbs.swiper.on('tap', swiper.thumbs.onThumbClick);
|
9449 | return true;
|
9450 | },
|
9451 | onThumbClick: function onThumbClick() {
|
9452 | var swiper = this;
|
9453 | var thumbsSwiper = swiper.thumbs.swiper;
|
9454 | if (!thumbsSwiper) return;
|
9455 | var clickedIndex = thumbsSwiper.clickedIndex;
|
9456 | var clickedSlide = thumbsSwiper.clickedSlide;
|
9457 | if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) return;
|
9458 | if (typeof clickedIndex === 'undefined' || clickedIndex === null) return;
|
9459 | var slideToIndex;
|
9460 |
|
9461 | if (thumbsSwiper.params.loop) {
|
9462 | slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10);
|
9463 | } else {
|
9464 | slideToIndex = clickedIndex;
|
9465 | }
|
9466 |
|
9467 | if (swiper.params.loop) {
|
9468 | var currentIndex = swiper.activeIndex;
|
9469 |
|
9470 | if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) {
|
9471 | swiper.loopFix();
|
9472 |
|
9473 | swiper._clientLeft = swiper.$wrapperEl[0].clientLeft;
|
9474 | currentIndex = swiper.activeIndex;
|
9475 | }
|
9476 |
|
9477 | var prevIndex = swiper.slides.eq(currentIndex).prevAll("[data-swiper-slide-index=\"" + slideToIndex + "\"]").eq(0).index();
|
9478 | var nextIndex = swiper.slides.eq(currentIndex).nextAll("[data-swiper-slide-index=\"" + slideToIndex + "\"]").eq(0).index();
|
9479 | if (typeof prevIndex === 'undefined') slideToIndex = nextIndex;else if (typeof nextIndex === 'undefined') slideToIndex = prevIndex;else if (nextIndex - currentIndex < currentIndex - prevIndex) slideToIndex = nextIndex;else slideToIndex = prevIndex;
|
9480 | }
|
9481 |
|
9482 | swiper.slideTo(slideToIndex);
|
9483 | },
|
9484 | update: function update(initial) {
|
9485 | var swiper = this;
|
9486 | var thumbsSwiper = swiper.thumbs.swiper;
|
9487 | if (!thumbsSwiper) return;
|
9488 | var slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' ? thumbsSwiper.slidesPerViewDynamic() : thumbsSwiper.params.slidesPerView;
|
9489 | var autoScrollOffset = swiper.params.thumbs.autoScrollOffset;
|
9490 | var useOffset = autoScrollOffset && !thumbsSwiper.params.loop;
|
9491 |
|
9492 | if (swiper.realIndex !== thumbsSwiper.realIndex || useOffset) {
|
9493 | var currentThumbsIndex = thumbsSwiper.activeIndex;
|
9494 | var newThumbsIndex;
|
9495 | var direction;
|
9496 |
|
9497 | if (thumbsSwiper.params.loop) {
|
9498 | if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) {
|
9499 | thumbsSwiper.loopFix();
|
9500 |
|
9501 | thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft;
|
9502 | currentThumbsIndex = thumbsSwiper.activeIndex;
|
9503 | }
|
9504 |
|
9505 |
|
9506 | var prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll("[data-swiper-slide-index=\"" + swiper.realIndex + "\"]").eq(0).index();
|
9507 | var nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll("[data-swiper-slide-index=\"" + swiper.realIndex + "\"]").eq(0).index();
|
9508 | if (typeof prevThumbsIndex === 'undefined') newThumbsIndex = nextThumbsIndex;else if (typeof nextThumbsIndex === 'undefined') newThumbsIndex = prevThumbsIndex;else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) newThumbsIndex = currentThumbsIndex;else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) newThumbsIndex = nextThumbsIndex;else newThumbsIndex = prevThumbsIndex;
|
9509 | direction = swiper.activeIndex > swiper.previousIndex ? 'next' : 'prev';
|
9510 | } else {
|
9511 | newThumbsIndex = swiper.realIndex;
|
9512 | direction = newThumbsIndex > swiper.previousIndex ? 'next' : 'prev';
|
9513 | }
|
9514 |
|
9515 | if (useOffset) {
|
9516 | newThumbsIndex += direction === 'next' ? autoScrollOffset : -1 * autoScrollOffset;
|
9517 | }
|
9518 |
|
9519 | if (thumbsSwiper.visibleSlidesIndexes && thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) {
|
9520 | if (thumbsSwiper.params.centeredSlides) {
|
9521 | if (newThumbsIndex > currentThumbsIndex) {
|
9522 | newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1;
|
9523 | } else {
|
9524 | newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1;
|
9525 | }
|
9526 | } else if (newThumbsIndex > currentThumbsIndex) {
|
9527 | newThumbsIndex = newThumbsIndex - slidesPerView + 1;
|
9528 | }
|
9529 |
|
9530 | thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined);
|
9531 | }
|
9532 | }
|
9533 |
|
9534 |
|
9535 | var thumbsToActivate = 1;
|
9536 | var thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass;
|
9537 |
|
9538 | if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) {
|
9539 | thumbsToActivate = swiper.params.slidesPerView;
|
9540 | }
|
9541 |
|
9542 | if (!swiper.params.thumbs.multipleActiveThumbs) {
|
9543 | thumbsToActivate = 1;
|
9544 | }
|
9545 |
|
9546 | thumbsToActivate = Math.floor(thumbsToActivate);
|
9547 | thumbsSwiper.slides.removeClass(thumbActiveClass);
|
9548 |
|
9549 | if (thumbsSwiper.params.loop || thumbsSwiper.params.virtual && thumbsSwiper.params.virtual.enabled) {
|
9550 | for (var i = 0; i < thumbsToActivate; i += 1) {
|
9551 | thumbsSwiper.$wrapperEl.children("[data-swiper-slide-index=\"" + (swiper.realIndex + i) + "\"]").addClass(thumbActiveClass);
|
9552 | }
|
9553 | } else {
|
9554 | for (var _i = 0; _i < thumbsToActivate; _i += 1) {
|
9555 | thumbsSwiper.slides.eq(swiper.realIndex + _i).addClass(thumbActiveClass);
|
9556 | }
|
9557 | }
|
9558 | }
|
9559 | };
|
9560 | var Thumbs$1 = {
|
9561 | name: 'thumbs',
|
9562 | params: {
|
9563 | thumbs: {
|
9564 | swiper: null,
|
9565 | multipleActiveThumbs: true,
|
9566 | autoScrollOffset: 0,
|
9567 | slideThumbActiveClass: 'swiper-slide-thumb-active',
|
9568 | thumbsContainerClass: 'swiper-container-thumbs'
|
9569 | }
|
9570 | },
|
9571 | create: function create() {
|
9572 | var swiper = this;
|
9573 | bindModuleMethods(swiper, {
|
9574 | thumbs: _extends({
|
9575 | swiper: null,
|
9576 | initialized: false
|
9577 | }, Thumbs)
|
9578 | });
|
9579 | },
|
9580 | on: {
|
9581 | beforeInit: function beforeInit(swiper) {
|
9582 | var thumbs = swiper.params.thumbs;
|
9583 | if (!thumbs || !thumbs.swiper) return;
|
9584 | swiper.thumbs.init();
|
9585 | swiper.thumbs.update(true);
|
9586 | },
|
9587 | slideChange: function slideChange(swiper) {
|
9588 | if (!swiper.thumbs.swiper) return;
|
9589 | swiper.thumbs.update();
|
9590 | },
|
9591 | update: function update(swiper) {
|
9592 | if (!swiper.thumbs.swiper) return;
|
9593 | swiper.thumbs.update();
|
9594 | },
|
9595 | resize: function resize(swiper) {
|
9596 | if (!swiper.thumbs.swiper) return;
|
9597 | swiper.thumbs.update();
|
9598 | },
|
9599 | observerUpdate: function observerUpdate(swiper) {
|
9600 | if (!swiper.thumbs.swiper) return;
|
9601 | swiper.thumbs.update();
|
9602 | },
|
9603 | setTransition: function setTransition(swiper, duration) {
|
9604 | var thumbsSwiper = swiper.thumbs.swiper;
|
9605 | if (!thumbsSwiper) return;
|
9606 | thumbsSwiper.setTransition(duration);
|
9607 | },
|
9608 | beforeDestroy: function beforeDestroy(swiper) {
|
9609 | var thumbsSwiper = swiper.thumbs.swiper;
|
9610 | if (!thumbsSwiper) return;
|
9611 |
|
9612 | if (swiper.thumbs.swiperCreated && thumbsSwiper) {
|
9613 | thumbsSwiper.destroy();
|
9614 | }
|
9615 | }
|
9616 | }
|
9617 | };
|
9618 |
|
9619 |
|
9620 | var components = [Virtual$1, Keyboard$1, Mousewheel$1, Navigation$1, Pagination$1, Scrollbar$1, Parallax$1, Zoom$1, Lazy$1, Controller$1, A11y$1, History$1, HashNavigation$1, Autoplay$1, EffectFade, EffectCube, EffectFlip, EffectCoverflow, Thumbs$1];
|
9621 | Swiper.use(components);
|
9622 |
|
9623 | return Swiper;
|
9624 |
|
9625 | })));
|
9626 |
|