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