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