jQuery 滚动条 滚动到底部(下拉到底部) 加载数据(触发事件、处理逻辑)、分页加载数据
1、针对浏览器整个窗口滚动 主要代码:
1 <script type="text/javascript"> 2 var pageNum = 1; 3 function GetProductListPageFun() { //请求获取数据 4 5 } 6 $(window).scroll(function () { //分页 7 if ($(window).scrollTop() + $(window).height() == $(document).height()) { //滚动到底部时 8 pageNum += 1; 9 GetProductListPageFun(); 10 } 11 }); 12 </script>
2、一个页面div 内 的滚动条下拉 到底部,触发事件(加载更多内容) 完整代码(注意:div 必须出现滚动条 , 此方法才有效):
1 <!DOCTYPE=html> 2 <html> 3 <head> 4 <script src="../Js/jquery-1.9.1.min.js" type="text/javascript"></script> 5 </head> 6 <body> 7 <div> 8 测试 div 滚动条下拉掉浏览器底部加载</div> 9 <div class="scrollDiv" style="height: 500px; overflow: auto;"> 10 <div class="childDiv" style='border: 1px solid Black; margin-top: 20px; color: Green; height: 600px'> 11 </div> 12 </div> 13 </body> 14 <script type="text/javascript"> 15 //关键代码 注意:div 必须出现滚动条 , 此方法才有效 16 $(document).ready(function () { 17 $(".scrollDiv").unbind("scroll").on("scroll", function (e) { //注意:含有css类名为:scrollDiv 的div 要出现 滚动条 此函数(scroll)才会触发 18 var sum = this.scrollHeight; //滚动条距顶部距离(页面超出窗口的高度) 19 var $obj = $(this); 20 if (sum <= $obj.scrollTop() + $obj.height()) { //判断滚动条是否 到达了 底部 , $obj.scrollTop():滚动条距顶部距离(页面超出窗口的高度) ,$obj.height():当前(div)滚动窗口的高度 21 //div 的滚动条 滚动到浏览器底部 时 需要处理的逻辑 22 //$(".scrollDiv").append($(".childDiv").clone()); 23 console.log("滚动条到达浏览器底部"); 24 alert("滚动条到达浏览器底部"); 25 } 26 }); 27 }); 28 </script> 29 </html>
3、一个页面 有多个div(tab)可以 切换 ,而且 div 内 的滚动条下拉 到底部,触发事件(加载更多内容) 完整代码(注意:div 必须出现滚动条 , 此方法才有效):
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>测试 div 滚动下拉加载</title> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 <meta name="apple-mobile-web-app-capable" content="yes"> 8 <meta name="apple-mobile-web-app-status-bar-style" content="black"> 9 <meta content="telephone=no" name="format-detection"> 10 <meta content="on" http-equiv="x-dns-prefetch-control"> 11 <script type="text/javascript" src="/js/jquery-1.9.1.min.js"></script> 12 <script type="text/javascript"> 13 //关键代码 注意:div 必须出现滚动条 , 此方法才有效 14 $(document).ready(function () { 15 $(".content-slide").height(parseFloat($(window).height()) - parseFloat($(".commenthead").height()) - 20); //设置高度让div 出现滚动条 16 $(".content-slide").unbind("scroll").on("scroll", function (e) { //注意:含有css类名为: content-slide 的div 要出现 滚动条 此函数(scroll)才会触发 17 var sum = this.scrollHeight; //滚动条距顶部距离(页面超出窗口的高度) 18 var $obj = $(this); 19 if (sum <= $obj.scrollTop() + $obj.height()) { //判断滚动条是否 到达了 底部 , $obj.scrollTop():滚动条距顶部距离(页面超出窗口的高度) ,$obj.height():当前(div)滚动窗口的高度 20 //div 的滚动条 滚动到浏览器底部 时 需要处理的逻辑 21 console.log("div_" + $(this).attr("status") + "滚动条到达浏览器底部"); 22 alert("div_" + $obj.attr("status") + "滚动条到达浏览器底部"); 23 } 24 }); 25 }); 26 </script> 27 </head> 28 <body> 29 <header class="commenthead whiteback"> 30 网页头部:(下拉 加载 更多) 31 </header> 32 <article class="commentWrap nonebottom"> 33 <div class="tabs"> 34 <a href="JavaScript:;" class="active">div_1</a> 35 <a href="JavaScript:;" >div_2</a> 36 <a href="JavaScript:;" >div_3</a> 37 <a href="JavaScript:;" >div_4</a> 38 </div> 39 <div class="swiper-container"> 40 <div class="swiper-wrapper" > 41 <div class="swiper-slide swiper-slide-visible swiper-slide-active"> 42 <div class="content-slide tab1" status="1" style="height:200px;overflow:auto;" > 43 <div class="order_li"> 44 <img src="../Images/0.jpg" /> 45 </div> 46 <div class="order_li"> 47 <img src="../Images/1.jpg" /> 48 </div> 49 <div class="order_li"> 50 <img src="../Images/2.jpg" /> 51 </div> 52 </div> 53 </div> 54 <div class="swiper-slide" > 55 <div class="content-slide" status="2" style="height:200px;overflow:auto;" > 56 <div class="order_li"> 57 <img src="../Images/3.jpg" /> 58 </div> 59 <div class="order_li"> 60 <img src="../Images/4.jpg" /> 61 </div> 62 <div class="order_li"> 63 <img src="../Images/5.jpg" /> 64 </div> 65 </div> 66 </div> 67 <div class="swiper-slide" > 68 <div class="content-slide" status="3" style="height:200px;overflow:auto;" > 69 <div class="order_li"> 70 <img src="../Images/0.jpg" /> 71 </div> 72 <div class="order_li"> 73 <img src="../Images/1.jpg" /> 74 </div> 75 <div class="order_li"> 76 <img src="../Images/2.jpg" /> 77 </div> 78 </div> 79 </div> 80 <div class="swiper-slide" > 81 <div class="content-slide" status="4" style="height:200px;overflow:auto;" > 82 <div class="order_li"> 83 <img src="../Images/3.jpg" /> 84 </div> 85 <div class="order_li"> 86 <img src="../Images/5.jpg" /> 87 </div> 88 <div class="order_li"> 89 <img src="../Images/4.jpg" /> 90 </div> 91 </div> 92 </div> 93 </div> 94 </div> 95 </article> 96 <style type="text/css"> 97 a 98 { 99 color: #333; 100 text-decoration: none; 101 } 102 .tabs 103 { 104 height: 35px; 105 background: #fff; 106 border-bottom: #F0F2F5 thin solid; 107 box-sizing: border-box; 108 display: block; 109 width: 100%; 110 } 111 .tabs a 112 { 113 display: inline-block; 114 float: left; 115 width: 20%; 116 margin: 0 2.5%; 117 text-align: center; 118 line-height: 35px; 119 font-size: 14px; /*padding: 0 10px;*/ 120 box-sizing: border-box; 121 } 122 .tabs a.active 123 { 124 border-bottom: #E23030 2px solid; 125 color: #FF5500; 126 box-sizing: border-box; 127 } 128 .swiper-container 129 { 130 min-height: 400px; 131 width: 100%; 132 padding-bottom: 20px; 133 } 134 .swiper-slide 135 { 136 /*height: 325px;*/ 137 width: 100%; /*background: none;*/ /*color: #fff;*/ 138 } 139 .swiper-container 140 { 141 margin: 0 auto; 142 position: relative; 143 overflow: hidden; 144 -webkit-backface-visibility: hidden; 145 -moz-backface-visibility: hidden; 146 -ms-backface-visibility: hidden; 147 -o-backface-visibility: hidden; 148 backface-visibility: hidden; /* Fix of Webkit flickering */ 149 z-index: 1; 150 } 151 .swiper-wrapper 152 { 153 position: relative; 154 width: 100%; 155 -webkit-transition-property: -webkit-transform, left, top; 156 -webkit-transition-duration: 0s; 157 -webkit-transform: translate3d(0px, 0, 0); 158 -webkit-transition-timing-function: ease; 159 -moz-transition-property: -moz-transform, left, top; 160 -moz-transition-duration: 0s; 161 -moz-transform: translate3d(0px, 0, 0); 162 -moz-transition-timing-function: ease; 163 -o-transition-property: -o-transform, left, top; 164 -o-transition-duration: 0s; 165 -o-transform: translate3d(0px, 0, 0); 166 -o-transition-timing-function: ease; 167 -o-transform: translate(0px, 0px); 168 -ms-transition-property: -ms-transform, left, top; 169 -ms-transition-duration: 0s; 170 -ms-transform: translate3d(0px, 0, 0); 171 -ms-transition-timing-function: ease; 172 transition-property: transform, left, top; 173 transition-duration: 0s; 174 transform: translate3d(0px, 0, 0); 175 transition-timing-function: ease; 176 -webkit-box-sizing: content-box; 177 -moz-box-sizing: content-box; 178 box-sizing: content-box; 179 } 180 .swiper-free-mode > .swiper-wrapper 181 { 182 -webkit-transition-timing-function: ease-out; 183 -moz-transition-timing-function: ease-out; 184 -ms-transition-timing-function: ease-out; 185 -o-transition-timing-function: ease-out; 186 transition-timing-function: ease-out; 187 margin: 0 auto; 188 } 189 .swiper-slide 190 { 191 float: left; 192 -webkit-box-sizing: content-box; 193 -moz-box-sizing: content-box; /*box-sizing: content-box;*/ 194 } 195 .order_li 196 { 197 margin-bottom: 7px; 198 } 199 .order_li .cart_main_li 200 { 201 background: none !important; 202 margin-top: 0px; 203 padding-top: 3px; 204 padding-bottom: 3px; 205 } 206 .order_li .cart_main_right 207 { 208 width: 60%; 209 } 210 .order_li .cart_main_left 211 { 212 text-align: center; 213 width: 15%; 214 text-align: right; 215 padding-left: 5px; 216 box-sizing: border-box; 217 } 218 .order_li > p 219 { 220 line-height: 32px; 221 background: #fff; 222 height: 32px; 223 text-align: right; 224 padding: 0 10px; 225 } 226 .order_li > p:first-of-type 227 { 228 color: #FF5500; 229 } 230 .order_day 231 { 232 width: 60px; 233 text-align: center; 234 background: #E23030; 235 color: #fff; 236 line-height: 20px; 237 } 238 .order_li p button 239 { 240 border: #ccc thin solid; 241 background: #fff; 242 height: 28px; 243 padding: 0 10px; 244 } 245 .order_li .cart_main_left .old_price 246 { 247 text-decoration: line-through; 248 color: #CCCCCC; 249 } 250 .order_null 251 { 252 text-align: center; 253 margin: 70px 0; 254 } 255 .order_null img 256 { 257 width: 100px; 258 } 259 .order_null p:first-of-type 260 { 261 margin-top: 20px; 262 font-size: 16px; 263 color: #000; 264 } 265 /***************订单详情********************/.orderdetail 266 { 267 padding: 10px; 268 background: #fff; 269 line-height: 22px; 270 margin-bottom: 8px; 271 } 272 .orderdetail_add 273 { 274 padding-left: 20px; 275 background: url(../img/52.png) no-repeat left; 276 background-size: 15px; 277 } 278 .orderdetail_mess 279 { 280 padding: 10px; 281 background: #fff; 282 line-height: 18px; 283 } 284 .otherfoot .order_foot 285 { 286 text-align: left; 287 float: left; 288 width: 100px; 289 padding: 5px; 290 } 291 .order_foot_bt button 292 { 293 border: #ccc thin solid; 294 background: #fff; 295 height: 35px; 296 margin: 7px 10px 5px 0; 297 padding: 0 12px; 298 } 299 </style> 300 <script type="text/javascript"> 301 /* 302 * Swiper 2.7.0 303 * Mobile touch slider and framework with hardware accelerated transitions 304 * 305 * http://www.idangero.us/sliders/swiper/ 306 * 307 * Copyright 2010-2014, Vladimir Kharlampidi 308 * The iDangero.us 309 * http://www.idangero.us/ 310 * 311 * Licensed under GPL & MIT 312 * 313 * Released on: August 30, 2014 314 */ 315 var Swiper = function (a, b) { 316 "use strict"; 317 318 function c(a, b) { 319 return document.querySelectorAll ? (b || document).querySelectorAll(a) : jQuery(a, b) 320 } 321 322 function d(a) { 323 return "[object Array]" === Object.prototype.toString.apply(a) ? !0 : !1 324 } 325 326 function e() { 327 var a = F - I; 328 return b.freeMode && (a = F - I), b.slidesPerView > C.slides.length && !b.centeredSlides && (a = 0), 0 > a && (a = 0), a 329 } 330 331 function f() { 332 function a(a) { 333 var c = new Image; 334 c.onload = function () { 335 "undefined" != typeof C && null !== C && (void 0 !== C.imagesLoaded && C.imagesLoaded++, C.imagesLoaded === C.imagesToLoad.length && (C.reInit(), b.onImagesReady && C.fireCallback(b.onImagesReady, C))) 336 }, c.src = a 337 } 338 var d = C.h.addEventListener, 339 e = "wrapper" === b.eventTarget ? C.wrapper : C.container; 340 if (C.browser.ie10 || C.browser.ie11 ? (d(e, C.touchEvents.touchStart, p), d(document, C.touchEvents.touchMove, q), d(document, C.touchEvents.touchEnd, r)) : (C.support.touch && (d(e, "touchstart", p), d(e, "touchmove", q), d(e, "touchend", r)), b.simulateTouch && (d(e, "mousedown", p), d(document, "mousemove", q), d(document, "mouseup", r))), b.autoResize && d(window, "resize", C.resizeFix), g(), C._wheelEvent = !1, b.mousewheelControl) { 341 if (void 0 !== document.onmousewheel && (C._wheelEvent = "mousewheel"), !C._wheelEvent) try { 342 new WheelEvent("wheel"), C._wheelEvent = "wheel" 343 } catch (f) { } 344 C._wheelEvent || (C._wheelEvent = "DOMMouseScroll"), C._wheelEvent && d(C.container, C._wheelEvent, j) 345 } 346 if (b.keyboardControl && d(document, "keydown", i), b.updateOnImagesReady) { 347 C.imagesToLoad = c("img", C.container); 348 for (var h = 0; h < C.imagesToLoad.length; h++) a(C.imagesToLoad[h].getAttribute("src")) 349 } 350 } 351 352 function g() { 353 var a, d = C.h.addEventListener; 354 if (b.preventLinks) { 355 var e = c("a", C.container); 356 for (a = 0; a < e.length; a++) d(e[a], "click", n) 357 } 358 if (b.releaseFormElements) { 359 var f = c("input, textarea, select", C.container); 360 for (a = 0; a < f.length; a++) d(f[a], C.touchEvents.touchStart, o, !0) 361 } 362 if (b.onSlideClick) 363 for (a = 0; a < C.slides.length; a++) d(C.slides[a], "click", k); 364 if (b.onSlideTouch) 365 for (a = 0; a < C.slides.length; a++) d(C.slides[a], C.touchEvents.touchStart, l) 366 } 367 368 function h() { 369 var a, d = C.h.removeEventListener; 370 if (b.onSlideClick) 371 for (a = 0; a < C.slides.length; a++) d(C.slides[a], "click", k); 372 if (b.onSlideTouch) 373 for (a = 0; a < C.slides.length; a++) d(C.slides[a], C.touchEvents.touchStart, l); 374 if (b.releaseFormElements) { 375 var e = c("input, textarea, select", C.container); 376 for (a = 0; a < e.length; a++) d(e[a], C.touchEvents.touchStart, o, !0) 377 } 378 if (b.preventLinks) { 379 var f = c("a", C.container); 380 for (a = 0; a < f.length; a++) d(f[a], "click", n) 381 } 382 } 383 384 function i(a) { 385 var b = a.keyCode || a.charCode; 386 if (!(a.shiftKey || a.altKey || a.ctrlKey || a.metaKey)) { 387 if (37 === b || 39 === b || 38 === b || 40 === b) { 388 for (var c = !1, d = C.h.getOffset(C.container), e = C.h.windowScroll().left, f = C.h.windowScroll().top, g = C.h.windowWidth(), h = C.h.windowHeight(), i = [ 389 [d.left, d.top], 390 [d.left + C.width, d.top], 391 [d.left, d.top + C.height], 392 [d.left + C.width, d.top + C.height] 393 ], j = 0; j < i.length; j++) { 394 var k = i[j]; 395 k[0] >= e && k[0] <= e + g && k[1] >= f && k[1] <= f + h && (c = !0) 396 } 397 if (!c) return 398 } 399 M ? ((37 === b || 39 === b) && (a.preventDefault ? a.preventDefault() : a.returnValue = !1), 39 === b && C.swipeNext(), 37 === b && C.swipePrev()) : ((38 === b || 40 === b) && (a.preventDefault ? a.preventDefault() : a.returnValue = !1), 40 === b && C.swipeNext(), 38 === b && C.swipePrev()) 400 } 401 } 402 403 function j(a) { 404 var c = C._wheelEvent, 405 d = 0; 406 if (a.detail) d = -a.detail; 407 else if ("mousewheel" === c) 408 if (b.mousewheelControlForceToAxis) 409 if (M) { 410 if (!(Math.abs(a.wheelDeltaX) > Math.abs(a.wheelDeltaY))) return; 411 d = a.wheelDeltaX 412 } else { 413 if (!(Math.abs(a.wheelDeltaY) > Math.abs(a.wheelDeltaX))) return; 414 d = a.wheelDeltaY 415 } else d = a.wheelDelta; 416 else if ("DOMMouseScroll" === c) d = -a.detail; 417 else if ("wheel" === c) 418 if (b.mousewheelControlForceToAxis) 419 if (M) { 420 if (!(Math.abs(a.deltaX) > Math.abs(a.deltaY))) return; 421 d = -a.deltaX 422 } else { 423 if (!(Math.abs(a.deltaY) > Math.abs(a.deltaX))) return; 424 d = -a.deltaY 425 } else d = Math.abs(a.deltaX) > Math.abs(a.deltaY) ? -a.deltaX : -a.deltaY; 426 if (b.freeMode) { 427 var f = C.getWrapperTranslate() + d; 428 if (f > 0 && (f = 0), f < -e() && (f = -e()), C.setWrapperTransition(0), C.setWrapperTranslate(f), C.updateActiveSlide(f), 0 === f || f === -e()) return 429 } else (new Date).getTime() - U > 60 && (0 > d ? C.swipeNext() : C.swipePrev()), U = (new Date).getTime(); 430 return b.autoplay && C.stopAutoplay(!0), a.preventDefault ? a.preventDefault() : a.returnValue = !1, !1 431 } 432 433 function k(a) { 434 C.allowSlideClick && (m(a), C.fireCallback(b.onSlideClick, C, a)) 435 } 436 437 function l(a) { 438 m(a), C.fireCallback(b.onSlideTouch, C, a) 439 } 440 441 function m(a) { 442 if (a.currentTarget) C.clickedSlide = a.currentTarget; 443 else { 444 var c = a.srcElement; 445 do { 446 if (c.className.indexOf(b.slideClass) > -1) break; 447 c = c.parentNode 448 } while (c); 449 C.clickedSlide = c 450 } 451 C.clickedSlideIndex = C.slides.indexOf(C.clickedSlide), C.clickedSlideLoopIndex = C.clickedSlideIndex - (C.loopedSlides || 0) 452 } 453 454 function n(a) { 455 return C.allowLinks ? void 0 : (a.preventDefault ? a.preventDefault() : a.returnValue = !1, b.preventLinksPropagation && "stopPropagation" in a && a.stopPropagation(), !1) 456 } 457 458 function o(a) { 459 return a.stopPropagation ? a.stopPropagation() : a.returnValue = !1, !1 460 } 461 462 function p(a) { 463 if (b.preventLinks && (C.allowLinks = !0), C.isTouched || b.onlyExternal) return !1; 464 var c = a.target || a.srcElement; 465 document.activeElement && document.activeElement !== c && document.activeElement.blur(); 466 var d = "input select textarea".split(" "); 467 if (b.noSwiping && c && s(c)) return !1; 468 if ($ = !1, C.isTouched = !0, Z = "touchstart" === a.type, !Z && "which" in a && 3 === a.which) return !1; 469 if (!Z || 1 === a.targetTouches.length) { 470 C.callPlugins("onTouchStartBegin"), !Z && !C.isAndroid && d.indexOf(c.tagName.toLowerCase()) < 0 && (a.preventDefault ? a.preventDefault() : a.returnValue = !1); 471 var e = Z ? a.targetTouches[0].pageX : a.pageX || a.clientX, 472 f = Z ? a.targetTouches[0].pageY : a.pageY || a.clientY; 473 C.touches.startX = C.touches.currentX = e, C.touches.startY = C.touches.currentY = f, C.touches.start = C.touches.current = M ? e : f, C.setWrapperTransition(0), C.positions.start = C.positions.current = C.getWrapperTranslate(), C.setWrapperTranslate(C.positions.start), C.times.start = (new Date).getTime(), H = void 0, b.moveStartThreshold > 0 && (W = !1), b.onTouchStart && C.fireCallback(b.onTouchStart, C, a), C.callPlugins("onTouchStartEnd") 474 } 475 } 476 477 function q(a) { 478 if (C.isTouched && !b.onlyExternal && (!Z || "mousemove" !== a.type)) { 479 var c = Z ? a.targetTouches[0].pageX : a.pageX || a.clientX, 480 d = Z ? a.targetTouches[0].pageY : a.pageY || a.clientY; 481 if ("undefined" == typeof H && M && (H = !!(H || Math.abs(d - C.touches.startY) > Math.abs(c - C.touches.startX))), "undefined" != typeof H || M || (H = !!(H || Math.abs(d - C.touches.startY) < Math.abs(c - C.touches.startX))), H) return void (C.isTouched = !1); 482 if (M) { 483 if (!b.swipeToNext && c < C.touches.startX || !b.swipeToPrev && c > C.touches.startX) return 484 } else if (!b.swipeToNext && d < C.touches.startY || !b.swipeToPrev && d > C.touches.startY) return; 485 if (a.assignedToSwiper) return void (C.isTouched = !1); 486 if (a.assignedToSwiper = !0, b.preventLinks && (C.allowLinks = !1), b.onSlideClick && (C.allowSlideClick = !1), b.autoplay && C.stopAutoplay(!0), !Z || 1 === a.touches.length) { 487 if (C.isMoved || (C.callPlugins("onTouchMoveStart"), b.loop && (C.fixLoop(), C.positions.start = C.getWrapperTranslate()), b.onTouchMoveStart && C.fireCallback(b.onTouchMoveStart, C)), C.isMoved = !0, a.preventDefault ? a.preventDefault() : a.returnValue = !1, C.touches.current = M ? c : d, C.positions.current = (C.touches.current - C.touches.start) * b.touchRatio + C.positions.start, C.positions.current > 0 && b.onResistanceBefore && C.fireCallback(b.onResistanceBefore, C, C.positions.current), C.positions.current < -e() && b.onResistanceAfter && C.fireCallback(b.onResistanceAfter, C, Math.abs(C.positions.current + e())), b.resistance && "100%" !== b.resistance) { 488 var f; 489 if (C.positions.current > 0 && (f = 1 - C.positions.current / I / 2, C.positions.current = .5 > f ? I / 2 : C.positions.current * f), C.positions.current < -e()) { 490 var g = (C.touches.current - C.touches.start) * b.touchRatio + (e() + C.positions.start); 491 f = (I + g) / I; 492 var h = C.positions.current - g * (1 - f) / 2, 493 i = -e() - I / 2; 494 C.positions.current = i > h || 0 >= f ? i : h 495 } 496 } 497 if (b.resistance && "100%" === b.resistance && (C.positions.current > 0 && (!b.freeMode || b.freeModeFluid) && (C.positions.current = 0), C.positions.current < -e() && (!b.freeMode || b.freeModeFluid) && (C.positions.current = -e())), !b.followFinger) return; 498 if (b.moveStartThreshold) 499 if (Math.abs(C.touches.current - C.touches.start) > b.moveStartThreshold || W) { 500 if (!W) return W = !0, void (C.touches.start = C.touches.current); 501 C.setWrapperTranslate(C.positions.current) 502 } else C.positions.current = C.positions.start; 503 else C.setWrapperTranslate(C.positions.current); 504 return (b.freeMode || b.watchActiveIndex) && C.updateActiveSlide(C.positions.current), b.grabCursor && (C.container.style.cursor = "move", C.container.style.cursor = "grabbing", C.container.style.cursor = "-moz-grabbin", C.container.style.cursor = "-webkit-grabbing"), X || (X = C.touches.current), Y || (Y = (new Date).getTime()), C.velocity = (C.touches.current - X) / ((new Date).getTime() - Y) / 2, Math.abs(C.touches.current - X) < 2 && (C.velocity = 0), X = C.touches.current, Y = (new Date).getTime(), C.callPlugins("onTouchMoveEnd"), b.onTouchMove && C.fireCallback(b.onTouchMove, C, a), !1 505 } 506 } 507 } 508 509 function r(a) { 510 if (H && C.swipeReset(), !b.onlyExternal && C.isTouched) { 511 C.isTouched = !1, b.grabCursor && (C.container.style.cursor = "move", C.container.style.cursor = "grab", C.container.style.cursor = "-moz-grab", C.container.style.cursor = "-webkit-grab"), C.positions.current || 0 === C.positions.current || (C.positions.current = C.positions.start), b.followFinger && C.setWrapperTranslate(C.positions.current), C.times.end = (new Date).getTime(), C.touches.diff = C.touches.current - C.touches.start, C.touches.abs = Math.abs(C.touches.diff), C.positions.diff = C.positions.current - C.positions.start, C.positions.abs = Math.abs(C.positions.diff); 512 var c = C.positions.diff, 513 d = C.positions.abs, 514 f = C.times.end - C.times.start; 515 5 > d && 300 > f && C.allowLinks === !1 && (b.freeMode || 0 === d || C.swipeReset(), b.preventLinks && (C.allowLinks = !0), b.onSlideClick && (C.allowSlideClick = !0)), setTimeout(function () { 516 "undefined" != typeof C && null !== C && (b.preventLinks && (C.allowLinks = !0), b.onSlideClick && (C.allowSlideClick = !0)) 517 }, 100); 518 var g = e(); 519 if (!C.isMoved && b.freeMode) return C.isMoved = !1, b.onTouchEnd && C.fireCallback(b.onTouchEnd, C, a), void C.callPlugins("onTouchEnd"); 520 if (!C.isMoved || C.positions.current > 0 || C.positions.current < -g) return C.swipeReset(), b.onTouchEnd && C.fireCallback(b.onTouchEnd, C, a), void C.callPlugins("onTouchEnd"); 521 if (C.isMoved = !1, b.freeMode) { 522 if (b.freeModeFluid) { 523 var h, i = 1e3 * b.momentumRatio, 524 j = C.velocity * i, 525 k = C.positions.current + j, 526 l = !1, 527 m = 20 * Math.abs(C.velocity) * b.momentumBounceRatio; -g > k && (b.momentumBounce && C.support.transitions ? (-m > k + g && (k = -g - m), h = -g, l = !0, $ = !0) : k = -g), k > 0 && (b.momentumBounce && C.support.transitions ? (k > m && (k = m), h = 0, l = !0, $ = !0) : k = 0), 0 !== C.velocity && (i = Math.abs((k - C.positions.current) / C.velocity)), C.setWrapperTranslate(k), C.setWrapperTransition(i), b.momentumBounce && l && C.wrapperTransitionEnd(function () { 528 $ && (b.onMomentumBounce && C.fireCallback(b.onMomentumBounce, C), C.callPlugins("onMomentumBounce"), C.setWrapperTranslate(h), C.setWrapperTransition(300)) 529 }), C.updateActiveSlide(k) 530 } 531 return (!b.freeModeFluid || f >= 300) && C.updateActiveSlide(C.positions.current), b.onTouchEnd && C.fireCallback(b.onTouchEnd, C, a), void C.callPlugins("onTouchEnd") 532 } 533 G = 0 > c ? "toNext" : "toPrev", "toNext" === G && 300 >= f && (30 > d || !b.shortSwipes ? C.swipeReset() : C.swipeNext(!0)), "toPrev" === G && 300 >= f && (30 > d || !b.shortSwipes ? C.swipeReset() : C.swipePrev(!0)); 534 var n = 0; 535 if ("auto" === b.slidesPerView) { 536 for (var o, p = Math.abs(C.getWrapperTranslate()), q = 0, r = 0; r < C.slides.length; r++) 537 if (o = M ? C.slides[r].getWidth(!0, b.roundLengths) : C.slides[r].getHeight(!0, b.roundLengths), q += o, q > p) { 538 n = o; 539 break 540 } 541 n > I && (n = I) 542 } else n = E * b.slidesPerView; 543 "toNext" === G && f > 300 && (d >= n * b.longSwipesRatio ? C.swipeNext(!0) : C.swipeReset()), "toPrev" === G && f > 300 && (d >= n * b.longSwipesRatio ? C.swipePrev(!0) : C.swipeReset()), b.onTouchEnd && C.fireCallback(b.onTouchEnd, C, a), C.callPlugins("onTouchEnd") 544 } 545 } 546 547 function s(a) { 548 var c = !1; 549 do a.className.indexOf(b.noSwipingClass) > -1 && (c = !0), a = a.parentElement; while (!c && a.parentElement && -1 === a.className.indexOf(b.wrapperClass)); 550 return !c && a.className.indexOf(b.wrapperClass) > -1 && a.className.indexOf(b.noSwipingClass) > -1 && (c = !0), c 551 } 552 553 function t(a, b) { 554 var c, d = document.createElement("div"); 555 return d.innerHTML = b, c = d.firstChild, c.className += " " + a, c.outerHTML 556 } 557 558 function u(a, c, d) { 559 function e() { 560 var f = +new Date, 561 l = f - g; 562 h += i * l / (1e3 / 60), k = "toNext" === j ? h > a : a > h, k ? (C.setWrapperTranslate(Math.ceil(h)), C._DOMAnimating = !0, window.setTimeout(function () { 563 e() 564 }, 1e3 / 60)) : (b.onSlideChangeEnd && ("to" === c ? d.runCallbacks === !0 && C.fireCallback(b.onSlideChangeEnd, C, j) : C.fireCallback(b.onSlideChangeEnd, C, j)), C.setWrapperTranslate(a), C._DOMAnimating = !1) 565 } 566 var f = "to" === c && d.speed >= 0 ? d.speed : b.speed, 567 g = +new Date; 568 if (C.support.transitions || !b.DOMAnimation) C.setWrapperTranslate(a), C.setWrapperTransition(f); 569 else { 570 var h = C.getWrapperTranslate(), 571 i = Math.ceil((a - h) / f * (1e3 / 60)), 572 j = h > a ? "toNext" : "toPrev", 573 k = "toNext" === j ? h > a : a > h; 574 if (C._DOMAnimating) return; 575 e() 576 } 577 C.updateActiveSlide(a), b.onSlideNext && "next" === c && C.fireCallback(b.onSlideNext, C, a), b.onSlidePrev && "prev" === c && C.fireCallback(b.onSlidePrev, C, a), b.onSlideReset && "reset" === c && C.fireCallback(b.onSlideReset, C, a), ("next" === c || "prev" === c || "to" === c && d.runCallbacks === !0) && v(c) 578 } 579 580 function v(a) { 581 if (C.callPlugins("onSlideChangeStart"), b.onSlideChangeStart) 582 if (b.queueStartCallbacks && C.support.transitions) { 583 if (C._queueStartCallbacks) return; 584 C._queueStartCallbacks = !0, C.fireCallback(b.onSlideChangeStart, C, a), C.wrapperTransitionEnd(function () { 585 C._queueStartCallbacks = !1 586 }) 587 } else C.fireCallback(b.onSlideChangeStart, C, a); 588 if (b.onSlideChangeEnd) 589 if (C.support.transitions) 590 if (b.queueEndCallbacks) { 591 if (C._queueEndCallbacks) return; 592 C._queueEndCallbacks = !0, C.wrapperTransitionEnd(function (c) { 593 C.fireCallback(b.onSlideChangeEnd, c, a) 594 }) 595 } else C.wrapperTransitionEnd(function (c) { 596 C.fireCallback(b.onSlideChangeEnd, c, a) 597 }); 598 else b.DOMAnimation || setTimeout(function () { 599 C.fireCallback(b.onSlideChangeEnd, C, a) 600 }, 10) 601 } 602 603 function w() { 604 var a = C.paginationButtons; 605 if (a) 606 for (var b = 0; b < a.length; b++) C.h.removeEventListener(a[b], "click", y) 607 } 608 609 function x() { 610 var a = C.paginationButtons; 611 if (a) 612 for (var b = 0; b < a.length; b++) C.h.addEventListener(a[b], "click", y) 613 } 614 615 function y(a) { 616 for (var c, d = a.target || a.srcElement, e = C.paginationButtons, f = 0; f < e.length; f++) d === e[f] && (c = f); 617 b.autoplay && C.stopAutoplay(!0), C.swipeTo(c) 618 } 619 620 function z() { 621 _ = setTimeout(function () { 622 b.loop ? (C.fixLoop(), C.swipeNext(!0)) : C.swipeNext(!0) || (b.autoplayStopOnLast ? (clearTimeout(_), _ = void 0) : C.swipeTo(0)), C.wrapperTransitionEnd(function () { 623 "undefined" != typeof _ && z() 624 }) 625 }, b.autoplay) 626 } 627 628 function A() { 629 C.calcSlides(), b.loader.slides.length > 0 && 0 === C.slides.length && C.loadSlides(), b.loop && C.createLoop(), C.init(), f(), b.pagination && C.createPagination(!0), b.loop || b.initialSlide > 0 ? C.swipeTo(b.initialSlide, 0, !1) : C.updateActiveSlide(0), b.autoplay && C.startAutoplay(), C.centerIndex = C.activeIndex, b.onSwiperCreated && C.fireCallback(b.onSwiperCreated, C), C.callPlugins("onSwiperCreated") 630 } 631 if (!document.body.outerHTML && document.body.__defineGetter__ && HTMLElement) { 632 var B = HTMLElement.prototype; 633 B.__defineGetter__ && B.__defineGetter__("outerHTML", function () { 634 return (new XMLSerializer).serializeToString(this) 635 }) 636 } 637 if (window.getComputedStyle || (window.getComputedStyle = function (a) { 638 return this.el = a, this.getPropertyValue = function (b) { 639 var c = /(\-([a-z]){1})/g; 640 return "float" === b && (b = "styleFloat"), c.test(b) && (b = b.replace(c, function () { 641 return arguments[2].toUpperCase() 642 })), a.currentStyle[b] ? a.currentStyle[b] : null 643 }, this 644 }), Array.prototype.indexOf || (Array.prototype.indexOf = function (a, b) { 645 for (var c = b || 0, d = this.length; d > c; c++) 646 if (this[c] === a) return c; 647 return -1 648 }), (document.querySelectorAll || window.jQuery) && "undefined" != typeof a && (a.nodeType || 0 !== c(a).length)) { 649 var C = this; 650 C.touches = { 651 start: 0, 652 startX: 0, 653 startY: 0, 654 current: 0, 655 currentX: 0, 656 currentY: 0, 657 diff: 0, 658 abs: 0 659 }, C.positions = { 660 start: 0, 661 abs: 0, 662 diff: 0, 663 current: 0 664 }, C.times = { 665 start: 0, 666 end: 0 667 }, C.id = (new Date).getTime(), C.container = a.nodeType ? a : c(a)[0], C.isTouched = !1, C.isMoved = !1, C.activeIndex = 0, C.centerIndex = 0, C.activeLoaderIndex = 0, C.activeLoopIndex = 0, C.previousIndex = null, C.velocity = 0, C.snapGrid = [], C.slidesGrid = [], C.imagesToLoad = [], C.imagesLoaded = 0, C.wrapperLeft = 0, C.wrapperRight = 0, C.wrapperTop = 0, C.wrapperBottom = 0, C.isAndroid = navigator.userAgent.toLowerCase().indexOf("android") >= 0; 668 var D, E, F, G, H, I, J = { 669 eventTarget: "wrapper", 670 mode: "horizontal", 671 touchRatio: 1, 672 speed: 300, 673 freeMode: !1, 674 freeModeFluid: !1, 675 momentumRatio: 1, 676 momentumBounce: !0, 677 momentumBounceRatio: 1, 678 slidesPerView: 1, 679 slidesPerGroup: 1, 680 slidesPerViewFit: !0, 681 simulateTouch: !0, 682 followFinger: !0, 683 shortSwipes: !0, 684 longSwipesRatio: .5, 685 moveStartThreshold: !1, 686 onlyExternal: !1, 687 createPagination: !0, 688 pagination: !1, 689 paginationElement: "span", 690 paginationClickable: !1, 691 paginationAsRange: !0, 692 resistance: !0, 693 scrollContainer: !1, 694 preventLinks: !0, 695 preventLinksPropagation: !1, 696 noSwiping: !1, 697 noSwipingClass: "swiper-no-swiping", 698 initialSlide: 0, 699 keyboardControl: !1, 700 mousewheelControl: !1, 701 mousewheelControlForceToAxis: !1, 702 useCSS3Transforms: !0, 703 autoplay: !1, 704 autoplayDisableOnInteraction: !0, 705 autoplayStopOnLast: !1, 706 loop: !1, 707 loopAdditionalSlides: 0, 708 roundLengths: !1, 709 calculateHeight: !1, 710 cssWidthAndHeight: !1, 711 updateOnImagesReady: !0, 712 releaseFormElements: !0, 713 watchActiveIndex: !1, 714 visibilityFullFit: !1, 715 offsetPxBefore: 0, 716 offsetPxAfter: 0, 717 offsetSlidesBefore: 0, 718 offsetSlidesAfter: 0, 719 centeredSlides: !1, 720 queueStartCallbacks: !1, 721 queueEndCallbacks: !1, 722 autoResize: !0, 723 resizeReInit: !1, 724 DOMAnimation: !0, 725 loader: { 726 slides: [], 727 slidesHTMLType: "inner", 728 surroundGroups: 1, 729 logic: "reload", 730 loadAllSlides: !1 731 }, 732 swipeToPrev: !0, 733 swipeToNext: !0, 734 slideElement: "div", 735 slideClass: "swiper-slide", 736 slideActiveClass: "swiper-slide-active", 737 slideVisibleClass: "swiper-slide-visible", 738 slideDuplicateClass: "swiper-slide-duplicate", 739 wrapperClass: "swiper-wrapper", 740 paginationElementClass: "swiper-pagination-switch", 741 paginationActiveClass: "swiper-active-switch", 742 paginationVisibleClass: "swiper-visible-switch" 743 }; 744 b = b || {}; 745 for (var K in J) 746 if (K in b && "object" == typeof b[K]) 747 for (var L in J[K]) L in b[K] || (b[K][L] = J[K][L]); 748 else K in b || (b[K] = J[K]); 749 C.params = b, b.scrollContainer && (b.freeMode = !0, b.freeModeFluid = !0), b.loop && (b.resistance = "100%"); 750 var M = "horizontal" === b.mode, 751 N = ["mousedown", "mousemove", "mouseup"]; 752 C.browser.ie10 && (N = ["MSPointerDown", "MSPointerMove", "MSPointerUp"]), C.browser.ie11 && (N = ["pointerdown", "pointermove", "pointerup"]), C.touchEvents = { 753 touchStart: C.support.touch || !b.simulateTouch ? "touchstart" : N[0], 754 touchMove: C.support.touch || !b.simulateTouch ? "touchmove" : N[1], 755 touchEnd: C.support.touch || !b.simulateTouch ? "touchend" : N[2] 756 }; 757 for (var O = C.container.childNodes.length - 1; O >= 0; O--) 758 if (C.container.childNodes[O].className) 759 for (var P = C.container.childNodes[O].className.split(/\s+/), Q = 0; Q < P.length; Q++) P[Q] === b.wrapperClass && (D = C.container.childNodes[O]); 760 C.wrapper = D, C._extendSwiperSlide = function (a) { 761 return a.append = function () { 762 return b.loop ? a.insertAfter(C.slides.length - C.loopedSlides) : (C.wrapper.appendChild(a), C.reInit()), a 763 }, a.prepend = function () { 764 return b.loop ? (C.wrapper.insertBefore(a, C.slides[C.loopedSlides]), C.removeLoopedSlides(), C.calcSlides(), C.createLoop()) : C.wrapper.insertBefore(a, C.wrapper.firstChild), C.reInit(), a 765 }, a.insertAfter = function (c) { 766 if ("undefined" == typeof c) return !1; 767 var d; 768 return b.loop ? (d = C.slides[c + 1 + C.loopedSlides], d ? C.wrapper.insertBefore(a, d) : C.wrapper.appendChild(a), C.removeLoopedSlides(), C.calcSlides(), C.createLoop()) : (d = C.slides[c + 1], C.wrapper.insertBefore(a, d)), C.reInit(), a 769 }, a.clone = function () { 770 return C._extendSwiperSlide(a.cloneNode(!0)) 771 }, a.remove = function () { 772 C.wrapper.removeChild(a), C.reInit() 773 }, a.html = function (b) { 774 return "undefined" == typeof b ? a.innerHTML : (a.innerHTML = b, a) 775 }, a.index = function () { 776 for (var b, c = C.slides.length - 1; c >= 0; c--) a === C.slides[c] && (b = c); 777 return b 778 }, a.isActive = function () { 779 return a.index() === C.activeIndex ? !0 : !1 780 }, a.swiperSlideDataStorage || (a.swiperSlideDataStorage = {}), a.getData = function (b) { 781 return a.swiperSlideDataStorage[b] 782 }, a.setData = function (b, c) { 783 return a.swiperSlideDataStorage[b] = c, a 784 }, a.data = function (b, c) { 785 return "undefined" == typeof c ? a.getAttribute("data-" + b) : (a.setAttribute("data-" + b, c), a) 786 }, a.getWidth = function (b, c) { 787 return C.h.getWidth(a, b, c) 788 }, a.getHeight = function (b, c) { 789 return C.h.getHeight(a, b, c) 790 }, a.getOffset = function () { 791 return C.h.getOffset(a) 792 }, a 793 }, C.calcSlides = function (a) { 794 var c = C.slides ? C.slides.length : !1; 795 C.slides = [], C.displaySlides = []; 796 for (var d = 0; d < C.wrapper.childNodes.length; d++) 797 if (C.wrapper.childNodes[d].className) 798 for (var e = C.wrapper.childNodes[d].className, f = e.split(/\s+/), i = 0; i < f.length; i++) f[i] === b.slideClass && C.slides.push(C.wrapper.childNodes[d]); 799 for (d = C.slides.length - 1; d >= 0; d--) C._extendSwiperSlide(C.slides[d]); 800 c !== !1 && (c !== C.slides.length || a) && (h(), g(), C.updateActiveSlide(), C.params.pagination && C.createPagination(), C.callPlugins("numberOfSlidesChanged")) 801 }, C.createSlide = function (a, c, d) { 802 c = c || C.params.slideClass, d = d || b.slideElement; 803 var e = document.createElement(d); 804 return e.innerHTML = a || "", e.className = c, C._extendSwiperSlide(e) 805 }, C.appendSlide = function (a, b, c) { 806 return a ? a.nodeType ? C._extendSwiperSlide(a).append() : C.createSlide(a, b, c).append() : void 0 807 }, C.prependSlide = function (a, b, c) { 808 return a ? a.nodeType ? C._extendSwiperSlide(a).prepend() : C.createSlide(a, b, c).prepend() : void 0 809 }, C.insertSlideAfter = function (a, b, c, d) { 810 return "undefined" == typeof a ? !1 : b.nodeType ? C._extendSwiperSlide(b).insertAfter(a) : C.createSlide(b, c, d).insertAfter(a) 811 }, C.removeSlide = function (a) { 812 if (C.slides[a]) { 813 if (b.loop) { 814 if (!C.slides[a + C.loopedSlides]) return !1; 815 C.slides[a + C.loopedSlides].remove(), C.removeLoopedSlides(), C.calcSlides(), C.createLoop() 816 } else C.slides[a].remove(); 817 return !0 818 } 819 return !1 820 }, C.removeLastSlide = function () { 821 return C.slides.length > 0 ? (b.loop ? (C.slides[C.slides.length - 1 - C.loopedSlides].remove(), C.removeLoopedSlides(), C.calcSlides(), C.createLoop()) : C.slides[C.slides.length - 1].remove(), !0) : !1 822 }, C.removeAllSlides = function () { 823 for (var a = C.slides.length - 1; a >= 0; a--) C.slides[a].remove() 824 }, C.getSlide = function (a) { 825 return C.slides[a] 826 }, C.getLastSlide = function () { 827 return C.slides[C.slides.length - 1] 828 }, C.getFirstSlide = function () { 829 return C.slides[0] 830 }, C.activeSlide = function () { 831 return C.slides[C.activeIndex] 832 }, C.fireCallback = function () { 833 var a = arguments[0]; 834 if ("[object Array]" === Object.prototype.toString.call(a)) 835 for (var c = 0; c < a.length; c++) "function" == typeof a[c] && a[c](arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]); 836 else "[object String]" === Object.prototype.toString.call(a) ? b["on" + a] && C.fireCallback(b["on" + a], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]) : a(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]) 837 }, C.addCallback = function (a, b) { 838 var c, e = this; 839 return e.params["on" + a] ? d(this.params["on" + a]) ? this.params["on" + a].push(b) : "function" == typeof this.params["on" + a] ? (c = this.params["on" + a], this.params["on" + a] = [], this.params["on" + a].push(c), this.params["on" + a].push(b)) : void 0 : (this.params["on" + a] = [], this.params["on" + a].push(b)) 840 }, C.removeCallbacks = function (a) { 841 C.params["on" + a] && (C.params["on" + a] = null) 842 }; 843 var R = []; 844 for (var S in C.plugins) 845 if (b[S]) { 846 var T = C.plugins[S](C, b[S]); 847 T && R.push(T) 848 } 849 C.callPlugins = function (a, b) { 850 b || (b = {}); 851 for (var c = 0; c < R.length; c++) a in R[c] && R[c][a](b) 852 }, !C.browser.ie10 && !C.browser.ie11 || b.onlyExternal || C.wrapper.classList.add("swiper-wp8-" + (M ? "horizontal" : "vertical")), b.freeMode && (C.container.className += " swiper-free-mode"), C.initialized = !1, C.init = function (a, c) { 853 var d = C.h.getWidth(C.container, !1, b.roundLengths), 854 e = C.h.getHeight(C.container, !1, b.roundLengths); 855 if (d !== C.width || e !== C.height || a) { 856 C.width = d, C.height = e; 857 var f, g, h, i, j, k, l; 858 I = M ? d : e; 859 var m = C.wrapper; 860 if (a && C.calcSlides(c), "auto" === b.slidesPerView) { 861 var n = 0, 862 o = 0; 863 b.slidesOffset > 0 && (m.style.paddingLeft = "", m.style.paddingRight = "", m.style.paddingTop = "", m.style.paddingBottom = ""), m.style.width = "", m.style.height = "", b.offsetPxBefore > 0 && (M ? C.wrapperLeft = b.offsetPxBefore : C.wrapperTop = b.offsetPxBefore), b.offsetPxAfter > 0 && (M ? C.wrapperRight = b.offsetPxAfter : C.wrapperBottom = b.offsetPxAfter), b.centeredSlides && (M ? (C.wrapperLeft = (I - this.slides[0].getWidth(!0, b.roundLengths)) / 2, C.wrapperRight = (I - C.slides[C.slides.length - 1].getWidth(!0, b.roundLengths)) / 2) : (C.wrapperTop = (I - C.slides[0].getHeight(!0, b.roundLengths)) / 2, C.wrapperBottom = (I - C.slides[C.slides.length - 1].getHeight(!0, b.roundLengths)) / 2)), M ? (C.wrapperLeft >= 0 && (m.style.paddingLeft = C.wrapperLeft + "px"), C.wrapperRight >= 0 && (m.style.paddingRight = C.wrapperRight + "px")) : (C.wrapperTop >= 0 && (m.style.paddingTop = C.wrapperTop + "px"), C.wrapperBottom >= 0 && (m.style.paddingBottom = C.wrapperBottom + "px")), k = 0; 864 var p = 0; 865 for (C.snapGrid = [], C.slidesGrid = [], h = 0, l = 0; l < C.slides.length; l++) { 866 f = C.slides[l].getWidth(!0, b.roundLengths), g = C.slides[l].getHeight(!0, b.roundLengths), b.calculateHeight && (h = Math.max(h, g)); 867 var q = M ? f : g; 868 if (b.centeredSlides) { 869 var r = l === C.slides.length - 1 ? 0 : C.slides[l + 1].getWidth(!0, b.roundLengths), 870 s = l === C.slides.length - 1 ? 0 : C.slides[l + 1].getHeight(!0, b.roundLengths), 871 t = M ? r : s; 872 if (q > I) { 873 if (b.slidesPerViewFit) C.snapGrid.push(k + C.wrapperLeft), C.snapGrid.push(k + q - I + C.wrapperLeft); 874 else 875 for (var u = 0; u <= Math.floor(q / (I + C.wrapperLeft)); u++) C.snapGrid.push(0 === u ? k + C.wrapperLeft : k + C.wrapperLeft + I * u); 876 C.slidesGrid.push(k + C.wrapperLeft) 877 } else C.snapGrid.push(p), C.slidesGrid.push(p); 878 p += q / 2 + t / 2 879 } else { 880 if (q > I) 881 if (b.slidesPerViewFit) C.snapGrid.push(k), C.snapGrid.push(k + q - I); 882 else if (0 !== I) 883 for (var v = 0; v <= Math.floor(q / I); v++) C.snapGrid.push(k + I * v); 884 else C.snapGrid.push(k); 885 else C.snapGrid.push(k); 886 C.slidesGrid.push(k) 887 } 888 k += q, n += f, o += g 889 } 890 b.calculateHeight && (C.height = h), M ? (F = n + C.wrapperRight + C.wrapperLeft, m.style.width = n + "px", m.style.height = C.height + "px") : (F = o + C.wrapperTop + C.wrapperBottom, m.style.width = C.width + "px", m.style.height = o + "px") 891 } else if (b.scrollContainer) m.style.width = "", m.style.height = "", i = C.slides[0].getWidth(!0, b.roundLengths), j = C.slides[0].getHeight(!0, b.roundLengths), F = M ? i : j, m.style.width = i + "px", m.style.height = j + "px", E = M ? i : j; 892 else { 893 if (b.calculateHeight) { 894 for (h = 0, j = 0, M || (C.container.style.height = ""), m.style.height = "", l = 0; l < C.slides.length; l++) C.slides[l].style.height = "", h = Math.max(C.slides[l].getHeight(!0), h), M || (j += C.slides[l].getHeight(!0)); 895 g = h, C.height = g, M ? j = g : (I = g, C.container.style.height = I + "px") 896 } else g = M ? C.height : C.height / b.slidesPerView, b.roundLengths && (g = Math.ceil(g)), j = M ? C.height : C.slides.length * g; 897 for (f = M ? C.width / b.slidesPerView : C.width, b.roundLengths && (f = Math.ceil(f)), i = M ? C.slides.length * f : C.width, E = M ? f : g, b.offsetSlidesBefore > 0 && (M ? C.wrapperLeft = E * b.offsetSlidesBefore : C.wrapperTop = E * b.offsetSlidesBefore), b.offsetSlidesAfter > 0 && (M ? C.wrapperRight = E * b.offsetSlidesAfter : C.wrapperBottom = E * b.offsetSlidesAfter), b.offsetPxBefore > 0 && (M ? C.wrapperLeft = b.offsetPxBefore : C.wrapperTop = b.offsetPxBefore), b.offsetPxAfter > 0 && (M ? C.wrapperRight = b.offsetPxAfter : C.wrapperBottom = b.offsetPxAfter), b.centeredSlides && (M ? (C.wrapperLeft = (I - E) / 2, C.wrapperRight = (I - E) / 2) : (C.wrapperTop = (I - E) / 2, C.wrapperBottom = (I - E) / 2)), M ? (C.wrapperLeft > 0 && (m.style.paddingLeft = C.wrapperLeft + "px"), C.wrapperRight > 0 && (m.style.paddingRight = C.wrapperRight + "px")) : (C.wrapperTop > 0 && (m.style.paddingTop = C.wrapperTop + "px"), C.wrapperBottom > 0 && (m.style.paddingBottom = C.wrapperBottom + "px")), F = M ? i + C.wrapperRight + C.wrapperLeft : j + C.wrapperTop + C.wrapperBottom, parseFloat(i) > 0 && (!b.cssWidthAndHeight || "height" === b.cssWidthAndHeight) && (m.style.width = i + "px"), parseFloat(j) > 0 && (!b.cssWidthAndHeight || "width" === b.cssWidthAndHeight) && (m.style.height = j + "px"), k = 0, C.snapGrid = [], C.slidesGrid = [], l = 0; l < C.slides.length; l++) C.snapGrid.push(k), C.slidesGrid.push(k), k += E, parseFloat(f) > 0 && (!b.cssWidthAndHeight || "height" === b.cssWidthAndHeight) && (C.slides[l].style.width = f + "px"), parseFloat(g) > 0 && (!b.cssWidthAndHeight || "width" === b.cssWidthAndHeight) && (C.slides[l].style.height = g + "px") 898 } 899 C.initialized ? (C.callPlugins("onInit"), b.onInit && C.fireCallback(b.onInit, C)) : (C.callPlugins("onFirstInit"), b.onFirstInit && C.fireCallback(b.onFirstInit, C)), C.initialized = !0 900 } 901 }, C.reInit = function (a) { 902 C.init(!0, a) 903 }, C.resizeFix = function (a) { 904 C.callPlugins("beforeResizeFix"), C.init(b.resizeReInit || a), b.freeMode ? C.getWrapperTranslate() < -e() && (C.setWrapperTransition(0), C.setWrapperTranslate(-e())) : (C.swipeTo(b.loop ? C.activeLoopIndex : C.activeIndex, 0, !1), b.autoplay && (C.support.transitions && "undefined" != typeof _ ? "undefined" != typeof _ && (clearTimeout(_), _ = void 0, C.startAutoplay()) : "undefined" != typeof ab && (clearInterval(ab), ab = void 0, C.startAutoplay()))), C.callPlugins("afterResizeFix") 905 }, C.destroy = function () { 906 var a = C.h.removeEventListener, 907 c = "wrapper" === b.eventTarget ? C.wrapper : C.container; 908 C.browser.ie10 || C.browser.ie11 ? (a(c, C.touchEvents.touchStart, p), a(document, C.touchEvents.touchMove, q), a(document, C.touchEvents.touchEnd, r)) : (C.support.touch && (a(c, "touchstart", p), a(c, "touchmove", q), a(c, "touchend", r)), b.simulateTouch && (a(c, "mousedown", p), a(document, "mousemove", q), a(document, "mouseup", r))), b.autoResize && a(window, "resize", C.resizeFix), h(), b.paginationClickable && w(), b.mousewheelControl && C._wheelEvent && a(C.container, C._wheelEvent, j), b.keyboardControl && a(document, "keydown", i), b.autoplay && C.stopAutoplay(), C.callPlugins("onDestroy"), C = null 909 }, C.disableKeyboardControl = function () { 910 b.keyboardControl = !1, C.h.removeEventListener(document, "keydown", i) 911 }, C.enableKeyboardControl = function () { 912 b.keyboardControl = !0, C.h.addEventListener(document, "keydown", i) 913 }; 914 var U = (new Date).getTime(); 915 if (C.disableMousewheelControl = function () { 916 return C._wheelEvent ? (b.mousewheelControl = !1, C.h.removeEventListener(C.container, C._wheelEvent, j), !0) : !1 917 }, C.enableMousewheelControl = function () { 918 return C._wheelEvent ? (b.mousewheelControl = !0, C.h.addEventListener(C.container, C._wheelEvent, j), !0) : !1 919 }, b.grabCursor) { 920 var V = C.container.style; 921 V.cursor = "move", V.cursor = "grab", V.cursor = "-moz-grab", V.cursor = "-webkit-grab" 922 } 923 C.allowSlideClick = !0, C.allowLinks = !0; 924 var W, X, Y, Z = !1, 925 $ = !0; 926 C.swipeNext = function (a) { 927 !a && b.loop && C.fixLoop(), !a && b.autoplay && C.stopAutoplay(!0), C.callPlugins("onSwipeNext"); 928 var c = C.getWrapperTranslate(), 929 d = c; 930 if ("auto" === b.slidesPerView) { 931 for (var f = 0; f < C.snapGrid.length; f++) 932 if (-c >= C.snapGrid[f] && -c < C.snapGrid[f + 1]) { 933 d = -C.snapGrid[f + 1]; 934 break 935 } 936 } else { 937 var g = E * b.slidesPerGroup; 938 d = -(Math.floor(Math.abs(c) / Math.floor(g)) * g + g) 939 } 940 return d < -e() && (d = -e()), d === c ? !1 : (u(d, "next"), !0) 941 }, C.swipePrev = function (a) { 942 !a && b.loop && C.fixLoop(), !a && b.autoplay && C.stopAutoplay(!0), C.callPlugins("onSwipePrev"); 943 var c, d = Math.ceil(C.getWrapperTranslate()); 944 if ("auto" === b.slidesPerView) { 945 c = 0; 946 for (var e = 1; e < C.snapGrid.length; e++) { 947 if (-d === C.snapGrid[e]) { 948 c = -C.snapGrid[e - 1]; 949 break 950 } 951 if (-d > C.snapGrid[e] && -d < C.snapGrid[e + 1]) { 952 c = -C.snapGrid[e]; 953 break 954 } 955 } 956 } else { 957 var f = E * b.slidesPerGroup; 958 c = -(Math.ceil(-d / f) - 1) * f 959 } 960 return c > 0 && (c = 0), c === d ? !1 : (u(c, "prev"), !0) 961 }, C.swipeReset = function () { 962 C.callPlugins("onSwipeReset"); 963 { 964 var a, c = C.getWrapperTranslate(), 965 d = E * b.slidesPerGroup; -e() 966 } 967 if ("auto" === b.slidesPerView) { 968 a = 0; 969 for (var f = 0; f < C.snapGrid.length; f++) { 970 if (-c === C.snapGrid[f]) return; 971 if (-c >= C.snapGrid[f] && -c < C.snapGrid[f + 1]) { 972 a = C.positions.diff > 0 ? -C.snapGrid[f + 1] : -C.snapGrid[f]; 973 break 974 } 975 } -c >= C.snapGrid[C.snapGrid.length - 1] && (a = -C.snapGrid[C.snapGrid.length - 1]), c <= -e() && (a = -e()) 976 } else a = 0 > c ? Math.round(c / d) * d : 0, c <= -e() && (a = -e()); 977 return b.scrollContainer && (a = 0 > c ? c : 0), a < -e() && (a = -e()), b.scrollContainer && I > E && (a = 0), a === c ? !1 : (u(a, "reset"), !0) 978 }, C.swipeTo = function (a, c, d) { 979 a = parseInt(a, 10), C.callPlugins("onSwipeTo", { 980 index: a, 981 speed: c 982 }), b.loop && (a += C.loopedSlides); 983 var f = C.getWrapperTranslate(); 984 if (!(a > C.slides.length - 1 || 0 > a)) { 985 var g; 986 return g = "auto" === b.slidesPerView ? -C.slidesGrid[a] : -a * E, g < -e() && (g = -e()), g === f ? !1 : (d = d === !1 ? !1 : !0, u(g, "to", { 987 index: a, 988 speed: c, 989 runCallbacks: d 990 }), !0) 991 } 992 }, C._queueStartCallbacks = !1, C._queueEndCallbacks = !1, C.updateActiveSlide = function (a) { 993 if (C.initialized && 0 !== C.slides.length) { 994 C.previousIndex = C.activeIndex, "undefined" == typeof a && (a = C.getWrapperTranslate()), a > 0 && (a = 0); 995 var c; 996 if ("auto" === b.slidesPerView) { 997 if (C.activeIndex = C.slidesGrid.indexOf(-a), C.activeIndex < 0) { 998 for (c = 0; c < C.slidesGrid.length - 1 && !(-a > C.slidesGrid[c] && -a < C.slidesGrid[c + 1]); c++); 999 var d = Math.abs(C.slidesGrid[c] + a), 1000 e = Math.abs(C.slidesGrid[c + 1] + a); 1001 C.activeIndex = e >= d ? c : c + 1 1002 } 1003 } else C.activeIndex = Math[b.visibilityFullFit ? "ceil" : "round"](-a / E); 1004 if (C.activeIndex === C.slides.length && (C.activeIndex = C.slides.length - 1), C.activeIndex < 0 && (C.activeIndex = 0), C.slides[C.activeIndex]) { 1005 if (C.calcVisibleSlides(a), C.support.classList) { 1006 var f; 1007 for (c = 0; c < C.slides.length; c++) f = C.slides[c], f.classList.remove(b.slideActiveClass), C.visibleSlides.indexOf(f) >= 0 ? f.classList.add(b.slideVisibleClass) : f.classList.remove(b.slideVisibleClass); 1008 C.slides[C.activeIndex].classList.add(b.slideActiveClass) 1009 } else { 1010 var g = new RegExp("\\s*" + b.slideActiveClass), 1011 h = new RegExp("\\s*" + b.slideVisibleClass); 1012 for (c = 0; c < C.slides.length; c++) C.slides[c].className = C.slides[c].className.replace(g, "").replace(h, ""), C.visibleSlides.indexOf(C.slides[c]) >= 0 && (C.slides[c].className += " " + b.slideVisibleClass); 1013 C.slides[C.activeIndex].className += " " + b.slideActiveClass 1014 } 1015 if (b.loop) { 1016 var i = C.loopedSlides; 1017 C.activeLoopIndex = C.activeIndex - i, C.activeLoopIndex >= C.slides.length - 2 * i && (C.activeLoopIndex = C.slides.length - 2 * i - C.activeLoopIndex), C.activeLoopIndex < 0 && (C.activeLoopIndex = C.slides.length - 2 * i + C.activeLoopIndex), C.activeLoopIndex < 0 && (C.activeLoopIndex = 0) 1018 } else C.activeLoopIndex = C.activeIndex; 1019 b.pagination && C.updatePagination(a) 1020 } 1021 } 1022 }, C.createPagination = function (a) { 1023 if (b.paginationClickable && C.paginationButtons && w(), C.paginationContainer = b.pagination.nodeType ? b.pagination : c(b.pagination)[0], b.createPagination) { 1024 var d = "", 1025 e = C.slides.length, 1026 f = e; 1027 b.loop && (f -= 2 * C.loopedSlides); 1028 for (var g = 0; f > g; g++) d += "<" + b.paginationElement + ' class="' + b.paginationElementClass + '"></' + b.paginationElement + ">"; 1029 C.paginationContainer.innerHTML = d 1030 } 1031 C.paginationButtons = c("." + b.paginationElementClass, C.paginationContainer), a || C.updatePagination(), C.callPlugins("onCreatePagination"), b.paginationClickable && x() 1032 }, C.updatePagination = function (a) { 1033 if (b.pagination && !(C.slides.length < 1)) { 1034 var d = c("." + b.paginationActiveClass, C.paginationContainer); 1035 if (d) { 1036 var e = C.paginationButtons; 1037 if (0 !== e.length) { 1038 for (var f = 0; f < e.length; f++) e[f].className = b.paginationElementClass; 1039 var g = b.loop ? C.loopedSlides : 0; 1040 if (b.paginationAsRange) { 1041 C.visibleSlides || C.calcVisibleSlides(a); 1042 var h, i = []; 1043 for (h = 0; h < C.visibleSlides.length; h++) { 1044 var j = C.slides.indexOf(C.visibleSlides[h]) - g; 1045 b.loop && 0 > j && (j = C.slides.length - 2 * C.loopedSlides + j), b.loop && j >= C.slides.length - 2 * C.loopedSlides && (j = C.slides.length - 2 * C.loopedSlides - j, j = Math.abs(j)), i.push(j) 1046 } 1047 for (h = 0; h < i.length; h++) e[i[h]] && (e[i[h]].className += " " + b.paginationVisibleClass); 1048 b.loop ? void 0 !== e[C.activeLoopIndex] && (e[C.activeLoopIndex].className += " " + b.paginationActiveClass) : e[C.activeIndex].className += " " + b.paginationActiveClass 1049 } else b.loop ? e[C.activeLoopIndex] && (e[C.activeLoopIndex].className += " " + b.paginationActiveClass + " " + b.paginationVisibleClass) : e[C.activeIndex].className += " " + b.paginationActiveClass + " " + b.paginationVisibleClass 1050 } 1051 } 1052 } 1053 }, C.calcVisibleSlides = function (a) { 1054 var c = [], 1055 d = 0, 1056 e = 0, 1057 f = 0; 1058 M && C.wrapperLeft > 0 && (a += C.wrapperLeft), !M && C.wrapperTop > 0 && (a += C.wrapperTop); 1059 for (var g = 0; g < C.slides.length; g++) { 1060 d += e, e = "auto" === b.slidesPerView ? M ? C.h.getWidth(C.slides[g], !0, b.roundLengths) : C.h.getHeight(C.slides[g], !0, b.roundLengths) : E, f = d + e; 1061 var h = !1; 1062 b.visibilityFullFit ? (d >= -a && -a + I >= f && (h = !0), -a >= d && f >= -a + I && (h = !0)) : (f > -a && -a + I >= f && (h = !0), d >= -a && -a + I > d && (h = !0), -a > d && f > -a + I && (h = !0)), h && c.push(C.slides[g]) 1063 } 1064 0 === c.length && (c = [C.slides[C.activeIndex]]), C.visibleSlides = c 1065 }; 1066 var _, ab; 1067 C.startAutoplay = function () { 1068 if (C.support.transitions) { 1069 if ("undefined" != typeof _) return !1; 1070 if (!b.autoplay) return; 1071 C.callPlugins("onAutoplayStart"), b.onAutoplayStart && C.fireCallback(b.onAutoplayStart, C), z() 1072 } else { 1073 if ("undefined" != typeof ab) return !1; 1074 if (!b.autoplay) return; 1075 C.callPlugins("onAutoplayStart"), b.onAutoplayStart && C.fireCallback(b.onAutoplayStart, C), ab = setInterval(function () { 1076 b.loop ? (C.fixLoop(), C.swipeNext(!0)) : C.swipeNext(!0) || (b.autoplayStopOnLast ? (clearInterval(ab), ab = void 0) : C.swipeTo(0)) 1077 }, b.autoplay) 1078 } 1079 }, C.stopAutoplay = function (a) { 1080 if (C.support.transitions) { 1081 if (!_) return; 1082 _ && clearTimeout(_), _ = void 0, a && !b.autoplayDisableOnInteraction && C.wrapperTransitionEnd(function () { 1083 z() 1084 }), C.callPlugins("onAutoplayStop"), b.onAutoplayStop && C.fireCallback(b.onAutoplayStop, C) 1085 } else ab && clearInterval(ab), ab = void 0, C.callPlugins("onAutoplayStop"), b.onAutoplayStop && C.fireCallback(b.onAutoplayStop, C) 1086 }, C.loopCreated = !1, C.removeLoopedSlides = function () { 1087 if (C.loopCreated) 1088 for (var a = 0; a < C.slides.length; a++) C.slides[a].getData("looped") === !0 && C.wrapper.removeChild(C.slides[a]) 1089 }, C.createLoop = function () { 1090 if (0 !== C.slides.length) { 1091 C.loopedSlides = "auto" === b.slidesPerView ? b.loopedSlides || 1 : b.slidesPerView + b.loopAdditionalSlides, C.loopedSlides > C.slides.length && (C.loopedSlides = C.slides.length); 1092 var a, c = "", 1093 d = "", 1094 e = "", 1095 f = C.slides.length, 1096 g = Math.floor(C.loopedSlides / f), 1097 h = C.loopedSlides % f; 1098 for (a = 0; g * f > a; a++) { 1099 var i = a; 1100 if (a >= f) { 1101 var j = Math.floor(a / f); 1102 i = a - f * j 1103 } 1104 e += C.slides[i].outerHTML 1105 } 1106 for (a = 0; h > a; a++) d += t(b.slideDuplicateClass, C.slides[a].outerHTML); 1107 for (a = f - h; f > a; a++) c += t(b.slideDuplicateClass, C.slides[a].outerHTML); 1108 var k = c + e + D.innerHTML + e + d; 1109 for (D.innerHTML = k, C.loopCreated = !0, C.calcSlides(), a = 0; a < C.slides.length; a++) (a < C.loopedSlides || a >= C.slides.length - C.loopedSlides) && C.slides[a].setData("looped", !0); 1110 C.callPlugins("onCreateLoop") 1111 } 1112 }, C.fixLoop = function () { 1113 var a; 1114 C.activeIndex < C.loopedSlides ? (a = C.slides.length - 3 * C.loopedSlides + C.activeIndex, C.swipeTo(a, 0, !1)) : ("auto" === b.slidesPerView && C.activeIndex >= 2 * C.loopedSlides || C.activeIndex > C.slides.length - 2 * b.slidesPerView) && (a = -C.slides.length + C.activeIndex + C.loopedSlides, C.swipeTo(a, 0, !1)) 1115 }, C.loadSlides = function () { 1116 var a = ""; 1117 C.activeLoaderIndex = 0; 1118 for (var c = b.loader.slides, d = b.loader.loadAllSlides ? c.length : b.slidesPerView * (1 + b.loader.surroundGroups), e = 0; d > e; e++) a += "outer" === b.loader.slidesHTMLType ? c[e] : "<" + b.slideElement + ' class="' + b.slideClass + '" data-swiperindex="' + e + '">' + c[e] + "</" + b.slideElement + ">"; 1119 C.wrapper.innerHTML = a, C.calcSlides(!0), b.loader.loadAllSlides || C.wrapperTransitionEnd(C.reloadSlides, !0) 1120 }, C.reloadSlides = function () { 1121 var a = b.loader.slides, 1122 c = parseInt(C.activeSlide().data("swiperindex"), 10); 1123 if (!(0 > c || c > a.length - 1)) { 1124 C.activeLoaderIndex = c; 1125 var d = Math.max(0, c - b.slidesPerView * b.loader.surroundGroups), 1126 e = Math.min(c + b.slidesPerView * (1 + b.loader.surroundGroups) - 1, a.length - 1); 1127 if (c > 0) { 1128 var f = -E * (c - d); 1129 C.setWrapperTranslate(f), C.setWrapperTransition(0) 1130 } 1131 var g; 1132 if ("reload" === b.loader.logic) { 1133 C.wrapper.innerHTML = ""; 1134 var h = ""; 1135 for (g = d; e >= g; g++) h += "outer" === b.loader.slidesHTMLType ? a[g] : "<" + b.slideElement + ' class="' + b.slideClass + '" data-swiperindex="' + g + '">' + a[g] + "</" + b.slideElement + ">"; 1136 C.wrapper.innerHTML = h 1137 } else { 1138 var i = 1e3, 1139 j = 0; 1140 for (g = 0; g < C.slides.length; g++) { 1141 var k = C.slides[g].data("swiperindex"); 1142 d > k || k > e ? C.wrapper.removeChild(C.slides[g]) : (i = Math.min(k, i), j = Math.max(k, j)) 1143 } 1144 for (g = d; e >= g; g++) { 1145 var l; 1146 i > g && (l = document.createElement(b.slideElement), l.className = b.slideClass, l.setAttribute("data-swiperindex", g), l.innerHTML = a[g], C.wrapper.insertBefore(l, C.wrapper.firstChild)), g > j && (l = document.createElement(b.slideElement), l.className = b.slideClass, l.setAttribute("data-swiperindex", g), l.innerHTML = a[g], C.wrapper.appendChild(l)) 1147 } 1148 } 1149 C.reInit(!0) 1150 } 1151 }, A() 1152 } 1153 }; 1154 Swiper.prototype = { 1155 plugins: {}, 1156 wrapperTransitionEnd: function (a, b) { 1157 "use strict"; 1158 1159 function c(h) { 1160 if (h.target === f && (a(e), e.params.queueEndCallbacks && (e._queueEndCallbacks = !1), !b)) 1161 for (d = 0; d < g.length; d++) e.h.removeEventListener(f, g[d], c) 1162 } 1163 var d, e = this, 1164 f = e.wrapper, 1165 g = ["webkitTransitionEnd", "transitionend", "oTransitionEnd", "MSTransitionEnd", "msTransitionEnd"]; 1166 if (a) 1167 for (d = 0; d < g.length; d++) e.h.addEventListener(f, g[d], c) 1168 }, 1169 getWrapperTranslate: function (a) { 1170 "use strict"; 1171 var b, c, d, e, f = this.wrapper; 1172 return "undefined" == typeof a && (a = "horizontal" === this.params.mode ? "x" : "y"), this.support.transforms && this.params.useCSS3Transforms ? (d = window.getComputedStyle(f, null), window.WebKitCSSMatrix ? e = new WebKitCSSMatrix("none" === d.webkitTransform ? "" : d.webkitTransform) : (e = d.MozTransform || d.OTransform || d.MsTransform || d.msTransform || d.transform || d.getPropertyValue("transform").replace("translate(", "matrix(1, 0, 0, 1,"), b = e.toString().split(",")), "x" === a && (c = window.WebKitCSSMatrix ? e.m41 : parseFloat(16 === b.length ? b[12] : b[4])), "y" === a && (c = window.WebKitCSSMatrix ? e.m42 : parseFloat(16 === b.length ? b[13] : b[5]))) : ("x" === a && (c = parseFloat(f.style.left, 10) || 0), "y" === a && (c = parseFloat(f.style.top, 10) || 0)), c || 0 1173 }, 1174 setWrapperTranslate: function (a, b, c) { 1175 "use strict"; 1176 var d, e = this.wrapper.style, 1177 f = { 1178 x: 0, 1179 y: 0, 1180 z: 0 1181 }; 1182 3 === arguments.length ? (f.x = a, f.y = b, f.z = c) : ("undefined" == typeof b && (b = "horizontal" === this.params.mode ? "x" : "y"), f[b] = a), this.support.transforms && this.params.useCSS3Transforms ? (d = this.support.transforms3d ? "translate3d(" + f.x + "px, " + f.y + "px, " + f.z + "px)" : "translate(" + f.x + "px, " + f.y + "px)", e.webkitTransform = e.MsTransform = e.msTransform = e.MozTransform = e.OTransform = e.transform = d) : (e.left = f.x + "px", e.top = f.y + "px"), this.callPlugins("onSetWrapperTransform", f), this.params.onSetWrapperTransform && this.fireCallback(this.params.onSetWrapperTransform, this, f) 1183 }, 1184 setWrapperTransition: function (a) { 1185 "use strict"; 1186 var b = this.wrapper.style; 1187 b.webkitTransitionDuration = b.MsTransitionDuration = b.msTransitionDuration = b.MozTransitionDuration = b.OTransitionDuration = b.transitionDuration = a / 1e3 + "s", this.callPlugins("onSetWrapperTransition", { 1188 duration: a 1189 }), this.params.onSetWrapperTransition && this.fireCallback(this.params.onSetWrapperTransition, this, a) 1190 }, 1191 h: { 1192 getWidth: function (a, b, c) { 1193 "use strict"; 1194 var d = window.getComputedStyle(a, null).getPropertyValue("width"), 1195 e = parseFloat(d); 1196 return (isNaN(e) || d.indexOf("%") > 0 || 0 > e) && (e = a.offsetWidth - parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-left")) - parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-right"))), b && (e += parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-left")) + parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-right"))), c ? Math.ceil(e) : e 1197 }, 1198 getHeight: function (a, b, c) { 1199 "use strict"; 1200 if (b) return a.offsetHeight; 1201 var d = window.getComputedStyle(a, null).getPropertyValue("height"), 1202 e = parseFloat(d); 1203 return (isNaN(e) || d.indexOf("%") > 0 || 0 > e) && (e = a.offsetHeight - parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-top")) - parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-bottom"))), b && (e += parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-top")) + parseFloat(window.getComputedStyle(a, null).getPropertyValue("padding-bottom"))), c ? Math.ceil(e) : e 1204 }, 1205 getOffset: function (a) { 1206 "use strict"; 1207 var b = a.getBoundingClientRect(), 1208 c = document.body, 1209 d = a.clientTop || c.clientTop || 0, 1210 e = a.clientLeft || c.clientLeft || 0, 1211 f = window.pageYOffset || a.scrollTop, 1212 g = window.pageXOffset || a.scrollLeft; 1213 return document.documentElement && !window.pageYOffset && (f = document.documentElement.scrollTop, g = document.documentElement.scrollLeft), { 1214 top: b.top + f - d, 1215 left: b.left + g - e 1216 } 1217 }, 1218 windowWidth: function () { 1219 "use strict"; 1220 return window.innerWidth ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : void 0 1221 }, 1222 windowHeight: function () { 1223 "use strict"; 1224 return window.innerHeight ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : void 0 1225 }, 1226 windowScroll: function () { 1227 "use strict"; 1228 return "undefined" != typeof pageYOffset ? { 1229 left: window.pageXOffset, 1230 top: window.pageYOffset 1231 } : document.documentElement ? { 1232 left: document.documentElement.scrollLeft, 1233 top: document.documentElement.scrollTop 1234 } : void 0 1235 }, 1236 addEventListener: function (a, b, c, d) { 1237 "use strict"; 1238 "undefined" == typeof d && (d = !1), a.addEventListener ? a.addEventListener(b, c, d) : a.attachEvent && a.attachEvent("on" + b, c) 1239 }, 1240 removeEventListener: function (a, b, c, d) { 1241 "use strict"; 1242 "undefined" == typeof d && (d = !1), a.removeEventListener ? a.removeEventListener(b, c, d) : a.detachEvent && a.detachEvent("on" + b, c) 1243 } 1244 }, 1245 setTransform: function (a, b) { 1246 "use strict"; 1247 var c = a.style; 1248 c.webkitTransform = c.MsTransform = c.msTransform = c.MozTransform = c.OTransform = c.transform = b 1249 }, 1250 setTranslate: function (a, b) { 1251 "use strict"; 1252 var c = a.style, 1253 d = { 1254 x: b.x || 0, 1255 y: b.y || 0, 1256 z: b.z || 0 1257 }, 1258 e = this.support.transforms3d ? "translate3d(" + d.x + "px," + d.y + "px," + d.z + "px)" : "translate(" + d.x + "px," + d.y + "px)"; 1259 c.webkitTransform = c.MsTransform = c.msTransform = c.MozTransform = c.OTransform = c.transform = e, this.support.transforms || (c.left = d.x + "px", c.top = d.y + "px") 1260 }, 1261 setTransition: function (a, b) { 1262 "use strict"; 1263 var c = a.style; 1264 c.webkitTransitionDuration = c.MsTransitionDuration = c.msTransitionDuration = c.MozTransitionDuration = c.OTransitionDuration = c.transitionDuration = b + "ms" 1265 }, 1266 support: { 1267 touch: window.Modernizr && Modernizr.touch === !0 || function () { 1268 "use strict"; 1269 return !!("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch) 1270 } (), 1271 transforms3d: window.Modernizr && Modernizr.csstransforms3d === !0 || function () { 1272 "use strict"; 1273 var a = document.createElement("div").style; 1274 return "webkitPerspective" in a || "MozPerspective" in a || "OPerspective" in a || "MsPerspective" in a || "perspective" in a 1275 } (), 1276 transforms: window.Modernizr && Modernizr.csstransforms === !0 || function () { 1277 "use strict"; 1278 var a = document.createElement("div").style; 1279 return "transform" in a || "WebkitTransform" in a || "MozTransform" in a || "msTransform" in a || "MsTransform" in a || "OTransform" in a 1280 } (), 1281 transitions: window.Modernizr && Modernizr.csstransitions === !0 || function () { 1282 "use strict"; 1283 var a = document.createElement("div").style; 1284 return "transition" in a || "WebkitTransition" in a || "MozTransition" in a || "msTransition" in a || "MsTransition" in a || "OTransition" in a 1285 } (), 1286 classList: function () { 1287 "use strict"; 1288 var a = document.createElement("div"); 1289 return "classList" in a 1290 } () 1291 }, 1292 browser: { 1293 ie8: function () { 1294 "use strict"; 1295 var a = -1; 1296 if ("Microsoft Internet Explorer" === navigator.appName) { 1297 var b = navigator.userAgent, 1298 c = new RegExp(/MSIE ([0-9]{1,}[\.0-9]{0,})/); 1299 null !== c.exec(b) && (a = parseFloat(RegExp.$1)) 1300 } 1301 return -1 !== a && 9 > a 1302 } (), 1303 ie10: window.navigator.msPointerEnabled, 1304 ie11: window.navigator.pointerEnabled 1305 } 1306 }, (window.jQuery || window.Zepto) && !function (a) { 1307 "use strict"; 1308 a.fn.swiper = function (b) { 1309 var c; 1310 return this.each(function (d) { 1311 var e = a(this); 1312 if (!e.data("swiper")) { 1313 var f = new Swiper(e[0], b); 1314 d || (c = f), e.data("swiper", f) 1315 } 1316 }), c 1317 } 1318 } (window.jQuery || window.Zepto), "undefined" != typeof module && (module.exports = Swiper), "function" == typeof define && define.amd && define([], function () { 1319 "use strict"; 1320 return Swiper 1321 }); 1322 </script> 1323 <script type="text/javascript"> 1324 window.onload = function () { 1325 var allH = window.innerHeight; 1326 var catapuller = $(".cata_pullermian_con").height(allH - 80); 1327 } 1328 var tabsSwiper = new Swiper('.swiper-container', { 1329 speed: 500, 1330 onSlideChangeStart: function () { 1331 $(".tabs .active").removeClass('active'); 1332 $(".tabs a").eq(tabsSwiper.activeIndex).addClass('active'); 1333 bodyHeight(); 1334 }, 1335 onSlideChangeEnd: function () { 1336 } 1337 }); 1338 $(".tabs a").on('touchstart mousedown', function (e) { 1339 e.preventDefault(); 1340 $(".tabs .active").removeClass('active'); 1341 $(this).addClass('active'); 1342 tabsSwiper.swipeTo($(this).index()); 1343 }); 1344 $(".tabs a").click(function (e) { 1345 e.preventDefault(); 1346 }); 1347 // 设置swiper-slide高度 1348 function bodyHeight() { 1349 $("body").scrollTop(0); 1350 $(".swiper-slide").each(function () { 1351 if ($(this).hasClass("swiper-slide-visible")) { 1352 var contentH = $(this).find(".content-slide").height(); 1353 $(".swiper-container").height(contentH); 1354 } 1355 }) 1356 } 1357 1358 </script> 1359 </body> 1360 </html>
如果等滚动条拉到底部时再加载,会影响用户体验。一般动态加载的时候都需要向服务端请求资源,这时需要时间。一个更佳的方式是,
当滚动条距离浏览器底部存在一定距离(beforehandHeight)时,就动态加载更多数据,向服务端请求资源。也就是预加载。
那么上面的 2或者3 的滚动方式 的判断 if 条件就需要改成: sum - beforehandHeight <= $obj.scrollTop() + $obj.height() 或者: this.scrollHeight - beforehandHeight <= $(this).scrollTop() + $(this).height() 。
例如:当滚动条 离浏览器底部 还有50px时 就需要 加载数据(或者处理其他逻辑),那么 上面的 2或者3 的 判断 if 条件就 需要改成: sum - 50<= $obj.scrollTop() + $obj.height() 或者: this.scrollHeight - 50<= $(this).scrollTop() + $(this).height()