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