You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

7629 lines
253 KiB

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