Commit 5618d59fbf65ebc4e7584a1acf4ca3d9093434d6
1 parent
c72e61b6
swaiper
Showing
6 changed files
with
8653 additions
and
68 deletions
css/index.css
| ... | ... | @@ -1218,15 +1218,15 @@ header{ |
| 1218 | 1218 | margin-top: 8px; |
| 1219 | 1219 | } |
| 1220 | 1220 | /*new 新欢迎页样式 sta*/ |
| 1221 | -.silde-wrap{ | |
| 1221 | +.swiper-container{ | |
| 1222 | 1222 | width: 1200px; |
| 1223 | 1223 | height: 444px; |
| 1224 | - overflow: hidden; | |
| 1225 | - position: absolute; | |
| 1226 | - top:50%; | |
| 1227 | - left: 50%; | |
| 1228 | - margin-left: -600px; | |
| 1229 | - margin-top: -222px; | |
| 1224 | + /*overflow: hidden;*/ | |
| 1225 | + /*position: absolute;*/ | |
| 1226 | + /*!*top:50%;*!*/ | |
| 1227 | + /*!*left: 50%;*!*/ | |
| 1228 | + /*margin-left: -600px;*/ | |
| 1229 | + /*margin-top: -222px;*/ | |
| 1230 | 1230 | |
| 1231 | 1231 | } |
| 1232 | 1232 | .parking-wrap{ | ... | ... |
css/swiper.css
0 → 100755
| 1 | +/** | |
| 2 | + * Swiper 4.4.6 | |
| 3 | + * Most modern mobile touch slider and framework with hardware accelerated transitions | |
| 4 | + * http://www.idangero.us/swiper/ | |
| 5 | + * | |
| 6 | + * Copyright 2014-2018 Vladimir Kharlampidi | |
| 7 | + * | |
| 8 | + * Released under the MIT License | |
| 9 | + * | |
| 10 | + * Released on: December 19, 2018 | |
| 11 | + */ | |
| 12 | +.swiper-container { | |
| 13 | + margin: 0 auto; | |
| 14 | + position: relative; | |
| 15 | + overflow: hidden; | |
| 16 | + list-style: none; | |
| 17 | + padding: 0; | |
| 18 | + /* Fix of Webkit flickering */ | |
| 19 | + z-index: 1; | |
| 20 | +} | |
| 21 | +.swiper-container-no-flexbox .swiper-slide { | |
| 22 | + float: left; | |
| 23 | +} | |
| 24 | +.swiper-container-vertical > .swiper-wrapper { | |
| 25 | + -webkit-box-orient: vertical; | |
| 26 | + -webkit-box-direction: normal; | |
| 27 | + -webkit-flex-direction: column; | |
| 28 | + -ms-flex-direction: column; | |
| 29 | + flex-direction: column; | |
| 30 | +} | |
| 31 | +.swiper-wrapper { | |
| 32 | + position: relative; | |
| 33 | + width: 100%; | |
| 34 | + height: 100%; | |
| 35 | + z-index: 1; | |
| 36 | + display: -webkit-box; | |
| 37 | + display: -webkit-flex; | |
| 38 | + display: -ms-flexbox; | |
| 39 | + display: flex; | |
| 40 | + -webkit-transition-property: -webkit-transform; | |
| 41 | + transition-property: -webkit-transform; | |
| 42 | + -o-transition-property: transform; | |
| 43 | + transition-property: transform; | |
| 44 | + transition-property: transform, -webkit-transform; | |
| 45 | + -webkit-box-sizing: content-box; | |
| 46 | + box-sizing: content-box; | |
| 47 | +} | |
| 48 | +.swiper-container-android .swiper-slide, | |
| 49 | +.swiper-wrapper { | |
| 50 | + -webkit-transform: translate3d(0px, 0, 0); | |
| 51 | + transform: translate3d(0px, 0, 0); | |
| 52 | +} | |
| 53 | +.swiper-container-multirow > .swiper-wrapper { | |
| 54 | + -webkit-flex-wrap: wrap; | |
| 55 | + -ms-flex-wrap: wrap; | |
| 56 | + flex-wrap: wrap; | |
| 57 | +} | |
| 58 | +.swiper-container-free-mode > .swiper-wrapper { | |
| 59 | + -webkit-transition-timing-function: ease-out; | |
| 60 | + -o-transition-timing-function: ease-out; | |
| 61 | + transition-timing-function: ease-out; | |
| 62 | + margin: 0 auto; | |
| 63 | +} | |
| 64 | +.swiper-slide { | |
| 65 | + -webkit-flex-shrink: 0; | |
| 66 | + -ms-flex-negative: 0; | |
| 67 | + flex-shrink: 0; | |
| 68 | + width: 100%; | |
| 69 | + height: 100%; | |
| 70 | + position: relative; | |
| 71 | + -webkit-transition-property: -webkit-transform; | |
| 72 | + transition-property: -webkit-transform; | |
| 73 | + -o-transition-property: transform; | |
| 74 | + transition-property: transform; | |
| 75 | + transition-property: transform, -webkit-transform; | |
| 76 | +} | |
| 77 | +.swiper-slide-invisible-blank { | |
| 78 | + visibility: hidden; | |
| 79 | +} | |
| 80 | +/* Auto Height */ | |
| 81 | +.swiper-container-autoheight, | |
| 82 | +.swiper-container-autoheight .swiper-slide { | |
| 83 | + height: auto; | |
| 84 | +} | |
| 85 | +.swiper-container-autoheight .swiper-wrapper { | |
| 86 | + -webkit-box-align: start; | |
| 87 | + -webkit-align-items: flex-start; | |
| 88 | + -ms-flex-align: start; | |
| 89 | + align-items: flex-start; | |
| 90 | + -webkit-transition-property: height, -webkit-transform; | |
| 91 | + transition-property: height, -webkit-transform; | |
| 92 | + -o-transition-property: transform, height; | |
| 93 | + transition-property: transform, height; | |
| 94 | + transition-property: transform, height, -webkit-transform; | |
| 95 | +} | |
| 96 | +/* 3D Effects */ | |
| 97 | +.swiper-container-3d { | |
| 98 | + -webkit-perspective: 1200px; | |
| 99 | + perspective: 1200px; | |
| 100 | +} | |
| 101 | +.swiper-container-3d .swiper-wrapper, | |
| 102 | +.swiper-container-3d .swiper-slide, | |
| 103 | +.swiper-container-3d .swiper-slide-shadow-left, | |
| 104 | +.swiper-container-3d .swiper-slide-shadow-right, | |
| 105 | +.swiper-container-3d .swiper-slide-shadow-top, | |
| 106 | +.swiper-container-3d .swiper-slide-shadow-bottom, | |
| 107 | +.swiper-container-3d .swiper-cube-shadow { | |
| 108 | + -webkit-transform-style: preserve-3d; | |
| 109 | + transform-style: preserve-3d; | |
| 110 | +} | |
| 111 | +.swiper-container-3d .swiper-slide-shadow-left, | |
| 112 | +.swiper-container-3d .swiper-slide-shadow-right, | |
| 113 | +.swiper-container-3d .swiper-slide-shadow-top, | |
| 114 | +.swiper-container-3d .swiper-slide-shadow-bottom { | |
| 115 | + position: absolute; | |
| 116 | + left: 0; | |
| 117 | + top: 0; | |
| 118 | + width: 100%; | |
| 119 | + height: 100%; | |
| 120 | + pointer-events: none; | |
| 121 | + z-index: 10; | |
| 122 | +} | |
| 123 | +.swiper-container-3d .swiper-slide-shadow-left { | |
| 124 | + background-image: -webkit-gradient(linear, right top, left top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0))); | |
| 125 | + background-image: -webkit-linear-gradient(right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 126 | + background-image: -o-linear-gradient(right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 127 | + background-image: linear-gradient(to left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 128 | +} | |
| 129 | +.swiper-container-3d .swiper-slide-shadow-right { | |
| 130 | + background-image: -webkit-gradient(linear, left top, right top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0))); | |
| 131 | + background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 132 | + background-image: -o-linear-gradient(left, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 133 | + background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 134 | +} | |
| 135 | +.swiper-container-3d .swiper-slide-shadow-top { | |
| 136 | + background-image: -webkit-gradient(linear, left bottom, left top, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0))); | |
| 137 | + background-image: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 138 | + background-image: -o-linear-gradient(bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 139 | + background-image: linear-gradient(to top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 140 | +} | |
| 141 | +.swiper-container-3d .swiper-slide-shadow-bottom { | |
| 142 | + background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0.5)), to(rgba(0, 0, 0, 0))); | |
| 143 | + background-image: -webkit-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 144 | + background-image: -o-linear-gradient(top, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 145 | + background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0)); | |
| 146 | +} | |
| 147 | +/* IE10 Windows Phone 8 Fixes */ | |
| 148 | +.swiper-container-wp8-horizontal, | |
| 149 | +.swiper-container-wp8-horizontal > .swiper-wrapper { | |
| 150 | + -ms-touch-action: pan-y; | |
| 151 | + touch-action: pan-y; | |
| 152 | +} | |
| 153 | +.swiper-container-wp8-vertical, | |
| 154 | +.swiper-container-wp8-vertical > .swiper-wrapper { | |
| 155 | + -ms-touch-action: pan-x; | |
| 156 | + touch-action: pan-x; | |
| 157 | +} | |
| 158 | +.swiper-button-prev, | |
| 159 | +.swiper-button-next { | |
| 160 | + position: absolute; | |
| 161 | + top: 50%; | |
| 162 | + width: 27px; | |
| 163 | + height: 44px; | |
| 164 | + margin-top: -22px; | |
| 165 | + z-index: 10; | |
| 166 | + cursor: pointer; | |
| 167 | + background-size: 27px 44px; | |
| 168 | + background-position: center; | |
| 169 | + background-repeat: no-repeat; | |
| 170 | +} | |
| 171 | +.swiper-button-prev.swiper-button-disabled, | |
| 172 | +.swiper-button-next.swiper-button-disabled { | |
| 173 | + opacity: 0.35; | |
| 174 | + cursor: auto; | |
| 175 | + pointer-events: none; | |
| 176 | +} | |
| 177 | +.swiper-button-prev, | |
| 178 | +.swiper-container-rtl .swiper-button-next { | |
| 179 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E"); | |
| 180 | + left: 10px; | |
| 181 | + right: auto; | |
| 182 | +} | |
| 183 | +.swiper-button-next, | |
| 184 | +.swiper-container-rtl .swiper-button-prev { | |
| 185 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E"); | |
| 186 | + right: 10px; | |
| 187 | + left: auto; | |
| 188 | +} | |
| 189 | +.swiper-button-prev.swiper-button-white, | |
| 190 | +.swiper-container-rtl .swiper-button-next.swiper-button-white { | |
| 191 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23ffffff'%2F%3E%3C%2Fsvg%3E"); | |
| 192 | +} | |
| 193 | +.swiper-button-next.swiper-button-white, | |
| 194 | +.swiper-container-rtl .swiper-button-prev.swiper-button-white { | |
| 195 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23ffffff'%2F%3E%3C%2Fsvg%3E"); | |
| 196 | +} | |
| 197 | +.swiper-button-prev.swiper-button-black, | |
| 198 | +.swiper-container-rtl .swiper-button-next.swiper-button-black { | |
| 199 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E"); | |
| 200 | +} | |
| 201 | +.swiper-button-next.swiper-button-black, | |
| 202 | +.swiper-container-rtl .swiper-button-prev.swiper-button-black { | |
| 203 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23000000'%2F%3E%3C%2Fsvg%3E"); | |
| 204 | +} | |
| 205 | +.swiper-button-lock { | |
| 206 | + display: none; | |
| 207 | +} | |
| 208 | +.swiper-pagination { | |
| 209 | + position: absolute; | |
| 210 | + text-align: center; | |
| 211 | + -webkit-transition: 300ms opacity; | |
| 212 | + -o-transition: 300ms opacity; | |
| 213 | + transition: 300ms opacity; | |
| 214 | + -webkit-transform: translate3d(0, 0, 0); | |
| 215 | + transform: translate3d(0, 0, 0); | |
| 216 | + z-index: 10; | |
| 217 | +} | |
| 218 | +.swiper-pagination.swiper-pagination-hidden { | |
| 219 | + opacity: 0; | |
| 220 | +} | |
| 221 | +/* Common Styles */ | |
| 222 | +.swiper-pagination-fraction, | |
| 223 | +.swiper-pagination-custom, | |
| 224 | +.swiper-container-horizontal > .swiper-pagination-bullets { | |
| 225 | + bottom: 10px; | |
| 226 | + left: 0; | |
| 227 | + width: 100%; | |
| 228 | +} | |
| 229 | +/* Bullets */ | |
| 230 | +.swiper-pagination-bullets-dynamic { | |
| 231 | + overflow: hidden; | |
| 232 | + font-size: 0; | |
| 233 | +} | |
| 234 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet { | |
| 235 | + -webkit-transform: scale(0.33); | |
| 236 | + -ms-transform: scale(0.33); | |
| 237 | + transform: scale(0.33); | |
| 238 | + position: relative; | |
| 239 | +} | |
| 240 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active { | |
| 241 | + -webkit-transform: scale(1); | |
| 242 | + -ms-transform: scale(1); | |
| 243 | + transform: scale(1); | |
| 244 | +} | |
| 245 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-main { | |
| 246 | + -webkit-transform: scale(1); | |
| 247 | + -ms-transform: scale(1); | |
| 248 | + transform: scale(1); | |
| 249 | +} | |
| 250 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev { | |
| 251 | + -webkit-transform: scale(0.66); | |
| 252 | + -ms-transform: scale(0.66); | |
| 253 | + transform: scale(0.66); | |
| 254 | +} | |
| 255 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-prev-prev { | |
| 256 | + -webkit-transform: scale(0.33); | |
| 257 | + -ms-transform: scale(0.33); | |
| 258 | + transform: scale(0.33); | |
| 259 | +} | |
| 260 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-next { | |
| 261 | + -webkit-transform: scale(0.66); | |
| 262 | + -ms-transform: scale(0.66); | |
| 263 | + transform: scale(0.66); | |
| 264 | +} | |
| 265 | +.swiper-pagination-bullets-dynamic .swiper-pagination-bullet-active-next-next { | |
| 266 | + -webkit-transform: scale(0.33); | |
| 267 | + -ms-transform: scale(0.33); | |
| 268 | + transform: scale(0.33); | |
| 269 | +} | |
| 270 | +.swiper-pagination-bullet { | |
| 271 | + width: 8px; | |
| 272 | + height: 8px; | |
| 273 | + display: inline-block; | |
| 274 | + border-radius: 100%; | |
| 275 | + background: #000; | |
| 276 | + opacity: 0.2; | |
| 277 | +} | |
| 278 | +button.swiper-pagination-bullet { | |
| 279 | + border: none; | |
| 280 | + margin: 0; | |
| 281 | + padding: 0; | |
| 282 | + -webkit-box-shadow: none; | |
| 283 | + box-shadow: none; | |
| 284 | + -webkit-appearance: none; | |
| 285 | + -moz-appearance: none; | |
| 286 | + appearance: none; | |
| 287 | +} | |
| 288 | +.swiper-pagination-clickable .swiper-pagination-bullet { | |
| 289 | + cursor: pointer; | |
| 290 | +} | |
| 291 | +.swiper-pagination-bullet-active { | |
| 292 | + opacity: 1; | |
| 293 | + background: #007aff; | |
| 294 | +} | |
| 295 | +.swiper-container-vertical > .swiper-pagination-bullets { | |
| 296 | + right: 10px; | |
| 297 | + top: 50%; | |
| 298 | + -webkit-transform: translate3d(0px, -50%, 0); | |
| 299 | + transform: translate3d(0px, -50%, 0); | |
| 300 | +} | |
| 301 | +.swiper-container-vertical > .swiper-pagination-bullets .swiper-pagination-bullet { | |
| 302 | + margin: 6px 0; | |
| 303 | + display: block; | |
| 304 | +} | |
| 305 | +.swiper-container-vertical > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic { | |
| 306 | + top: 50%; | |
| 307 | + -webkit-transform: translateY(-50%); | |
| 308 | + -ms-transform: translateY(-50%); | |
| 309 | + transform: translateY(-50%); | |
| 310 | + width: 8px; | |
| 311 | +} | |
| 312 | +.swiper-container-vertical > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet { | |
| 313 | + display: inline-block; | |
| 314 | + -webkit-transition: 200ms top, 200ms -webkit-transform; | |
| 315 | + transition: 200ms top, 200ms -webkit-transform; | |
| 316 | + -o-transition: 200ms transform, 200ms top; | |
| 317 | + transition: 200ms transform, 200ms top; | |
| 318 | + transition: 200ms transform, 200ms top, 200ms -webkit-transform; | |
| 319 | +} | |
| 320 | +.swiper-container-horizontal > .swiper-pagination-bullets .swiper-pagination-bullet { | |
| 321 | + margin: 0 4px; | |
| 322 | +} | |
| 323 | +.swiper-container-horizontal > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic { | |
| 324 | + left: 50%; | |
| 325 | + -webkit-transform: translateX(-50%); | |
| 326 | + -ms-transform: translateX(-50%); | |
| 327 | + transform: translateX(-50%); | |
| 328 | + white-space: nowrap; | |
| 329 | +} | |
| 330 | +.swiper-container-horizontal > .swiper-pagination-bullets.swiper-pagination-bullets-dynamic .swiper-pagination-bullet { | |
| 331 | + -webkit-transition: 200ms left, 200ms -webkit-transform; | |
| 332 | + transition: 200ms left, 200ms -webkit-transform; | |
| 333 | + -o-transition: 200ms transform, 200ms left; | |
| 334 | + transition: 200ms transform, 200ms left; | |
| 335 | + transition: 200ms transform, 200ms left, 200ms -webkit-transform; | |
| 336 | +} | |
| 337 | +.swiper-container-horizontal.swiper-container-rtl > .swiper-pagination-bullets-dynamic .swiper-pagination-bullet { | |
| 338 | + -webkit-transition: 200ms right, 200ms -webkit-transform; | |
| 339 | + transition: 200ms right, 200ms -webkit-transform; | |
| 340 | + -o-transition: 200ms transform, 200ms right; | |
| 341 | + transition: 200ms transform, 200ms right; | |
| 342 | + transition: 200ms transform, 200ms right, 200ms -webkit-transform; | |
| 343 | +} | |
| 344 | +/* Progress */ | |
| 345 | +.swiper-pagination-progressbar { | |
| 346 | + background: rgba(0, 0, 0, 0.25); | |
| 347 | + position: absolute; | |
| 348 | +} | |
| 349 | +.swiper-pagination-progressbar .swiper-pagination-progressbar-fill { | |
| 350 | + background: #007aff; | |
| 351 | + position: absolute; | |
| 352 | + left: 0; | |
| 353 | + top: 0; | |
| 354 | + width: 100%; | |
| 355 | + height: 100%; | |
| 356 | + -webkit-transform: scale(0); | |
| 357 | + -ms-transform: scale(0); | |
| 358 | + transform: scale(0); | |
| 359 | + -webkit-transform-origin: left top; | |
| 360 | + -ms-transform-origin: left top; | |
| 361 | + transform-origin: left top; | |
| 362 | +} | |
| 363 | +.swiper-container-rtl .swiper-pagination-progressbar .swiper-pagination-progressbar-fill { | |
| 364 | + -webkit-transform-origin: right top; | |
| 365 | + -ms-transform-origin: right top; | |
| 366 | + transform-origin: right top; | |
| 367 | +} | |
| 368 | +.swiper-container-horizontal > .swiper-pagination-progressbar, | |
| 369 | +.swiper-container-vertical > .swiper-pagination-progressbar.swiper-pagination-progressbar-opposite { | |
| 370 | + width: 100%; | |
| 371 | + height: 4px; | |
| 372 | + left: 0; | |
| 373 | + top: 0; | |
| 374 | +} | |
| 375 | +.swiper-container-vertical > .swiper-pagination-progressbar, | |
| 376 | +.swiper-container-horizontal > .swiper-pagination-progressbar.swiper-pagination-progressbar-opposite { | |
| 377 | + width: 4px; | |
| 378 | + height: 100%; | |
| 379 | + left: 0; | |
| 380 | + top: 0; | |
| 381 | +} | |
| 382 | +.swiper-pagination-white .swiper-pagination-bullet-active { | |
| 383 | + background: #ffffff; | |
| 384 | +} | |
| 385 | +.swiper-pagination-progressbar.swiper-pagination-white { | |
| 386 | + background: rgba(255, 255, 255, 0.25); | |
| 387 | +} | |
| 388 | +.swiper-pagination-progressbar.swiper-pagination-white .swiper-pagination-progressbar-fill { | |
| 389 | + background: #ffffff; | |
| 390 | +} | |
| 391 | +.swiper-pagination-black .swiper-pagination-bullet-active { | |
| 392 | + background: #000000; | |
| 393 | +} | |
| 394 | +.swiper-pagination-progressbar.swiper-pagination-black { | |
| 395 | + background: rgba(0, 0, 0, 0.25); | |
| 396 | +} | |
| 397 | +.swiper-pagination-progressbar.swiper-pagination-black .swiper-pagination-progressbar-fill { | |
| 398 | + background: #000000; | |
| 399 | +} | |
| 400 | +.swiper-pagination-lock { | |
| 401 | + display: none; | |
| 402 | +} | |
| 403 | +/* Scrollbar */ | |
| 404 | +.swiper-scrollbar { | |
| 405 | + border-radius: 10px; | |
| 406 | + position: relative; | |
| 407 | + -ms-touch-action: none; | |
| 408 | + background: rgba(0, 0, 0, 0.1); | |
| 409 | +} | |
| 410 | +.swiper-container-horizontal > .swiper-scrollbar { | |
| 411 | + position: absolute; | |
| 412 | + left: 1%; | |
| 413 | + bottom: 3px; | |
| 414 | + z-index: 50; | |
| 415 | + height: 5px; | |
| 416 | + width: 98%; | |
| 417 | +} | |
| 418 | +.swiper-container-vertical > .swiper-scrollbar { | |
| 419 | + position: absolute; | |
| 420 | + right: 3px; | |
| 421 | + top: 1%; | |
| 422 | + z-index: 50; | |
| 423 | + width: 5px; | |
| 424 | + height: 98%; | |
| 425 | +} | |
| 426 | +.swiper-scrollbar-drag { | |
| 427 | + height: 100%; | |
| 428 | + width: 100%; | |
| 429 | + position: relative; | |
| 430 | + background: rgba(0, 0, 0, 0.5); | |
| 431 | + border-radius: 10px; | |
| 432 | + left: 0; | |
| 433 | + top: 0; | |
| 434 | +} | |
| 435 | +.swiper-scrollbar-cursor-drag { | |
| 436 | + cursor: move; | |
| 437 | +} | |
| 438 | +.swiper-scrollbar-lock { | |
| 439 | + display: none; | |
| 440 | +} | |
| 441 | +.swiper-zoom-container { | |
| 442 | + width: 100%; | |
| 443 | + height: 100%; | |
| 444 | + display: -webkit-box; | |
| 445 | + display: -webkit-flex; | |
| 446 | + display: -ms-flexbox; | |
| 447 | + display: flex; | |
| 448 | + -webkit-box-pack: center; | |
| 449 | + -webkit-justify-content: center; | |
| 450 | + -ms-flex-pack: center; | |
| 451 | + justify-content: center; | |
| 452 | + -webkit-box-align: center; | |
| 453 | + -webkit-align-items: center; | |
| 454 | + -ms-flex-align: center; | |
| 455 | + align-items: center; | |
| 456 | + text-align: center; | |
| 457 | +} | |
| 458 | +.swiper-zoom-container > img, | |
| 459 | +.swiper-zoom-container > svg, | |
| 460 | +.swiper-zoom-container > canvas { | |
| 461 | + max-width: 100%; | |
| 462 | + max-height: 100%; | |
| 463 | + -o-object-fit: contain; | |
| 464 | + object-fit: contain; | |
| 465 | +} | |
| 466 | +.swiper-slide-zoomed { | |
| 467 | + cursor: move; | |
| 468 | +} | |
| 469 | +/* Preloader */ | |
| 470 | +.swiper-lazy-preloader { | |
| 471 | + width: 42px; | |
| 472 | + height: 42px; | |
| 473 | + position: absolute; | |
| 474 | + left: 50%; | |
| 475 | + top: 50%; | |
| 476 | + margin-left: -21px; | |
| 477 | + margin-top: -21px; | |
| 478 | + z-index: 10; | |
| 479 | + -webkit-transform-origin: 50%; | |
| 480 | + -ms-transform-origin: 50%; | |
| 481 | + transform-origin: 50%; | |
| 482 | + -webkit-animation: swiper-preloader-spin 1s steps(12, end) infinite; | |
| 483 | + animation: swiper-preloader-spin 1s steps(12, end) infinite; | |
| 484 | +} | |
| 485 | +.swiper-lazy-preloader:after { | |
| 486 | + display: block; | |
| 487 | + content: ''; | |
| 488 | + width: 100%; | |
| 489 | + height: 100%; | |
| 490 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%236c6c6c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"); | |
| 491 | + background-position: 50%; | |
| 492 | + background-size: 100%; | |
| 493 | + background-repeat: no-repeat; | |
| 494 | +} | |
| 495 | +.swiper-lazy-preloader-white:after { | |
| 496 | + background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%23fff'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E"); | |
| 497 | +} | |
| 498 | +@-webkit-keyframes swiper-preloader-spin { | |
| 499 | + 100% { | |
| 500 | + -webkit-transform: rotate(360deg); | |
| 501 | + transform: rotate(360deg); | |
| 502 | + } | |
| 503 | +} | |
| 504 | +@keyframes swiper-preloader-spin { | |
| 505 | + 100% { | |
| 506 | + -webkit-transform: rotate(360deg); | |
| 507 | + transform: rotate(360deg); | |
| 508 | + } | |
| 509 | +} | |
| 510 | +/* a11y */ | |
| 511 | +.swiper-container .swiper-notification { | |
| 512 | + position: absolute; | |
| 513 | + left: 0; | |
| 514 | + top: 0; | |
| 515 | + pointer-events: none; | |
| 516 | + opacity: 0; | |
| 517 | + z-index: -1000; | |
| 518 | +} | |
| 519 | +.swiper-container-fade.swiper-container-free-mode .swiper-slide { | |
| 520 | + -webkit-transition-timing-function: ease-out; | |
| 521 | + -o-transition-timing-function: ease-out; | |
| 522 | + transition-timing-function: ease-out; | |
| 523 | +} | |
| 524 | +.swiper-container-fade .swiper-slide { | |
| 525 | + pointer-events: none; | |
| 526 | + -webkit-transition-property: opacity; | |
| 527 | + -o-transition-property: opacity; | |
| 528 | + transition-property: opacity; | |
| 529 | +} | |
| 530 | +.swiper-container-fade .swiper-slide .swiper-slide { | |
| 531 | + pointer-events: none; | |
| 532 | +} | |
| 533 | +.swiper-container-fade .swiper-slide-active, | |
| 534 | +.swiper-container-fade .swiper-slide-active .swiper-slide-active { | |
| 535 | + pointer-events: auto; | |
| 536 | +} | |
| 537 | +.swiper-container-cube { | |
| 538 | + overflow: visible; | |
| 539 | +} | |
| 540 | +.swiper-container-cube .swiper-slide { | |
| 541 | + pointer-events: none; | |
| 542 | + -webkit-backface-visibility: hidden; | |
| 543 | + backface-visibility: hidden; | |
| 544 | + z-index: 1; | |
| 545 | + visibility: hidden; | |
| 546 | + -webkit-transform-origin: 0 0; | |
| 547 | + -ms-transform-origin: 0 0; | |
| 548 | + transform-origin: 0 0; | |
| 549 | + width: 100%; | |
| 550 | + height: 100%; | |
| 551 | +} | |
| 552 | +.swiper-container-cube .swiper-slide .swiper-slide { | |
| 553 | + pointer-events: none; | |
| 554 | +} | |
| 555 | +.swiper-container-cube.swiper-container-rtl .swiper-slide { | |
| 556 | + -webkit-transform-origin: 100% 0; | |
| 557 | + -ms-transform-origin: 100% 0; | |
| 558 | + transform-origin: 100% 0; | |
| 559 | +} | |
| 560 | +.swiper-container-cube .swiper-slide-active, | |
| 561 | +.swiper-container-cube .swiper-slide-active .swiper-slide-active { | |
| 562 | + pointer-events: auto; | |
| 563 | +} | |
| 564 | +.swiper-container-cube .swiper-slide-active, | |
| 565 | +.swiper-container-cube .swiper-slide-next, | |
| 566 | +.swiper-container-cube .swiper-slide-prev, | |
| 567 | +.swiper-container-cube .swiper-slide-next + .swiper-slide { | |
| 568 | + pointer-events: auto; | |
| 569 | + visibility: visible; | |
| 570 | +} | |
| 571 | +.swiper-container-cube .swiper-slide-shadow-top, | |
| 572 | +.swiper-container-cube .swiper-slide-shadow-bottom, | |
| 573 | +.swiper-container-cube .swiper-slide-shadow-left, | |
| 574 | +.swiper-container-cube .swiper-slide-shadow-right { | |
| 575 | + z-index: 0; | |
| 576 | + -webkit-backface-visibility: hidden; | |
| 577 | + backface-visibility: hidden; | |
| 578 | +} | |
| 579 | +.swiper-container-cube .swiper-cube-shadow { | |
| 580 | + position: absolute; | |
| 581 | + left: 0; | |
| 582 | + bottom: 0px; | |
| 583 | + width: 100%; | |
| 584 | + height: 100%; | |
| 585 | + background: #000; | |
| 586 | + opacity: 0.6; | |
| 587 | + -webkit-filter: blur(50px); | |
| 588 | + filter: blur(50px); | |
| 589 | + z-index: 0; | |
| 590 | +} | |
| 591 | +.swiper-container-flip { | |
| 592 | + overflow: visible; | |
| 593 | +} | |
| 594 | +.swiper-container-flip .swiper-slide { | |
| 595 | + pointer-events: none; | |
| 596 | + -webkit-backface-visibility: hidden; | |
| 597 | + backface-visibility: hidden; | |
| 598 | + z-index: 1; | |
| 599 | +} | |
| 600 | +.swiper-container-flip .swiper-slide .swiper-slide { | |
| 601 | + pointer-events: none; | |
| 602 | +} | |
| 603 | +.swiper-container-flip .swiper-slide-active, | |
| 604 | +.swiper-container-flip .swiper-slide-active .swiper-slide-active { | |
| 605 | + pointer-events: auto; | |
| 606 | +} | |
| 607 | +.swiper-container-flip .swiper-slide-shadow-top, | |
| 608 | +.swiper-container-flip .swiper-slide-shadow-bottom, | |
| 609 | +.swiper-container-flip .swiper-slide-shadow-left, | |
| 610 | +.swiper-container-flip .swiper-slide-shadow-right { | |
| 611 | + z-index: 0; | |
| 612 | + -webkit-backface-visibility: hidden; | |
| 613 | + backface-visibility: hidden; | |
| 614 | +} | |
| 615 | +.swiper-container-coverflow .swiper-wrapper { | |
| 616 | + /* Windows 8 IE 10 fix */ | |
| 617 | + -ms-perspective: 1200px; | |
| 618 | +} | ... | ... |
index.html
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | <link rel="stylesheet" href="css/common.css?v=1"> |
| 14 | 14 | <link rel="stylesheet" href="css/index.css?a=1"> |
| 15 | 15 | <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> |
| 16 | + <link rel="stylesheet" href="css/swiper.css"> | |
| 16 | 17 | <script src="js/config.js"></script> |
| 17 | 18 | <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> |
| 18 | 19 | </head> |
| ... | ... | @@ -31,18 +32,15 @@ |
| 31 | 32 | </div> |
| 32 | 33 | </header> |
| 33 | 34 | <!--内容--> |
| 34 | -<div class="main-con clearfix"> | |
| 35 | +<div class="main-con"> | |
| 35 | 36 | |
| 36 | - <ul class="silde-wrap" id="box"> | |
| 37 | - <!-- | |
| 38 | - <li class="parking-wrap" data-link="http://ent.dyszt.com/parkingcloud/admin/SubMenus/index.html"></li> | |
| 39 | - <li class="platform-wrap" data-link="http://zteits.gnway.cc:8021/cfgovcloud/pages/total.html"></li> | |
| 40 | - <li class="api-wrap" data-link="http://www.rnting.com/api/index.html"></li> | |
| 41 | - <li class="gprmxc-wrap" data-link="http://gprmxc.renniting.cn/home/home.html"></li> | |
| 42 | - <li class="caruser-wrap" data-link="http://121.40.121.40:8070/v2.1/html/user_login.html"></li> | |
| 43 | - --> | |
| 44 | - </ul> | |
| 37 | + <div class="swiper-container"> | |
| 38 | + <div class="swiper-wrapper" id="box"> | |
| 39 | + </div> | |
| 40 | + <!-- Add Arrows --> | |
| 45 | 41 | |
| 42 | + </div> | |
| 43 | + <!--</div>--> | |
| 46 | 44 | </div> |
| 47 | 45 | <!--底部--> |
| 48 | 46 | <footer> |
| ... | ... | @@ -68,7 +66,7 @@ |
| 68 | 66 | <script src="js/jquery.min.js"></script> |
| 69 | 67 | <script src="js/unit.js"></script> |
| 70 | 68 | <script src="bootstrap/js/bootstrap.min.js"></script> |
| 71 | -<script src="js/slider.js"></script> | |
| 69 | +<script src="js/swiper.js"></script> | |
| 72 | 70 | <script type="text/javascript"> |
| 73 | 71 | document.write("<s" + "cript type='text/javascript' src='js/index.js?ver" + Math.random() + "'></s" + "cript>"); |
| 74 | 72 | </script> | ... | ... |
js/index.js
| ... | ... | @@ -69,35 +69,35 @@ var fun={ |
| 69 | 69 | arrnewList.push(item) |
| 70 | 70 | } |
| 71 | 71 | }) |
| 72 | - console.log(arrlist) | |
| 72 | + // console.log(arrlist) | |
| 73 | 73 | var sysOpProList = arrlist.concat(arrnewList) |
| 74 | 74 | console.log(sysOpProList) |
| 75 | 75 | for(var i=0;i<sysOpProList.length;i++){ |
| 76 | 76 | if(sysOpProList[i].projectCode=='BUSINESS_PLATFORM'){ |
| 77 | 77 | |
| 78 | - menuList+='<li class="parking-nav" data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 79 | - imgList+='<li class="parking-wrap" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 78 | + menuList+='<li class="parking-nav " data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 79 | + imgList+='<li class="parking-wrap swiper-slide" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | else if(sysOpProList[i].projectCode=='GOVERNMENT_PLATFORM'){ |
| 83 | 83 | |
| 84 | - menuList+='<li class="platform-nav" data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 85 | - imgList+='<li class="platform-wrap" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 84 | + menuList+='<li class="platform-nav " data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 85 | + imgList+='<li class="platform-wrap swiper-slide" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 86 | 86 | } |
| 87 | 87 | else if(sysOpProList[i].projectCode=='INTERFACE_PLATFORM'){ |
| 88 | 88 | |
| 89 | - menuList+='<li class="api-nav" data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 90 | - imgList+='<li class="api-wrap" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 89 | + menuList+='<li class="api-nav " data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 90 | + imgList+='<li class="api-wrap swiper-slide" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 91 | 91 | } |
| 92 | 92 | else if(sysOpProList[i].projectCode=='CAR_USER_PLATFORM'){ |
| 93 | 93 | |
| 94 | - menuList+='<li class="caruser-nav" data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 95 | - imgList+='<li class="caruser-wrap" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 94 | + menuList+='<li class="caruser-nav " data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 95 | + imgList+='<li class="caruser-wrap swiper-slide" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 96 | 96 | } |
| 97 | 97 | else if(sysOpProList[i].projectCode=='BEIAN_PLATFORM'){ |
| 98 | 98 | |
| 99 | - menuList+='<li class="gprmxc-nav" data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 100 | - imgList+='<li class="gprmxc-wrap" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 99 | + menuList+='<li class="gprmxc-nav " data-slideindex="'+i+'">'+sysOpProList[i].projectName+'</li>'; | |
| 100 | + imgList+='<li class="gprmxc-wrap swiper-slide" data-link="'+sysOpProList[i].projectUrl+'"><div class="guide-way">进入平台</div></li>'; | |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| ... | ... | @@ -132,24 +132,26 @@ $(document).on('click','#box li',function () { |
| 132 | 132 | } |
| 133 | 133 | window.open(link) |
| 134 | 134 | }) |
| 135 | -var $box = $('#box') | |
| 136 | -$box.boxSlider({ | |
| 137 | - speed: 1000 | |
| 138 | - , autoScroll: false | |
| 139 | - , timeout: 5000 | |
| 140 | - , next: '#next' | |
| 141 | - , prev: '#prev' | |
| 142 | - , pause: '#pause' | |
| 143 | - , effect: 'scrollHorz' | |
| 144 | - , blindCount: 15 | |
| 145 | - | |
| 146 | -}); | |
| 147 | - | |
| 148 | -$('#controls').on('click', 'li', function (ev) { | |
| 149 | - $('#controls li').removeClass('active'); | |
| 150 | - console.log($(this).data('slideindex')); | |
| 151 | - $box.boxSlider('showSlide', $(this).data('slideindex')); | |
| 152 | - $(this).addClass('active'); | |
| 153 | - //ev.preventDefault(); | |
| 154 | -}); | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | +var tabsSwiper = new Swiper('.swiper-container',{ | |
| 139 | + autoplay:false, | |
| 140 | + speed:1000, | |
| 141 | + | |
| 142 | +}) | |
| 143 | +$("#controls li").on('touchstart mousedown',function(e){ | |
| 144 | + var that=$(this); | |
| 145 | + // e.preventDefault() | |
| 146 | + // $(".tabs .active").removeClass('active') | |
| 147 | + // $(this).addClass('active') | |
| 148 | + tabsSwiper.slideTo( that.index() ) | |
| 149 | +}) | |
| 150 | + | |
| 151 | + | |
| 152 | +$("controls li").click(function(e){ | |
| 153 | + e.preventDefault() | |
| 154 | +}) | |
| 155 | + | |
| 156 | + | |
| 155 | 157 | ... | ... |
js/slider.js deleted
| 1 | -// JavaScript Document | |
| 2 | -(function(i,f,r){var g={},s=!0,p={},u={speed:800,timeout:5E3,autoScroll:!1,pauseOnHover:!1,effect:"scrollVert3d",perspective:1E3};i.jqBoxSlider=g;g.init=function(a){var b=f.extend({},u,a),d=g.slideAnimator(b.effect);return this.each(function(){var a=f(this),h=a.children(),e=f.extend({},b);a.data("bssettings",e);e.slideAnimator=d;e.slideAnimator.initialize(a,h,e);v(a,e);if(e.autoScroll&&(e.autointv=setInterval(function(){n(a)},e.timeout+e.speed),e.pauseOnHover))a.on("hover",o)})};g.playPause=function(){return this.each(function(){o.call(f(this))})}; | |
| 3 | - g.showSlide=function(a){a=parseInt(a,10);return this.each(function(){var b=f(this);q(b);n(b,a)})};g.registerAnimator=function(a,b){f.each(a.split(","),function(a,c){p[c]=b});b._cacheOriginalCSS=w;"function"===typeof b.configure&&b.configure(s,x)};g.slideAnimator=function(a){if("object"===typeof p[a])return p[a];throw Error("The slide animator for the "+a+" effect has not been registered");};g.option=function(a,b){return"undefined"===typeof b?(this.data("bssettings")||{})[a]:this.each(function(){var d= | |
| 4 | - f(this),c=d.data("bssettings")||{};c[a]=b;q(d,c);"effect"===a?(c.slideAnimator.destroy(d,c),c.slideAnimator=g.slideAnimator(b),c._slideFilter=null,c.bsfaceindex=0,c.slideAnimator.initialize(d,d.children(),c)):"function"===typeof c.slideAnimator.reset&&c.slideAnimator.reset(d,c)})};g.destroy=function(){return this.each(function(){var a=f(this),b=(a.data()||{}).bssettings;b&&"object"===typeof b.slideAnimator&&(b.autointv&&clearInterval(b.autointv),b.slideAnimator.destroy(a,b))})};var v=function(a,b){var d= | |
| 5 | - f();null!=b.next&&(d=d.add(f(b.next).on("click",{reverse:!1},t)));null!=b.prev&&(d=d.add(f(b.prev).on("click",{reverse:!0},t)));null!=b.pause&&(d=d.add(f(b.pause).on("click",y)));d.data("bsbox",a)},t=function(a){var b=f(this).data("bsbox");q(b);n(b,r,a.data.reverse);a.preventDefault()},y=function(a){var b=f(this),d=b.data("bsbox");o.call(d);b.toggleClass("paused");a.preventDefault()},o=function(a,b,d){var c=f(this);d||(d=c.data("bssettings"));if(null!=d.autointv||b)if(d.autointv=clearInterval(d.autointv), | |
| 6 | - !b)return;d.autointv=setInterval(function(){n(c)},d.timeout+d.speed)},n=function(a,b,d){var c=a.data("bssettings"),h=a.children(),e,k,j,g;null!=c._slideFilter&&(h="function"===typeof c._slideFilter?h.filter(function(b){return c._slideFilter.call(h,b,c)}):h.filter(c.slideFilter));e=c.bsfaceindex||0;k=z(e,h.length,d,b);a.hasClass("jbs-in-motion")||-1===k||(j=h.eq(e),g=h.eq(k),a.addClass("jbs-in-motion"),"function"===typeof c.onbefore&&c.onbefore.call(a,j,g,e,k),f.extend(c,c.slideAnimator.transition(f.extend({$box:a, | |
| 7 | - $slides:h,$currSlide:j,$nextSlide:g,reverse:d,currIndex:e,nextIndex:k},c))),setTimeout(function(){a.removeClass("jbs-in-motion");"function"===typeof c.onafter&&c.onafter.call(a,j,g,e,k)},c.speed),c.bsfaceindex=k)},q=function(a,b){b||(b=a.data("bssettings")||{});b.autoScroll&&o.call(a,r,!0,b)},z=function(a,b,d,c){null==c&&(c=d?0>a-1?b-1:a-1:a+1<b?a+1:0);return c===a||c>=b||0>c?-1:c},w=function(a,b,d,c){c="position top left display overflow width height".split(" ").concat(c||[]);d.origCSS||(d.origCSS= | |
| 8 | - {});d.origCSS[b]||(d.origCSS[b]={});f.each(c,function(h,e){d.origCSS[b][e]=a.css(e)})},x=function(){var a=document.body.style,b="";"webkitTransition"in a&&(b="-webkit-");"MozTransition"in a&&(b="-moz-");s="webkitPerspective"in a||"MozPerspective"in a||"perspective"in a;return b}();f.fn.boxSlider=function(a){return"string"===typeof a&&"function"===typeof g[a]?g[a].apply(this,Array.prototype.slice.call(arguments,1)):g.init.apply(this,arguments)};i.jqBoxSlider.registerAnimator("blindDown,blindLeft", | |
| 9 | - function(){var a=function(b,a){return this.get(b)!==a.$blinds.get(0)},b=function(b){return b.attr("src")||b.find("img").attr("src")},d=function(b){switch(b.effect){case "blindDown":return{top:"100%"};case "blindLeft":return{width:"0px"}}},c=function(a){var e={backgroundImage:"url("+b(a.$nextSlide)+")"};switch(a.effect){case "blindDown":e.top="0px";break;case "blindLeft":e.width=a.blindSize}return e};return{initialize:function(d,e,c){var j=f(document.createElement("div")),g=b(e.eq(0)),l,m=0;c.blindCount|| | |
| 10 | - (c.blindCount=10);c.blindSpeed=c.speed;c.blindintv=c.speed/c.blindCount;c.speed+=c.blindintv*c.blindCount;c.blindSize=d.width()/c.blindCount;this._cacheOriginalCSS(d,"box",c);for(this._cacheOriginalCSS(e,"slides",c);m<c.blindCount;++m)l=m*c.blindSize,f(document.createElement("div")).css({position:"absolute",top:"0px",left:l+"px",width:c.blindSize+"px",height:"100%",backgroundImage:"url("+g+")",backgroundPosition:-l+"px 0px"}).appendTo(j);d.css("position","relative");d.css({height:e.css("height"), | |
| 11 | - overflow:"hidden"});e.css({zIndex:1,position:"absolute",top:0,left:0});j.css({position:"absolute",top:"0px",left:"0px",width:"100%",height:"100%",zIndex:2}).appendTo(d);c.$blinds=j;c._slideFilter=a},transition:function(b){b.$box.height();var a=b.$blinds.children();b.$slides.hide();b.$nextSlide.show();a.each(function(a,c){(function(){var e=b.blindintv*a,g=f(c);setTimeout(function(){g.animate(d(b),b.blindSpeed)},e)})()});setTimeout(function(){a.css(c(b))},b.speed)},destroy:function(b,a){a.$blinds.remove(); | |
| 12 | - b.css(a.origCSS.box);b.children().css(a.origCSS.slides);a.speed=a.blindSpeed;delete a.blindCount;delete a.blindSpeed;delete a.blindintv;delete a.$blinds;delete a.blindSize}}}());i.jqBoxSlider.registerAnimator("fade",function(){var a={initialize:function(b,d,c){a._cacheOriginalCSS(b,"box",c);a._cacheOriginalCSS(d,"slides",c);-1!=="static inherit".indexOf(b.css("position"))&&b.css("position","relative");b.css({height:d.eq(0).height(),overflow:"hidden"});d.css({position:"absolute",top:0,left:0}).filter(":gt(0)").hide()}, | |
| 13 | - transition:function(b){b.$nextSlide.fadeIn(b.speed);b.$currSlide.fadeOut(b.speed)},destroy:function(b,a){b.children().css(a.origCSS.slides);b.css(a.origCSS.box)}};return a}());i.jqBoxSlider.registerAnimator("scrollVert3d,scrollHorz3d",function(){var a={},b=!1,d="";a.configure=function(a,c){b=a;d=c};a.initialize=function(c,e,f){var g=c.parent(),i=g.innerWidth(),l=g.innerHeight(),m={position:"absolute",top:0,left:0,width:i,height:l};a._cacheOriginalCSS(c,"box",f,[d+"transform",d+"transition",d+"transform-style"]); | |
| 14 | - a._cacheOriginalCSS(e,"slides",f,[d+"transform"]);a._cacheOriginalCSS(e,"viewport",f,[d+"perspective"]);e.css(m);c.css(m);-1!=="static inherit".indexOf(g.css("position"))&&g.css("position","relative");b?(f.translateZ="scrollVert3d"===f.effect?l/2:i/2,f.bsangle=0,g.css(d+"perspective",f.perspective),g.css("overflow","visible"),c.css(d+"transform-style","preserve-3d"),c.css(d+"transform","translate3d(0, 0, -"+f.translateZ+"px)"),e.eq(0).css(d+"transform","rotate3d(0, 1, 0, 0deg) translate3d(0, 0, "+ | |
| 15 | - f.translateZ+"px)"),setTimeout(function(){a.reset(c,f)},10)):e.filter(":gt(0)").hide()};a.reset=function(b,a){b.css(d+"transition",d+"transform "+(a.speed/1E3+"s"))};a.transition=function(a){var e=a.bsangle+(a.reverse?90:-90),f="scrollVert3d"===a.effect;if(b)return 0===e&&(e=a.reverse?360:-360),a.$currSlide.css("z-index",1),a.$slides.filter(function(b){return a.currIndex!==b}).css(d+"transform","none").css("display","none"),a.$nextSlide.css(d+"transform",c(e,f)+" translate3d(0, 0,"+a.translateZ+"px)").css({display:"block", | |
| 16 | - zIndex:2}),a.$box.css(d+"transform","translate3d(0, 0, -"+a.translateZ+"px) rotate3d("+(f?"1, 0, 0, ":"0, 1, 0, ")+e+"deg)"),360===Math.abs(e)&&(a.$box.css(d+"transform","translate3d(0, 0, -"+a.translateZ+"px)"),e=0),{bsangle:e};a.$slides.filter(function(b){return a.currIndex!==b}).hide();a.$currSlide.fadeOut(a.speed);a.$nextSlide.fadeIn(a.speed)};a.destroy=function(a,b){var c=a.children(),d=a.parent();b.origCSS&&(a.css(b.origCSS.box),c.css(b.origCSS.slides),d.css(b.origCSS.viewport),delete b.bsangle, | |
| 17 | - delete b.translateZ)};var c=function(a,b){switch(a){case 360:case -360:return"rotate3d(0, 1, 0, 0deg)";case 90:case -270:return"rotate3d("+(b?"1, 0, 0,":"0, 1, 0,")+" -90deg)";case 180:case -180:return"rotate3d("+(b?"1, 0, 0,":"0, 1, 0,")+" 180deg)";case 270:case -90:return"rotate3d("+(b?"1, 0, 0,":"0, 1, 0,")+" 90deg)"}};return a}());i.jqBoxSlider.registerAnimator("scrollVert,scrollHorz",function(){var a={initialize:function(b,d,c){var f=b.width(),e=d.eq(0).height();a._cacheOriginalCSS(b,"box",c); | |
| 18 | - a._cacheOriginalCSS(d,"slides",c);-1!=="static inherit".indexOf(b.css("position"))&&b.css("position","relative");b.css({height:e,overflow:"hidden"});d.css({position:"absolute",top:0,left:0,width:f,height:e}).filter(":gt(0)").hide()},transition:function(a){var d=a.$box,c=a.reverse,g={},e={};"scrollVert"===a.effect?(e.top=(c?d.height():-d.height())+"px",g.top=-parseInt(e.top,10)+"px",d={top:"0px"}):(e.left=(c?d.width():-d.width())+"px",g.left=-parseInt(e.left,10)+"px",d={left:"0px"});a.$nextSlide.css(f.extend(e, | |
| 19 | - {display:"block"})).animate(d,a.speed);a.$currSlide.animate(g,a.speed)},destroy:function(a,d){a.children().css(d.origCSS.slides);a.css(d.origCSS.box)}};return a}())})(window,jQuery||Zepto); |
js/swiper.js
0 → 100755
Changes suppressed. Click to show
| 1 | +/** | |
| 2 | + * Swiper 4.4.6 | |
| 3 | + * Most modern mobile touch slider and framework with hardware accelerated transitions | |
| 4 | + * http://www.idangero.us/swiper/ | |
| 5 | + * | |
| 6 | + * Copyright 2014-2018 Vladimir Kharlampidi | |
| 7 | + * | |
| 8 | + * Released under the MIT License | |
| 9 | + * | |
| 10 | + * Released on: December 19, 2018 | |
| 11 | + */ | |
| 12 | + | |
| 13 | +(function (global, factory) { | |
| 14 | + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | |
| 15 | + typeof define === 'function' && define.amd ? define(factory) : | |
| 16 | + (global.Swiper = factory()); | |
| 17 | +}(this, (function () { 'use strict'; | |
| 18 | + | |
| 19 | + /** | |
| 20 | + * SSR Window 1.0.1 | |
| 21 | + * Better handling for window object in SSR environment | |
| 22 | + * https://github.com/nolimits4web/ssr-window | |
| 23 | + * | |
| 24 | + * Copyright 2018, Vladimir Kharlampidi | |
| 25 | + * | |
| 26 | + * Licensed under MIT | |
| 27 | + * | |
| 28 | + * Released on: July 18, 2018 | |
| 29 | + */ | |
| 30 | + var doc = (typeof document === 'undefined') ? { | |
| 31 | + body: {}, | |
| 32 | + addEventListener: function addEventListener() {}, | |
| 33 | + removeEventListener: function removeEventListener() {}, | |
| 34 | + activeElement: { | |
| 35 | + blur: function blur() {}, | |
| 36 | + nodeName: '', | |
| 37 | + }, | |
| 38 | + querySelector: function querySelector() { | |
| 39 | + return null; | |
| 40 | + }, | |
| 41 | + querySelectorAll: function querySelectorAll() { | |
| 42 | + return []; | |
| 43 | + }, | |
| 44 | + getElementById: function getElementById() { | |
| 45 | + return null; | |
| 46 | + }, | |
| 47 | + createEvent: function createEvent() { | |
| 48 | + return { | |
| 49 | + initEvent: function initEvent() {}, | |
| 50 | + }; | |
| 51 | + }, | |
| 52 | + createElement: function createElement() { | |
| 53 | + return { | |
| 54 | + children: [], | |
| 55 | + childNodes: [], | |
| 56 | + style: {}, | |
| 57 | + setAttribute: function setAttribute() {}, | |
| 58 | + getElementsByTagName: function getElementsByTagName() { | |
| 59 | + return []; | |
| 60 | + }, | |
| 61 | + }; | |
| 62 | + }, | |
| 63 | + location: { hash: '' }, | |
| 64 | + } : document; // eslint-disable-line | |
| 65 | + | |
| 66 | + var win = (typeof window === 'undefined') ? { | |
| 67 | + document: doc, | |
| 68 | + navigator: { | |
| 69 | + userAgent: '', | |
| 70 | + }, | |
| 71 | + location: {}, | |
| 72 | + history: {}, | |
| 73 | + CustomEvent: function CustomEvent() { | |
| 74 | + return this; | |
| 75 | + }, | |
| 76 | + addEventListener: function addEventListener() {}, | |
| 77 | + removeEventListener: function removeEventListener() {}, | |
| 78 | + getComputedStyle: function getComputedStyle() { | |
| 79 | + return { | |
| 80 | + getPropertyValue: function getPropertyValue() { | |
| 81 | + return ''; | |
| 82 | + }, | |
| 83 | + }; | |
| 84 | + }, | |
| 85 | + Image: function Image() {}, | |
| 86 | + Date: function Date() {}, | |
| 87 | + screen: {}, | |
| 88 | + setTimeout: function setTimeout() {}, | |
| 89 | + clearTimeout: function clearTimeout() {}, | |
| 90 | + } : window; // eslint-disable-line | |
| 91 | + | |
| 92 | + /** | |
| 93 | + * Dom7 2.1.2 | |
| 94 | + * Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API | |
| 95 | + * http://framework7.io/docs/dom.html | |
| 96 | + * | |
| 97 | + * Copyright 2018, Vladimir Kharlampidi | |
| 98 | + * The iDangero.us | |
| 99 | + * http://www.idangero.us/ | |
| 100 | + * | |
| 101 | + * Licensed under MIT | |
| 102 | + * | |
| 103 | + * Released on: September 13, 2018 | |
| 104 | + */ | |
| 105 | + | |
| 106 | + var Dom7 = function Dom7(arr) { | |
| 107 | + var self = this; | |
| 108 | + // Create array-like object | |
| 109 | + for (var i = 0; i < arr.length; i += 1) { | |
| 110 | + self[i] = arr[i]; | |
| 111 | + } | |
| 112 | + self.length = arr.length; | |
| 113 | + // Return collection with methods | |
| 114 | + return this; | |
| 115 | + }; | |
| 116 | + | |
| 117 | + function $(selector, context) { | |
| 118 | + var arr = []; | |
| 119 | + var i = 0; | |
| 120 | + if (selector && !context) { | |
| 121 | + if (selector instanceof Dom7) { | |
| 122 | + return selector; | |
| 123 | + } | |
| 124 | + } | |
| 125 | + if (selector) { | |
| 126 | + // String | |
| 127 | + if (typeof selector === 'string') { | |
| 128 | + var els; | |
| 129 | + var tempParent; | |
| 130 | + var html = selector.trim(); | |
| 131 | + if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) { | |
| 132 | + var toCreate = 'div'; | |
| 133 | + if (html.indexOf('<li') === 0) { toCreate = 'ul'; } | |
| 134 | + if (html.indexOf('<tr') === 0) { toCreate = 'tbody'; } | |
| 135 | + if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) { toCreate = 'tr'; } | |
| 136 | + if (html.indexOf('<tbody') === 0) { toCreate = 'table'; } | |
| 137 | + if (html.indexOf('<option') === 0) { toCreate = 'select'; } | |
| 138 | + tempParent = doc.createElement(toCreate); | |
| 139 | + tempParent.innerHTML = html; | |
| 140 | + for (i = 0; i < tempParent.childNodes.length; i += 1) { | |
| 141 | + arr.push(tempParent.childNodes[i]); | |
| 142 | + } | |
| 143 | + } else { | |
| 144 | + if (!context && selector[0] === '#' && !selector.match(/[ .<>:~]/)) { | |
| 145 | + // Pure ID selector | |
| 146 | + els = [doc.getElementById(selector.trim().split('#')[1])]; | |
| 147 | + } else { | |
| 148 | + // Other selectors | |
| 149 | + els = (context || doc).querySelectorAll(selector.trim()); | |
| 150 | + } | |
| 151 | + for (i = 0; i < els.length; i += 1) { | |
| 152 | + if (els[i]) { arr.push(els[i]); } | |
| 153 | + } | |
| 154 | + } | |
| 155 | + } else if (selector.nodeType || selector === win || selector === doc) { | |
| 156 | + // Node/element | |
| 157 | + arr.push(selector); | |
| 158 | + } else if (selector.length > 0 && selector[0].nodeType) { | |
| 159 | + // Array of elements or instance of Dom | |
| 160 | + for (i = 0; i < selector.length; i += 1) { | |
| 161 | + arr.push(selector[i]); | |
| 162 | + } | |
| 163 | + } | |
| 164 | + } | |
| 165 | + return new Dom7(arr); | |
| 166 | + } | |
| 167 | + | |
| 168 | + $.fn = Dom7.prototype; | |
| 169 | + $.Class = Dom7; | |
| 170 | + $.Dom7 = Dom7; | |
| 171 | + | |
| 172 | + function unique(arr) { | |
| 173 | + var uniqueArray = []; | |
| 174 | + for (var i = 0; i < arr.length; i += 1) { | |
| 175 | + if (uniqueArray.indexOf(arr[i]) === -1) { uniqueArray.push(arr[i]); } | |
| 176 | + } | |
| 177 | + return uniqueArray; | |
| 178 | + } | |
| 179 | + | |
| 180 | + // Classes and attributes | |
| 181 | + function addClass(className) { | |
| 182 | + if (typeof className === 'undefined') { | |
| 183 | + return this; | |
| 184 | + } | |
| 185 | + var classes = className.split(' '); | |
| 186 | + for (var i = 0; i < classes.length; i += 1) { | |
| 187 | + for (var j = 0; j < this.length; j += 1) { | |
| 188 | + if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.add(classes[i]); } | |
| 189 | + } | |
| 190 | + } | |
| 191 | + return this; | |
| 192 | + } | |
| 193 | + function removeClass(className) { | |
| 194 | + var classes = className.split(' '); | |
| 195 | + for (var i = 0; i < classes.length; i += 1) { | |
| 196 | + for (var j = 0; j < this.length; j += 1) { | |
| 197 | + if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.remove(classes[i]); } | |
| 198 | + } | |
| 199 | + } | |
| 200 | + return this; | |
| 201 | + } | |
| 202 | + function hasClass(className) { | |
| 203 | + if (!this[0]) { return false; } | |
| 204 | + return this[0].classList.contains(className); | |
| 205 | + } | |
| 206 | + function toggleClass(className) { | |
| 207 | + var classes = className.split(' '); | |
| 208 | + for (var i = 0; i < classes.length; i += 1) { | |
| 209 | + for (var j = 0; j < this.length; j += 1) { | |
| 210 | + if (typeof this[j] !== 'undefined' && typeof this[j].classList !== 'undefined') { this[j].classList.toggle(classes[i]); } | |
| 211 | + } | |
| 212 | + } | |
| 213 | + return this; | |
| 214 | + } | |
| 215 | + function attr(attrs, value) { | |
| 216 | + var arguments$1 = arguments; | |
| 217 | + | |
| 218 | + if (arguments.length === 1 && typeof attrs === 'string') { | |
| 219 | + // Get attr | |
| 220 | + if (this[0]) { return this[0].getAttribute(attrs); } | |
| 221 | + return undefined; | |
| 222 | + } | |
| 223 | + | |
| 224 | + // Set attrs | |
| 225 | + for (var i = 0; i < this.length; i += 1) { | |
| 226 | + if (arguments$1.length === 2) { | |
| 227 | + // String | |
| 228 | + this[i].setAttribute(attrs, value); | |
| 229 | + } else { | |
| 230 | + // Object | |
| 231 | + // eslint-disable-next-line | |
| 232 | + for (var attrName in attrs) { | |
| 233 | + this[i][attrName] = attrs[attrName]; | |
| 234 | + this[i].setAttribute(attrName, attrs[attrName]); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + } | |
| 238 | + return this; | |
| 239 | + } | |
| 240 | + // eslint-disable-next-line | |
| 241 | + function removeAttr(attr) { | |
| 242 | + for (var i = 0; i < this.length; i += 1) { | |
| 243 | + this[i].removeAttribute(attr); | |
| 244 | + } | |
| 245 | + return this; | |
| 246 | + } | |
| 247 | + function data(key, value) { | |
| 248 | + var el; | |
| 249 | + if (typeof value === 'undefined') { | |
| 250 | + el = this[0]; | |
| 251 | + // Get value | |
| 252 | + if (el) { | |
| 253 | + if (el.dom7ElementDataStorage && (key in el.dom7ElementDataStorage)) { | |
| 254 | + return el.dom7ElementDataStorage[key]; | |
| 255 | + } | |
| 256 | + | |
| 257 | + var dataKey = el.getAttribute(("data-" + key)); | |
| 258 | + if (dataKey) { | |
| 259 | + return dataKey; | |
| 260 | + } | |
| 261 | + return undefined; | |
| 262 | + } | |
| 263 | + return undefined; | |
| 264 | + } | |
| 265 | + | |
| 266 | + // Set value | |
| 267 | + for (var i = 0; i < this.length; i += 1) { | |
| 268 | + el = this[i]; | |
| 269 | + if (!el.dom7ElementDataStorage) { el.dom7ElementDataStorage = {}; } | |
| 270 | + el.dom7ElementDataStorage[key] = value; | |
| 271 | + } | |
| 272 | + return this; | |
| 273 | + } | |
| 274 | + // Transforms | |
| 275 | + // eslint-disable-next-line | |
| 276 | + function transform(transform) { | |
| 277 | + for (var i = 0; i < this.length; i += 1) { | |
| 278 | + var elStyle = this[i].style; | |
| 279 | + elStyle.webkitTransform = transform; | |
| 280 | + elStyle.transform = transform; | |
| 281 | + } | |
| 282 | + return this; | |
| 283 | + } | |
| 284 | + function transition(duration) { | |
| 285 | + if (typeof duration !== 'string') { | |
| 286 | + duration = duration + "ms"; // eslint-disable-line | |
| 287 | + } | |
| 288 | + for (var i = 0; i < this.length; i += 1) { | |
| 289 | + var elStyle = this[i].style; | |
| 290 | + elStyle.webkitTransitionDuration = duration; | |
| 291 | + elStyle.transitionDuration = duration; | |
| 292 | + } | |
| 293 | + return this; | |
| 294 | + } | |
| 295 | + // Events | |
| 296 | + function on() { | |
| 297 | + var assign; | |
| 298 | + | |
| 299 | + var args = [], len = arguments.length; | |
| 300 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 301 | + var eventType = args[0]; | |
| 302 | + var targetSelector = args[1]; | |
| 303 | + var listener = args[2]; | |
| 304 | + var capture = args[3]; | |
| 305 | + if (typeof args[1] === 'function') { | |
| 306 | + (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]); | |
| 307 | + targetSelector = undefined; | |
| 308 | + } | |
| 309 | + if (!capture) { capture = false; } | |
| 310 | + | |
| 311 | + function handleLiveEvent(e) { | |
| 312 | + var target = e.target; | |
| 313 | + if (!target) { return; } | |
| 314 | + var eventData = e.target.dom7EventData || []; | |
| 315 | + if (eventData.indexOf(e) < 0) { | |
| 316 | + eventData.unshift(e); | |
| 317 | + } | |
| 318 | + if ($(target).is(targetSelector)) { listener.apply(target, eventData); } | |
| 319 | + else { | |
| 320 | + var parents = $(target).parents(); // eslint-disable-line | |
| 321 | + for (var k = 0; k < parents.length; k += 1) { | |
| 322 | + if ($(parents[k]).is(targetSelector)) { listener.apply(parents[k], eventData); } | |
| 323 | + } | |
| 324 | + } | |
| 325 | + } | |
| 326 | + function handleEvent(e) { | |
| 327 | + var eventData = e && e.target ? e.target.dom7EventData || [] : []; | |
| 328 | + if (eventData.indexOf(e) < 0) { | |
| 329 | + eventData.unshift(e); | |
| 330 | + } | |
| 331 | + listener.apply(this, eventData); | |
| 332 | + } | |
| 333 | + var events = eventType.split(' '); | |
| 334 | + var j; | |
| 335 | + for (var i = 0; i < this.length; i += 1) { | |
| 336 | + var el = this[i]; | |
| 337 | + if (!targetSelector) { | |
| 338 | + for (j = 0; j < events.length; j += 1) { | |
| 339 | + var event = events[j]; | |
| 340 | + if (!el.dom7Listeners) { el.dom7Listeners = {}; } | |
| 341 | + if (!el.dom7Listeners[event]) { el.dom7Listeners[event] = []; } | |
| 342 | + el.dom7Listeners[event].push({ | |
| 343 | + listener: listener, | |
| 344 | + proxyListener: handleEvent, | |
| 345 | + }); | |
| 346 | + el.addEventListener(event, handleEvent, capture); | |
| 347 | + } | |
| 348 | + } else { | |
| 349 | + // Live events | |
| 350 | + for (j = 0; j < events.length; j += 1) { | |
| 351 | + var event$1 = events[j]; | |
| 352 | + if (!el.dom7LiveListeners) { el.dom7LiveListeners = {}; } | |
| 353 | + if (!el.dom7LiveListeners[event$1]) { el.dom7LiveListeners[event$1] = []; } | |
| 354 | + el.dom7LiveListeners[event$1].push({ | |
| 355 | + listener: listener, | |
| 356 | + proxyListener: handleLiveEvent, | |
| 357 | + }); | |
| 358 | + el.addEventListener(event$1, handleLiveEvent, capture); | |
| 359 | + } | |
| 360 | + } | |
| 361 | + } | |
| 362 | + return this; | |
| 363 | + } | |
| 364 | + function off() { | |
| 365 | + var assign; | |
| 366 | + | |
| 367 | + var args = [], len = arguments.length; | |
| 368 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 369 | + var eventType = args[0]; | |
| 370 | + var targetSelector = args[1]; | |
| 371 | + var listener = args[2]; | |
| 372 | + var capture = args[3]; | |
| 373 | + if (typeof args[1] === 'function') { | |
| 374 | + (assign = args, eventType = assign[0], listener = assign[1], capture = assign[2]); | |
| 375 | + targetSelector = undefined; | |
| 376 | + } | |
| 377 | + if (!capture) { capture = false; } | |
| 378 | + | |
| 379 | + var events = eventType.split(' '); | |
| 380 | + for (var i = 0; i < events.length; i += 1) { | |
| 381 | + var event = events[i]; | |
| 382 | + for (var j = 0; j < this.length; j += 1) { | |
| 383 | + var el = this[j]; | |
| 384 | + var handlers = (void 0); | |
| 385 | + if (!targetSelector && el.dom7Listeners) { | |
| 386 | + handlers = el.dom7Listeners[event]; | |
| 387 | + } else if (targetSelector && el.dom7LiveListeners) { | |
| 388 | + handlers = el.dom7LiveListeners[event]; | |
| 389 | + } | |
| 390 | + if (handlers && handlers.length) { | |
| 391 | + for (var k = handlers.length - 1; k >= 0; k -= 1) { | |
| 392 | + var handler = handlers[k]; | |
| 393 | + if (listener && handler.listener === listener) { | |
| 394 | + el.removeEventListener(event, handler.proxyListener, capture); | |
| 395 | + handlers.splice(k, 1); | |
| 396 | + } else if (!listener) { | |
| 397 | + el.removeEventListener(event, handler.proxyListener, capture); | |
| 398 | + handlers.splice(k, 1); | |
| 399 | + } | |
| 400 | + } | |
| 401 | + } | |
| 402 | + } | |
| 403 | + } | |
| 404 | + return this; | |
| 405 | + } | |
| 406 | + function trigger() { | |
| 407 | + var args = [], len = arguments.length; | |
| 408 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 409 | + | |
| 410 | + var events = args[0].split(' '); | |
| 411 | + var eventData = args[1]; | |
| 412 | + for (var i = 0; i < events.length; i += 1) { | |
| 413 | + var event = events[i]; | |
| 414 | + for (var j = 0; j < this.length; j += 1) { | |
| 415 | + var el = this[j]; | |
| 416 | + var evt = (void 0); | |
| 417 | + try { | |
| 418 | + evt = new win.CustomEvent(event, { | |
| 419 | + detail: eventData, | |
| 420 | + bubbles: true, | |
| 421 | + cancelable: true, | |
| 422 | + }); | |
| 423 | + } catch (e) { | |
| 424 | + evt = doc.createEvent('Event'); | |
| 425 | + evt.initEvent(event, true, true); | |
| 426 | + evt.detail = eventData; | |
| 427 | + } | |
| 428 | + // eslint-disable-next-line | |
| 429 | + el.dom7EventData = args.filter(function (data, dataIndex) { return dataIndex > 0; }); | |
| 430 | + el.dispatchEvent(evt); | |
| 431 | + el.dom7EventData = []; | |
| 432 | + delete el.dom7EventData; | |
| 433 | + } | |
| 434 | + } | |
| 435 | + return this; | |
| 436 | + } | |
| 437 | + function transitionEnd(callback) { | |
| 438 | + var events = ['webkitTransitionEnd', 'transitionend']; | |
| 439 | + var dom = this; | |
| 440 | + var i; | |
| 441 | + function fireCallBack(e) { | |
| 442 | + /* jshint validthis:true */ | |
| 443 | + if (e.target !== this) { return; } | |
| 444 | + callback.call(this, e); | |
| 445 | + for (i = 0; i < events.length; i += 1) { | |
| 446 | + dom.off(events[i], fireCallBack); | |
| 447 | + } | |
| 448 | + } | |
| 449 | + if (callback) { | |
| 450 | + for (i = 0; i < events.length; i += 1) { | |
| 451 | + dom.on(events[i], fireCallBack); | |
| 452 | + } | |
| 453 | + } | |
| 454 | + return this; | |
| 455 | + } | |
| 456 | + function outerWidth(includeMargins) { | |
| 457 | + if (this.length > 0) { | |
| 458 | + if (includeMargins) { | |
| 459 | + // eslint-disable-next-line | |
| 460 | + var styles = this.styles(); | |
| 461 | + return this[0].offsetWidth + parseFloat(styles.getPropertyValue('margin-right')) + parseFloat(styles.getPropertyValue('margin-left')); | |
| 462 | + } | |
| 463 | + return this[0].offsetWidth; | |
| 464 | + } | |
| 465 | + return null; | |
| 466 | + } | |
| 467 | + function outerHeight(includeMargins) { | |
| 468 | + if (this.length > 0) { | |
| 469 | + if (includeMargins) { | |
| 470 | + // eslint-disable-next-line | |
| 471 | + var styles = this.styles(); | |
| 472 | + return this[0].offsetHeight + parseFloat(styles.getPropertyValue('margin-top')) + parseFloat(styles.getPropertyValue('margin-bottom')); | |
| 473 | + } | |
| 474 | + return this[0].offsetHeight; | |
| 475 | + } | |
| 476 | + return null; | |
| 477 | + } | |
| 478 | + function offset() { | |
| 479 | + if (this.length > 0) { | |
| 480 | + var el = this[0]; | |
| 481 | + var box = el.getBoundingClientRect(); | |
| 482 | + var body = doc.body; | |
| 483 | + var clientTop = el.clientTop || body.clientTop || 0; | |
| 484 | + var clientLeft = el.clientLeft || body.clientLeft || 0; | |
| 485 | + var scrollTop = el === win ? win.scrollY : el.scrollTop; | |
| 486 | + var scrollLeft = el === win ? win.scrollX : el.scrollLeft; | |
| 487 | + return { | |
| 488 | + top: (box.top + scrollTop) - clientTop, | |
| 489 | + left: (box.left + scrollLeft) - clientLeft, | |
| 490 | + }; | |
| 491 | + } | |
| 492 | + | |
| 493 | + return null; | |
| 494 | + } | |
| 495 | + function styles() { | |
| 496 | + if (this[0]) { return win.getComputedStyle(this[0], null); } | |
| 497 | + return {}; | |
| 498 | + } | |
| 499 | + function css(props, value) { | |
| 500 | + var i; | |
| 501 | + if (arguments.length === 1) { | |
| 502 | + if (typeof props === 'string') { | |
| 503 | + if (this[0]) { return win.getComputedStyle(this[0], null).getPropertyValue(props); } | |
| 504 | + } else { | |
| 505 | + for (i = 0; i < this.length; i += 1) { | |
| 506 | + // eslint-disable-next-line | |
| 507 | + for (var prop in props) { | |
| 508 | + this[i].style[prop] = props[prop]; | |
| 509 | + } | |
| 510 | + } | |
| 511 | + return this; | |
| 512 | + } | |
| 513 | + } | |
| 514 | + if (arguments.length === 2 && typeof props === 'string') { | |
| 515 | + for (i = 0; i < this.length; i += 1) { | |
| 516 | + this[i].style[props] = value; | |
| 517 | + } | |
| 518 | + return this; | |
| 519 | + } | |
| 520 | + return this; | |
| 521 | + } | |
| 522 | + // Iterate over the collection passing elements to `callback` | |
| 523 | + function each(callback) { | |
| 524 | + // Don't bother continuing without a callback | |
| 525 | + if (!callback) { return this; } | |
| 526 | + // Iterate over the current collection | |
| 527 | + for (var i = 0; i < this.length; i += 1) { | |
| 528 | + // If the callback returns false | |
| 529 | + if (callback.call(this[i], i, this[i]) === false) { | |
| 530 | + // End the loop early | |
| 531 | + return this; | |
| 532 | + } | |
| 533 | + } | |
| 534 | + // Return `this` to allow chained DOM operations | |
| 535 | + return this; | |
| 536 | + } | |
| 537 | + // eslint-disable-next-line | |
| 538 | + function html(html) { | |
| 539 | + if (typeof html === 'undefined') { | |
| 540 | + return this[0] ? this[0].innerHTML : undefined; | |
| 541 | + } | |
| 542 | + | |
| 543 | + for (var i = 0; i < this.length; i += 1) { | |
| 544 | + this[i].innerHTML = html; | |
| 545 | + } | |
| 546 | + return this; | |
| 547 | + } | |
| 548 | + // eslint-disable-next-line | |
| 549 | + function text(text) { | |
| 550 | + if (typeof text === 'undefined') { | |
| 551 | + if (this[0]) { | |
| 552 | + return this[0].textContent.trim(); | |
| 553 | + } | |
| 554 | + return null; | |
| 555 | + } | |
| 556 | + | |
| 557 | + for (var i = 0; i < this.length; i += 1) { | |
| 558 | + this[i].textContent = text; | |
| 559 | + } | |
| 560 | + return this; | |
| 561 | + } | |
| 562 | + function is(selector) { | |
| 563 | + var el = this[0]; | |
| 564 | + var compareWith; | |
| 565 | + var i; | |
| 566 | + if (!el || typeof selector === 'undefined') { return false; } | |
| 567 | + if (typeof selector === 'string') { | |
| 568 | + if (el.matches) { return el.matches(selector); } | |
| 569 | + else if (el.webkitMatchesSelector) { return el.webkitMatchesSelector(selector); } | |
| 570 | + else if (el.msMatchesSelector) { return el.msMatchesSelector(selector); } | |
| 571 | + | |
| 572 | + compareWith = $(selector); | |
| 573 | + for (i = 0; i < compareWith.length; i += 1) { | |
| 574 | + if (compareWith[i] === el) { return true; } | |
| 575 | + } | |
| 576 | + return false; | |
| 577 | + } else if (selector === doc) { return el === doc; } | |
| 578 | + else if (selector === win) { return el === win; } | |
| 579 | + | |
| 580 | + if (selector.nodeType || selector instanceof Dom7) { | |
| 581 | + compareWith = selector.nodeType ? [selector] : selector; | |
| 582 | + for (i = 0; i < compareWith.length; i += 1) { | |
| 583 | + if (compareWith[i] === el) { return true; } | |
| 584 | + } | |
| 585 | + return false; | |
| 586 | + } | |
| 587 | + return false; | |
| 588 | + } | |
| 589 | + function index() { | |
| 590 | + var child = this[0]; | |
| 591 | + var i; | |
| 592 | + if (child) { | |
| 593 | + i = 0; | |
| 594 | + // eslint-disable-next-line | |
| 595 | + while ((child = child.previousSibling) !== null) { | |
| 596 | + if (child.nodeType === 1) { i += 1; } | |
| 597 | + } | |
| 598 | + return i; | |
| 599 | + } | |
| 600 | + return undefined; | |
| 601 | + } | |
| 602 | + // eslint-disable-next-line | |
| 603 | + function eq(index) { | |
| 604 | + if (typeof index === 'undefined') { return this; } | |
| 605 | + var length = this.length; | |
| 606 | + var returnIndex; | |
| 607 | + if (index > length - 1) { | |
| 608 | + return new Dom7([]); | |
| 609 | + } | |
| 610 | + if (index < 0) { | |
| 611 | + returnIndex = length + index; | |
| 612 | + if (returnIndex < 0) { return new Dom7([]); } | |
| 613 | + return new Dom7([this[returnIndex]]); | |
| 614 | + } | |
| 615 | + return new Dom7([this[index]]); | |
| 616 | + } | |
| 617 | + function append() { | |
| 618 | + var args = [], len = arguments.length; | |
| 619 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 620 | + | |
| 621 | + var newChild; | |
| 622 | + | |
| 623 | + for (var k = 0; k < args.length; k += 1) { | |
| 624 | + newChild = args[k]; | |
| 625 | + for (var i = 0; i < this.length; i += 1) { | |
| 626 | + if (typeof newChild === 'string') { | |
| 627 | + var tempDiv = doc.createElement('div'); | |
| 628 | + tempDiv.innerHTML = newChild; | |
| 629 | + while (tempDiv.firstChild) { | |
| 630 | + this[i].appendChild(tempDiv.firstChild); | |
| 631 | + } | |
| 632 | + } else if (newChild instanceof Dom7) { | |
| 633 | + for (var j = 0; j < newChild.length; j += 1) { | |
| 634 | + this[i].appendChild(newChild[j]); | |
| 635 | + } | |
| 636 | + } else { | |
| 637 | + this[i].appendChild(newChild); | |
| 638 | + } | |
| 639 | + } | |
| 640 | + } | |
| 641 | + | |
| 642 | + return this; | |
| 643 | + } | |
| 644 | + function prepend(newChild) { | |
| 645 | + var i; | |
| 646 | + var j; | |
| 647 | + for (i = 0; i < this.length; i += 1) { | |
| 648 | + if (typeof newChild === 'string') { | |
| 649 | + var tempDiv = doc.createElement('div'); | |
| 650 | + tempDiv.innerHTML = newChild; | |
| 651 | + for (j = tempDiv.childNodes.length - 1; j >= 0; j -= 1) { | |
| 652 | + this[i].insertBefore(tempDiv.childNodes[j], this[i].childNodes[0]); | |
| 653 | + } | |
| 654 | + } else if (newChild instanceof Dom7) { | |
| 655 | + for (j = 0; j < newChild.length; j += 1) { | |
| 656 | + this[i].insertBefore(newChild[j], this[i].childNodes[0]); | |
| 657 | + } | |
| 658 | + } else { | |
| 659 | + this[i].insertBefore(newChild, this[i].childNodes[0]); | |
| 660 | + } | |
| 661 | + } | |
| 662 | + return this; | |
| 663 | + } | |
| 664 | + function next(selector) { | |
| 665 | + if (this.length > 0) { | |
| 666 | + if (selector) { | |
| 667 | + if (this[0].nextElementSibling && $(this[0].nextElementSibling).is(selector)) { | |
| 668 | + return new Dom7([this[0].nextElementSibling]); | |
| 669 | + } | |
| 670 | + return new Dom7([]); | |
| 671 | + } | |
| 672 | + | |
| 673 | + if (this[0].nextElementSibling) { return new Dom7([this[0].nextElementSibling]); } | |
| 674 | + return new Dom7([]); | |
| 675 | + } | |
| 676 | + return new Dom7([]); | |
| 677 | + } | |
| 678 | + function nextAll(selector) { | |
| 679 | + var nextEls = []; | |
| 680 | + var el = this[0]; | |
| 681 | + if (!el) { return new Dom7([]); } | |
| 682 | + while (el.nextElementSibling) { | |
| 683 | + var next = el.nextElementSibling; // eslint-disable-line | |
| 684 | + if (selector) { | |
| 685 | + if ($(next).is(selector)) { nextEls.push(next); } | |
| 686 | + } else { nextEls.push(next); } | |
| 687 | + el = next; | |
| 688 | + } | |
| 689 | + return new Dom7(nextEls); | |
| 690 | + } | |
| 691 | + function prev(selector) { | |
| 692 | + if (this.length > 0) { | |
| 693 | + var el = this[0]; | |
| 694 | + if (selector) { | |
| 695 | + if (el.previousElementSibling && $(el.previousElementSibling).is(selector)) { | |
| 696 | + return new Dom7([el.previousElementSibling]); | |
| 697 | + } | |
| 698 | + return new Dom7([]); | |
| 699 | + } | |
| 700 | + | |
| 701 | + if (el.previousElementSibling) { return new Dom7([el.previousElementSibling]); } | |
| 702 | + return new Dom7([]); | |
| 703 | + } | |
| 704 | + return new Dom7([]); | |
| 705 | + } | |
| 706 | + function prevAll(selector) { | |
| 707 | + var prevEls = []; | |
| 708 | + var el = this[0]; | |
| 709 | + if (!el) { return new Dom7([]); } | |
| 710 | + while (el.previousElementSibling) { | |
| 711 | + var prev = el.previousElementSibling; // eslint-disable-line | |
| 712 | + if (selector) { | |
| 713 | + if ($(prev).is(selector)) { prevEls.push(prev); } | |
| 714 | + } else { prevEls.push(prev); } | |
| 715 | + el = prev; | |
| 716 | + } | |
| 717 | + return new Dom7(prevEls); | |
| 718 | + } | |
| 719 | + function parent(selector) { | |
| 720 | + var parents = []; // eslint-disable-line | |
| 721 | + for (var i = 0; i < this.length; i += 1) { | |
| 722 | + if (this[i].parentNode !== null) { | |
| 723 | + if (selector) { | |
| 724 | + if ($(this[i].parentNode).is(selector)) { parents.push(this[i].parentNode); } | |
| 725 | + } else { | |
| 726 | + parents.push(this[i].parentNode); | |
| 727 | + } | |
| 728 | + } | |
| 729 | + } | |
| 730 | + return $(unique(parents)); | |
| 731 | + } | |
| 732 | + function parents(selector) { | |
| 733 | + var parents = []; // eslint-disable-line | |
| 734 | + for (var i = 0; i < this.length; i += 1) { | |
| 735 | + var parent = this[i].parentNode; // eslint-disable-line | |
| 736 | + while (parent) { | |
| 737 | + if (selector) { | |
| 738 | + if ($(parent).is(selector)) { parents.push(parent); } | |
| 739 | + } else { | |
| 740 | + parents.push(parent); | |
| 741 | + } | |
| 742 | + parent = parent.parentNode; | |
| 743 | + } | |
| 744 | + } | |
| 745 | + return $(unique(parents)); | |
| 746 | + } | |
| 747 | + function closest(selector) { | |
| 748 | + var closest = this; // eslint-disable-line | |
| 749 | + if (typeof selector === 'undefined') { | |
| 750 | + return new Dom7([]); | |
| 751 | + } | |
| 752 | + if (!closest.is(selector)) { | |
| 753 | + closest = closest.parents(selector).eq(0); | |
| 754 | + } | |
| 755 | + return closest; | |
| 756 | + } | |
| 757 | + function find(selector) { | |
| 758 | + var foundElements = []; | |
| 759 | + for (var i = 0; i < this.length; i += 1) { | |
| 760 | + var found = this[i].querySelectorAll(selector); | |
| 761 | + for (var j = 0; j < found.length; j += 1) { | |
| 762 | + foundElements.push(found[j]); | |
| 763 | + } | |
| 764 | + } | |
| 765 | + return new Dom7(foundElements); | |
| 766 | + } | |
| 767 | + function children(selector) { | |
| 768 | + var children = []; // eslint-disable-line | |
| 769 | + for (var i = 0; i < this.length; i += 1) { | |
| 770 | + var childNodes = this[i].childNodes; | |
| 771 | + | |
| 772 | + for (var j = 0; j < childNodes.length; j += 1) { | |
| 773 | + if (!selector) { | |
| 774 | + if (childNodes[j].nodeType === 1) { children.push(childNodes[j]); } | |
| 775 | + } else if (childNodes[j].nodeType === 1 && $(childNodes[j]).is(selector)) { | |
| 776 | + children.push(childNodes[j]); | |
| 777 | + } | |
| 778 | + } | |
| 779 | + } | |
| 780 | + return new Dom7(unique(children)); | |
| 781 | + } | |
| 782 | + function remove() { | |
| 783 | + for (var i = 0; i < this.length; i += 1) { | |
| 784 | + if (this[i].parentNode) { this[i].parentNode.removeChild(this[i]); } | |
| 785 | + } | |
| 786 | + return this; | |
| 787 | + } | |
| 788 | + function add() { | |
| 789 | + var args = [], len = arguments.length; | |
| 790 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 791 | + | |
| 792 | + var dom = this; | |
| 793 | + var i; | |
| 794 | + var j; | |
| 795 | + for (i = 0; i < args.length; i += 1) { | |
| 796 | + var toAdd = $(args[i]); | |
| 797 | + for (j = 0; j < toAdd.length; j += 1) { | |
| 798 | + dom[dom.length] = toAdd[j]; | |
| 799 | + dom.length += 1; | |
| 800 | + } | |
| 801 | + } | |
| 802 | + return dom; | |
| 803 | + } | |
| 804 | + | |
| 805 | + var Methods = { | |
| 806 | + addClass: addClass, | |
| 807 | + removeClass: removeClass, | |
| 808 | + hasClass: hasClass, | |
| 809 | + toggleClass: toggleClass, | |
| 810 | + attr: attr, | |
| 811 | + removeAttr: removeAttr, | |
| 812 | + data: data, | |
| 813 | + transform: transform, | |
| 814 | + transition: transition, | |
| 815 | + on: on, | |
| 816 | + off: off, | |
| 817 | + trigger: trigger, | |
| 818 | + transitionEnd: transitionEnd, | |
| 819 | + outerWidth: outerWidth, | |
| 820 | + outerHeight: outerHeight, | |
| 821 | + offset: offset, | |
| 822 | + css: css, | |
| 823 | + each: each, | |
| 824 | + html: html, | |
| 825 | + text: text, | |
| 826 | + is: is, | |
| 827 | + index: index, | |
| 828 | + eq: eq, | |
| 829 | + append: append, | |
| 830 | + prepend: prepend, | |
| 831 | + next: next, | |
| 832 | + nextAll: nextAll, | |
| 833 | + prev: prev, | |
| 834 | + prevAll: prevAll, | |
| 835 | + parent: parent, | |
| 836 | + parents: parents, | |
| 837 | + closest: closest, | |
| 838 | + find: find, | |
| 839 | + children: children, | |
| 840 | + remove: remove, | |
| 841 | + add: add, | |
| 842 | + styles: styles, | |
| 843 | + }; | |
| 844 | + | |
| 845 | + Object.keys(Methods).forEach(function (methodName) { | |
| 846 | + $.fn[methodName] = Methods[methodName]; | |
| 847 | + }); | |
| 848 | + | |
| 849 | + var Utils = { | |
| 850 | + deleteProps: function deleteProps(obj) { | |
| 851 | + var object = obj; | |
| 852 | + Object.keys(object).forEach(function (key) { | |
| 853 | + try { | |
| 854 | + object[key] = null; | |
| 855 | + } catch (e) { | |
| 856 | + // no getter for object | |
| 857 | + } | |
| 858 | + try { | |
| 859 | + delete object[key]; | |
| 860 | + } catch (e) { | |
| 861 | + // something got wrong | |
| 862 | + } | |
| 863 | + }); | |
| 864 | + }, | |
| 865 | + nextTick: function nextTick(callback, delay) { | |
| 866 | + if ( delay === void 0 ) delay = 0; | |
| 867 | + | |
| 868 | + return setTimeout(callback, delay); | |
| 869 | + }, | |
| 870 | + now: function now() { | |
| 871 | + return Date.now(); | |
| 872 | + }, | |
| 873 | + getTranslate: function getTranslate(el, axis) { | |
| 874 | + if ( axis === void 0 ) axis = 'x'; | |
| 875 | + | |
| 876 | + var matrix; | |
| 877 | + var curTransform; | |
| 878 | + var transformMatrix; | |
| 879 | + | |
| 880 | + var curStyle = win.getComputedStyle(el, null); | |
| 881 | + | |
| 882 | + if (win.WebKitCSSMatrix) { | |
| 883 | + curTransform = curStyle.transform || curStyle.webkitTransform; | |
| 884 | + if (curTransform.split(',').length > 6) { | |
| 885 | + curTransform = curTransform.split(', ').map(function (a) { return a.replace(',', '.'); }).join(', '); | |
| 886 | + } | |
| 887 | + // Some old versions of Webkit choke when 'none' is passed; pass | |
| 888 | + // empty string instead in this case | |
| 889 | + transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); | |
| 890 | + } else { | |
| 891 | + transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); | |
| 892 | + matrix = transformMatrix.toString().split(','); | |
| 893 | + } | |
| 894 | + | |
| 895 | + if (axis === 'x') { | |
| 896 | + // Latest Chrome and webkits Fix | |
| 897 | + if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m41; } | |
| 898 | + // Crazy IE10 Matrix | |
| 899 | + else if (matrix.length === 16) { curTransform = parseFloat(matrix[12]); } | |
| 900 | + // Normal Browsers | |
| 901 | + else { curTransform = parseFloat(matrix[4]); } | |
| 902 | + } | |
| 903 | + if (axis === 'y') { | |
| 904 | + // Latest Chrome and webkits Fix | |
| 905 | + if (win.WebKitCSSMatrix) { curTransform = transformMatrix.m42; } | |
| 906 | + // Crazy IE10 Matrix | |
| 907 | + else if (matrix.length === 16) { curTransform = parseFloat(matrix[13]); } | |
| 908 | + // Normal Browsers | |
| 909 | + else { curTransform = parseFloat(matrix[5]); } | |
| 910 | + } | |
| 911 | + return curTransform || 0; | |
| 912 | + }, | |
| 913 | + parseUrlQuery: function parseUrlQuery(url) { | |
| 914 | + var query = {}; | |
| 915 | + var urlToParse = url || win.location.href; | |
| 916 | + var i; | |
| 917 | + var params; | |
| 918 | + var param; | |
| 919 | + var length; | |
| 920 | + if (typeof urlToParse === 'string' && urlToParse.length) { | |
| 921 | + urlToParse = urlToParse.indexOf('?') > -1 ? urlToParse.replace(/\S*\?/, '') : ''; | |
| 922 | + params = urlToParse.split('&').filter(function (paramsPart) { return paramsPart !== ''; }); | |
| 923 | + length = params.length; | |
| 924 | + | |
| 925 | + for (i = 0; i < length; i += 1) { | |
| 926 | + param = params[i].replace(/#\S+/g, '').split('='); | |
| 927 | + query[decodeURIComponent(param[0])] = typeof param[1] === 'undefined' ? undefined : decodeURIComponent(param[1]) || ''; | |
| 928 | + } | |
| 929 | + } | |
| 930 | + return query; | |
| 931 | + }, | |
| 932 | + isObject: function isObject(o) { | |
| 933 | + return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; | |
| 934 | + }, | |
| 935 | + extend: function extend() { | |
| 936 | + var args = [], len$1 = arguments.length; | |
| 937 | + while ( len$1-- ) args[ len$1 ] = arguments[ len$1 ]; | |
| 938 | + | |
| 939 | + var to = Object(args[0]); | |
| 940 | + for (var i = 1; i < args.length; i += 1) { | |
| 941 | + var nextSource = args[i]; | |
| 942 | + if (nextSource !== undefined && nextSource !== null) { | |
| 943 | + var keysArray = Object.keys(Object(nextSource)); | |
| 944 | + for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { | |
| 945 | + var nextKey = keysArray[nextIndex]; | |
| 946 | + var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); | |
| 947 | + if (desc !== undefined && desc.enumerable) { | |
| 948 | + if (Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) { | |
| 949 | + Utils.extend(to[nextKey], nextSource[nextKey]); | |
| 950 | + } else if (!Utils.isObject(to[nextKey]) && Utils.isObject(nextSource[nextKey])) { | |
| 951 | + to[nextKey] = {}; | |
| 952 | + Utils.extend(to[nextKey], nextSource[nextKey]); | |
| 953 | + } else { | |
| 954 | + to[nextKey] = nextSource[nextKey]; | |
| 955 | + } | |
| 956 | + } | |
| 957 | + } | |
| 958 | + } | |
| 959 | + } | |
| 960 | + return to; | |
| 961 | + }, | |
| 962 | + }; | |
| 963 | + | |
| 964 | + var Support = (function Support() { | |
| 965 | + var testDiv = doc.createElement('div'); | |
| 966 | + return { | |
| 967 | + touch: (win.Modernizr && win.Modernizr.touch === true) || (function checkTouch() { | |
| 968 | + return !!((win.navigator.maxTouchPoints > 0) || ('ontouchstart' in win) || (win.DocumentTouch && doc instanceof win.DocumentTouch)); | |
| 969 | + }()), | |
| 970 | + | |
| 971 | + pointerEvents: !!(win.navigator.pointerEnabled || win.PointerEvent || ('maxTouchPoints' in win.navigator)), | |
| 972 | + prefixedPointerEvents: !!win.navigator.msPointerEnabled, | |
| 973 | + | |
| 974 | + transition: (function checkTransition() { | |
| 975 | + var style = testDiv.style; | |
| 976 | + return ('transition' in style || 'webkitTransition' in style || 'MozTransition' in style); | |
| 977 | + }()), | |
| 978 | + transforms3d: (win.Modernizr && win.Modernizr.csstransforms3d === true) || (function checkTransforms3d() { | |
| 979 | + var style = testDiv.style; | |
| 980 | + return ('webkitPerspective' in style || 'MozPerspective' in style || 'OPerspective' in style || 'MsPerspective' in style || 'perspective' in style); | |
| 981 | + }()), | |
| 982 | + | |
| 983 | + flexbox: (function checkFlexbox() { | |
| 984 | + var style = testDiv.style; | |
| 985 | + var styles = ('alignItems webkitAlignItems webkitBoxAlign msFlexAlign mozBoxAlign webkitFlexDirection msFlexDirection mozBoxDirection mozBoxOrient webkitBoxDirection webkitBoxOrient').split(' '); | |
| 986 | + for (var i = 0; i < styles.length; i += 1) { | |
| 987 | + if (styles[i] in style) { return true; } | |
| 988 | + } | |
| 989 | + return false; | |
| 990 | + }()), | |
| 991 | + | |
| 992 | + observer: (function checkObserver() { | |
| 993 | + return ('MutationObserver' in win || 'WebkitMutationObserver' in win); | |
| 994 | + }()), | |
| 995 | + | |
| 996 | + passiveListener: (function checkPassiveListener() { | |
| 997 | + var supportsPassive = false; | |
| 998 | + try { | |
| 999 | + var opts = Object.defineProperty({}, 'passive', { | |
| 1000 | + // eslint-disable-next-line | |
| 1001 | + get: function get() { | |
| 1002 | + supportsPassive = true; | |
| 1003 | + }, | |
| 1004 | + }); | |
| 1005 | + win.addEventListener('testPassiveListener', null, opts); | |
| 1006 | + } catch (e) { | |
| 1007 | + // No support | |
| 1008 | + } | |
| 1009 | + return supportsPassive; | |
| 1010 | + }()), | |
| 1011 | + | |
| 1012 | + gestures: (function checkGestures() { | |
| 1013 | + return 'ongesturestart' in win; | |
| 1014 | + }()), | |
| 1015 | + }; | |
| 1016 | + }()); | |
| 1017 | + | |
| 1018 | + var SwiperClass = function SwiperClass(params) { | |
| 1019 | + if ( params === void 0 ) params = {}; | |
| 1020 | + | |
| 1021 | + var self = this; | |
| 1022 | + self.params = params; | |
| 1023 | + | |
| 1024 | + // Events | |
| 1025 | + self.eventsListeners = {}; | |
| 1026 | + | |
| 1027 | + if (self.params && self.params.on) { | |
| 1028 | + Object.keys(self.params.on).forEach(function (eventName) { | |
| 1029 | + self.on(eventName, self.params.on[eventName]); | |
| 1030 | + }); | |
| 1031 | + } | |
| 1032 | + }; | |
| 1033 | + | |
| 1034 | + var staticAccessors = { components: { configurable: true } }; | |
| 1035 | + | |
| 1036 | + SwiperClass.prototype.on = function on (events, handler, priority) { | |
| 1037 | + var self = this; | |
| 1038 | + if (typeof handler !== 'function') { return self; } | |
| 1039 | + var method = priority ? 'unshift' : 'push'; | |
| 1040 | + events.split(' ').forEach(function (event) { | |
| 1041 | + if (!self.eventsListeners[event]) { self.eventsListeners[event] = []; } | |
| 1042 | + self.eventsListeners[event][method](handler); | |
| 1043 | + }); | |
| 1044 | + return self; | |
| 1045 | + }; | |
| 1046 | + | |
| 1047 | + SwiperClass.prototype.once = function once (events, handler, priority) { | |
| 1048 | + var self = this; | |
| 1049 | + if (typeof handler !== 'function') { return self; } | |
| 1050 | + function onceHandler() { | |
| 1051 | + var args = [], len = arguments.length; | |
| 1052 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 1053 | + | |
| 1054 | + handler.apply(self, args); | |
| 1055 | + self.off(events, onceHandler); | |
| 1056 | + } | |
| 1057 | + return self.on(events, onceHandler, priority); | |
| 1058 | + }; | |
| 1059 | + | |
| 1060 | + SwiperClass.prototype.off = function off (events, handler) { | |
| 1061 | + var self = this; | |
| 1062 | + if (!self.eventsListeners) { return self; } | |
| 1063 | + events.split(' ').forEach(function (event) { | |
| 1064 | + if (typeof handler === 'undefined') { | |
| 1065 | + self.eventsListeners[event] = []; | |
| 1066 | + } else if (self.eventsListeners[event] && self.eventsListeners[event].length) { | |
| 1067 | + self.eventsListeners[event].forEach(function (eventHandler, index) { | |
| 1068 | + if (eventHandler === handler) { | |
| 1069 | + self.eventsListeners[event].splice(index, 1); | |
| 1070 | + } | |
| 1071 | + }); | |
| 1072 | + } | |
| 1073 | + }); | |
| 1074 | + return self; | |
| 1075 | + }; | |
| 1076 | + | |
| 1077 | + SwiperClass.prototype.emit = function emit () { | |
| 1078 | + var args = [], len = arguments.length; | |
| 1079 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 1080 | + | |
| 1081 | + var self = this; | |
| 1082 | + if (!self.eventsListeners) { return self; } | |
| 1083 | + var events; | |
| 1084 | + var data; | |
| 1085 | + var context; | |
| 1086 | + if (typeof args[0] === 'string' || Array.isArray(args[0])) { | |
| 1087 | + events = args[0]; | |
| 1088 | + data = args.slice(1, args.length); | |
| 1089 | + context = self; | |
| 1090 | + } else { | |
| 1091 | + events = args[0].events; | |
| 1092 | + data = args[0].data; | |
| 1093 | + context = args[0].context || self; | |
| 1094 | + } | |
| 1095 | + var eventsArray = Array.isArray(events) ? events : events.split(' '); | |
| 1096 | + eventsArray.forEach(function (event) { | |
| 1097 | + if (self.eventsListeners && self.eventsListeners[event]) { | |
| 1098 | + var handlers = []; | |
| 1099 | + self.eventsListeners[event].forEach(function (eventHandler) { | |
| 1100 | + handlers.push(eventHandler); | |
| 1101 | + }); | |
| 1102 | + handlers.forEach(function (eventHandler) { | |
| 1103 | + eventHandler.apply(context, data); | |
| 1104 | + }); | |
| 1105 | + } | |
| 1106 | + }); | |
| 1107 | + return self; | |
| 1108 | + }; | |
| 1109 | + | |
| 1110 | + SwiperClass.prototype.useModulesParams = function useModulesParams (instanceParams) { | |
| 1111 | + var instance = this; | |
| 1112 | + if (!instance.modules) { return; } | |
| 1113 | + Object.keys(instance.modules).forEach(function (moduleName) { | |
| 1114 | + var module = instance.modules[moduleName]; | |
| 1115 | + // Extend params | |
| 1116 | + if (module.params) { | |
| 1117 | + Utils.extend(instanceParams, module.params); | |
| 1118 | + } | |
| 1119 | + }); | |
| 1120 | + }; | |
| 1121 | + | |
| 1122 | + SwiperClass.prototype.useModules = function useModules (modulesParams) { | |
| 1123 | + if ( modulesParams === void 0 ) modulesParams = {}; | |
| 1124 | + | |
| 1125 | + var instance = this; | |
| 1126 | + if (!instance.modules) { return; } | |
| 1127 | + Object.keys(instance.modules).forEach(function (moduleName) { | |
| 1128 | + var module = instance.modules[moduleName]; | |
| 1129 | + var moduleParams = modulesParams[moduleName] || {}; | |
| 1130 | + // Extend instance methods and props | |
| 1131 | + if (module.instance) { | |
| 1132 | + Object.keys(module.instance).forEach(function (modulePropName) { | |
| 1133 | + var moduleProp = module.instance[modulePropName]; | |
| 1134 | + if (typeof moduleProp === 'function') { | |
| 1135 | + instance[modulePropName] = moduleProp.bind(instance); | |
| 1136 | + } else { | |
| 1137 | + instance[modulePropName] = moduleProp; | |
| 1138 | + } | |
| 1139 | + }); | |
| 1140 | + } | |
| 1141 | + // Add event listeners | |
| 1142 | + if (module.on && instance.on) { | |
| 1143 | + Object.keys(module.on).forEach(function (moduleEventName) { | |
| 1144 | + instance.on(moduleEventName, module.on[moduleEventName]); | |
| 1145 | + }); | |
| 1146 | + } | |
| 1147 | + | |
| 1148 | + // Module create callback | |
| 1149 | + if (module.create) { | |
| 1150 | + module.create.bind(instance)(moduleParams); | |
| 1151 | + } | |
| 1152 | + }); | |
| 1153 | + }; | |
| 1154 | + | |
| 1155 | + staticAccessors.components.set = function (components) { | |
| 1156 | + var Class = this; | |
| 1157 | + if (!Class.use) { return; } | |
| 1158 | + Class.use(components); | |
| 1159 | + }; | |
| 1160 | + | |
| 1161 | + SwiperClass.installModule = function installModule (module) { | |
| 1162 | + var params = [], len = arguments.length - 1; | |
| 1163 | + while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ]; | |
| 1164 | + | |
| 1165 | + var Class = this; | |
| 1166 | + if (!Class.prototype.modules) { Class.prototype.modules = {}; } | |
| 1167 | + var name = module.name || (((Object.keys(Class.prototype.modules).length) + "_" + (Utils.now()))); | |
| 1168 | + Class.prototype.modules[name] = module; | |
| 1169 | + // Prototype | |
| 1170 | + if (module.proto) { | |
| 1171 | + Object.keys(module.proto).forEach(function (key) { | |
| 1172 | + Class.prototype[key] = module.proto[key]; | |
| 1173 | + }); | |
| 1174 | + } | |
| 1175 | + // Class | |
| 1176 | + if (module.static) { | |
| 1177 | + Object.keys(module.static).forEach(function (key) { | |
| 1178 | + Class[key] = module.static[key]; | |
| 1179 | + }); | |
| 1180 | + } | |
| 1181 | + // Callback | |
| 1182 | + if (module.install) { | |
| 1183 | + module.install.apply(Class, params); | |
| 1184 | + } | |
| 1185 | + return Class; | |
| 1186 | + }; | |
| 1187 | + | |
| 1188 | + SwiperClass.use = function use (module) { | |
| 1189 | + var params = [], len = arguments.length - 1; | |
| 1190 | + while ( len-- > 0 ) params[ len ] = arguments[ len + 1 ]; | |
| 1191 | + | |
| 1192 | + var Class = this; | |
| 1193 | + if (Array.isArray(module)) { | |
| 1194 | + module.forEach(function (m) { return Class.installModule(m); }); | |
| 1195 | + return Class; | |
| 1196 | + } | |
| 1197 | + return Class.installModule.apply(Class, [ module ].concat( params )); | |
| 1198 | + }; | |
| 1199 | + | |
| 1200 | + Object.defineProperties( SwiperClass, staticAccessors ); | |
| 1201 | + | |
| 1202 | + function updateSize () { | |
| 1203 | + var swiper = this; | |
| 1204 | + var width; | |
| 1205 | + var height; | |
| 1206 | + var $el = swiper.$el; | |
| 1207 | + if (typeof swiper.params.width !== 'undefined') { | |
| 1208 | + width = swiper.params.width; | |
| 1209 | + } else { | |
| 1210 | + width = $el[0].clientWidth; | |
| 1211 | + } | |
| 1212 | + if (typeof swiper.params.height !== 'undefined') { | |
| 1213 | + height = swiper.params.height; | |
| 1214 | + } else { | |
| 1215 | + height = $el[0].clientHeight; | |
| 1216 | + } | |
| 1217 | + if ((width === 0 && swiper.isHorizontal()) || (height === 0 && swiper.isVertical())) { | |
| 1218 | + return; | |
| 1219 | + } | |
| 1220 | + | |
| 1221 | + // Subtract paddings | |
| 1222 | + width = width - parseInt($el.css('padding-left'), 10) - parseInt($el.css('padding-right'), 10); | |
| 1223 | + height = height - parseInt($el.css('padding-top'), 10) - parseInt($el.css('padding-bottom'), 10); | |
| 1224 | + | |
| 1225 | + Utils.extend(swiper, { | |
| 1226 | + width: width, | |
| 1227 | + height: height, | |
| 1228 | + size: swiper.isHorizontal() ? width : height, | |
| 1229 | + }); | |
| 1230 | + } | |
| 1231 | + | |
| 1232 | + function updateSlides () { | |
| 1233 | + var swiper = this; | |
| 1234 | + var params = swiper.params; | |
| 1235 | + | |
| 1236 | + var $wrapperEl = swiper.$wrapperEl; | |
| 1237 | + var swiperSize = swiper.size; | |
| 1238 | + var rtl = swiper.rtlTranslate; | |
| 1239 | + var wrongRTL = swiper.wrongRTL; | |
| 1240 | + var isVirtual = swiper.virtual && params.virtual.enabled; | |
| 1241 | + var previousSlidesLength = isVirtual ? swiper.virtual.slides.length : swiper.slides.length; | |
| 1242 | + var slides = $wrapperEl.children(("." + (swiper.params.slideClass))); | |
| 1243 | + var slidesLength = isVirtual ? swiper.virtual.slides.length : slides.length; | |
| 1244 | + var snapGrid = []; | |
| 1245 | + var slidesGrid = []; | |
| 1246 | + var slidesSizesGrid = []; | |
| 1247 | + | |
| 1248 | + var offsetBefore = params.slidesOffsetBefore; | |
| 1249 | + if (typeof offsetBefore === 'function') { | |
| 1250 | + offsetBefore = params.slidesOffsetBefore.call(swiper); | |
| 1251 | + } | |
| 1252 | + | |
| 1253 | + var offsetAfter = params.slidesOffsetAfter; | |
| 1254 | + if (typeof offsetAfter === 'function') { | |
| 1255 | + offsetAfter = params.slidesOffsetAfter.call(swiper); | |
| 1256 | + } | |
| 1257 | + | |
| 1258 | + var previousSnapGridLength = swiper.snapGrid.length; | |
| 1259 | + var previousSlidesGridLength = swiper.snapGrid.length; | |
| 1260 | + | |
| 1261 | + var spaceBetween = params.spaceBetween; | |
| 1262 | + var slidePosition = -offsetBefore; | |
| 1263 | + var prevSlideSize = 0; | |
| 1264 | + var index = 0; | |
| 1265 | + if (typeof swiperSize === 'undefined') { | |
| 1266 | + return; | |
| 1267 | + } | |
| 1268 | + if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) { | |
| 1269 | + spaceBetween = (parseFloat(spaceBetween.replace('%', '')) / 100) * swiperSize; | |
| 1270 | + } | |
| 1271 | + | |
| 1272 | + swiper.virtualSize = -spaceBetween; | |
| 1273 | + | |
| 1274 | + // reset margins | |
| 1275 | + if (rtl) { slides.css({ marginLeft: '', marginTop: '' }); } | |
| 1276 | + else { slides.css({ marginRight: '', marginBottom: '' }); } | |
| 1277 | + | |
| 1278 | + var slidesNumberEvenToRows; | |
| 1279 | + if (params.slidesPerColumn > 1) { | |
| 1280 | + if (Math.floor(slidesLength / params.slidesPerColumn) === slidesLength / swiper.params.slidesPerColumn) { | |
| 1281 | + slidesNumberEvenToRows = slidesLength; | |
| 1282 | + } else { | |
| 1283 | + slidesNumberEvenToRows = Math.ceil(slidesLength / params.slidesPerColumn) * params.slidesPerColumn; | |
| 1284 | + } | |
| 1285 | + if (params.slidesPerView !== 'auto' && params.slidesPerColumnFill === 'row') { | |
| 1286 | + slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, params.slidesPerView * params.slidesPerColumn); | |
| 1287 | + } | |
| 1288 | + } | |
| 1289 | + | |
| 1290 | + // Calc slides | |
| 1291 | + var slideSize; | |
| 1292 | + var slidesPerColumn = params.slidesPerColumn; | |
| 1293 | + var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn; | |
| 1294 | + var numFullColumns = Math.floor(slidesLength / params.slidesPerColumn); | |
| 1295 | + for (var i = 0; i < slidesLength; i += 1) { | |
| 1296 | + slideSize = 0; | |
| 1297 | + var slide = slides.eq(i); | |
| 1298 | + if (params.slidesPerColumn > 1) { | |
| 1299 | + // Set slides order | |
| 1300 | + var newSlideOrderIndex = (void 0); | |
| 1301 | + var column = (void 0); | |
| 1302 | + var row = (void 0); | |
| 1303 | + if (params.slidesPerColumnFill === 'column') { | |
| 1304 | + column = Math.floor(i / slidesPerColumn); | |
| 1305 | + row = i - (column * slidesPerColumn); | |
| 1306 | + if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn - 1)) { | |
| 1307 | + row += 1; | |
| 1308 | + if (row >= slidesPerColumn) { | |
| 1309 | + row = 0; | |
| 1310 | + column += 1; | |
| 1311 | + } | |
| 1312 | + } | |
| 1313 | + newSlideOrderIndex = column + ((row * slidesNumberEvenToRows) / slidesPerColumn); | |
| 1314 | + slide | |
| 1315 | + .css({ | |
| 1316 | + '-webkit-box-ordinal-group': newSlideOrderIndex, | |
| 1317 | + '-moz-box-ordinal-group': newSlideOrderIndex, | |
| 1318 | + '-ms-flex-order': newSlideOrderIndex, | |
| 1319 | + '-webkit-order': newSlideOrderIndex, | |
| 1320 | + order: newSlideOrderIndex, | |
| 1321 | + }); | |
| 1322 | + } else { | |
| 1323 | + row = Math.floor(i / slidesPerRow); | |
| 1324 | + column = i - (row * slidesPerRow); | |
| 1325 | + } | |
| 1326 | + slide | |
| 1327 | + .css( | |
| 1328 | + ("margin-" + (swiper.isHorizontal() ? 'top' : 'left')), | |
| 1329 | + (row !== 0 && params.spaceBetween) && (((params.spaceBetween) + "px")) | |
| 1330 | + ) | |
| 1331 | + .attr('data-swiper-column', column) | |
| 1332 | + .attr('data-swiper-row', row); | |
| 1333 | + } | |
| 1334 | + if (slide.css('display') === 'none') { continue; } // eslint-disable-line | |
| 1335 | + | |
| 1336 | + if (params.slidesPerView === 'auto') { | |
| 1337 | + var slideStyles = win.getComputedStyle(slide[0], null); | |
| 1338 | + var currentTransform = slide[0].style.transform; | |
| 1339 | + var currentWebKitTransform = slide[0].style.webkitTransform; | |
| 1340 | + if (currentTransform) { | |
| 1341 | + slide[0].style.transform = 'none'; | |
| 1342 | + } | |
| 1343 | + if (currentWebKitTransform) { | |
| 1344 | + slide[0].style.webkitTransform = 'none'; | |
| 1345 | + } | |
| 1346 | + if (params.roundLengths) { | |
| 1347 | + slideSize = swiper.isHorizontal() | |
| 1348 | + ? slide.outerWidth(true) | |
| 1349 | + : slide.outerHeight(true); | |
| 1350 | + } else { | |
| 1351 | + // eslint-disable-next-line | |
| 1352 | + if (swiper.isHorizontal()) { | |
| 1353 | + var width = parseFloat(slideStyles.getPropertyValue('width')); | |
| 1354 | + var paddingLeft = parseFloat(slideStyles.getPropertyValue('padding-left')); | |
| 1355 | + var paddingRight = parseFloat(slideStyles.getPropertyValue('padding-right')); | |
| 1356 | + var marginLeft = parseFloat(slideStyles.getPropertyValue('margin-left')); | |
| 1357 | + var marginRight = parseFloat(slideStyles.getPropertyValue('margin-right')); | |
| 1358 | + var boxSizing = slideStyles.getPropertyValue('box-sizing'); | |
| 1359 | + if (boxSizing && boxSizing === 'border-box') { | |
| 1360 | + slideSize = width + marginLeft + marginRight; | |
| 1361 | + } else { | |
| 1362 | + slideSize = width + paddingLeft + paddingRight + marginLeft + marginRight; | |
| 1363 | + } | |
| 1364 | + } else { | |
| 1365 | + var height = parseFloat(slideStyles.getPropertyValue('height')); | |
| 1366 | + var paddingTop = parseFloat(slideStyles.getPropertyValue('padding-top')); | |
| 1367 | + var paddingBottom = parseFloat(slideStyles.getPropertyValue('padding-bottom')); | |
| 1368 | + var marginTop = parseFloat(slideStyles.getPropertyValue('margin-top')); | |
| 1369 | + var marginBottom = parseFloat(slideStyles.getPropertyValue('margin-bottom')); | |
| 1370 | + var boxSizing$1 = slideStyles.getPropertyValue('box-sizing'); | |
| 1371 | + if (boxSizing$1 && boxSizing$1 === 'border-box') { | |
| 1372 | + slideSize = height + marginTop + marginBottom; | |
| 1373 | + } else { | |
| 1374 | + slideSize = height + paddingTop + paddingBottom + marginTop + marginBottom; | |
| 1375 | + } | |
| 1376 | + } | |
| 1377 | + } | |
| 1378 | + if (currentTransform) { | |
| 1379 | + slide[0].style.transform = currentTransform; | |
| 1380 | + } | |
| 1381 | + if (currentWebKitTransform) { | |
| 1382 | + slide[0].style.webkitTransform = currentWebKitTransform; | |
| 1383 | + } | |
| 1384 | + if (params.roundLengths) { slideSize = Math.floor(slideSize); } | |
| 1385 | + } else { | |
| 1386 | + slideSize = (swiperSize - ((params.slidesPerView - 1) * spaceBetween)) / params.slidesPerView; | |
| 1387 | + if (params.roundLengths) { slideSize = Math.floor(slideSize); } | |
| 1388 | + | |
| 1389 | + if (slides[i]) { | |
| 1390 | + if (swiper.isHorizontal()) { | |
| 1391 | + slides[i].style.width = slideSize + "px"; | |
| 1392 | + } else { | |
| 1393 | + slides[i].style.height = slideSize + "px"; | |
| 1394 | + } | |
| 1395 | + } | |
| 1396 | + } | |
| 1397 | + if (slides[i]) { | |
| 1398 | + slides[i].swiperSlideSize = slideSize; | |
| 1399 | + } | |
| 1400 | + slidesSizesGrid.push(slideSize); | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + if (params.centeredSlides) { | |
| 1404 | + slidePosition = slidePosition + (slideSize / 2) + (prevSlideSize / 2) + spaceBetween; | |
| 1405 | + if (prevSlideSize === 0 && i !== 0) { slidePosition = slidePosition - (swiperSize / 2) - spaceBetween; } | |
| 1406 | + if (i === 0) { slidePosition = slidePosition - (swiperSize / 2) - spaceBetween; } | |
| 1407 | + if (Math.abs(slidePosition) < 1 / 1000) { slidePosition = 0; } | |
| 1408 | + if (params.roundLengths) { slidePosition = Math.floor(slidePosition); } | |
| 1409 | + if ((index) % params.slidesPerGroup === 0) { snapGrid.push(slidePosition); } | |
| 1410 | + slidesGrid.push(slidePosition); | |
| 1411 | + } else { | |
| 1412 | + if (params.roundLengths) { slidePosition = Math.floor(slidePosition); } | |
| 1413 | + if ((index) % params.slidesPerGroup === 0) { snapGrid.push(slidePosition); } | |
| 1414 | + slidesGrid.push(slidePosition); | |
| 1415 | + slidePosition = slidePosition + slideSize + spaceBetween; | |
| 1416 | + } | |
| 1417 | + | |
| 1418 | + swiper.virtualSize += slideSize + spaceBetween; | |
| 1419 | + | |
| 1420 | + prevSlideSize = slideSize; | |
| 1421 | + | |
| 1422 | + index += 1; | |
| 1423 | + } | |
| 1424 | + swiper.virtualSize = Math.max(swiper.virtualSize, swiperSize) + offsetAfter; | |
| 1425 | + var newSlidesGrid; | |
| 1426 | + | |
| 1427 | + if ( | |
| 1428 | + rtl && wrongRTL && (params.effect === 'slide' || params.effect === 'coverflow')) { | |
| 1429 | + $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); | |
| 1430 | + } | |
| 1431 | + if (!Support.flexbox || params.setWrapperSize) { | |
| 1432 | + if (swiper.isHorizontal()) { $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); } | |
| 1433 | + else { $wrapperEl.css({ height: ((swiper.virtualSize + params.spaceBetween) + "px") }); } | |
| 1434 | + } | |
| 1435 | + | |
| 1436 | + if (params.slidesPerColumn > 1) { | |
| 1437 | + swiper.virtualSize = (slideSize + params.spaceBetween) * slidesNumberEvenToRows; | |
| 1438 | + swiper.virtualSize = Math.ceil(swiper.virtualSize / params.slidesPerColumn) - params.spaceBetween; | |
| 1439 | + if (swiper.isHorizontal()) { $wrapperEl.css({ width: ((swiper.virtualSize + params.spaceBetween) + "px") }); } | |
| 1440 | + else { $wrapperEl.css({ height: ((swiper.virtualSize + params.spaceBetween) + "px") }); } | |
| 1441 | + if (params.centeredSlides) { | |
| 1442 | + newSlidesGrid = []; | |
| 1443 | + for (var i$1 = 0; i$1 < snapGrid.length; i$1 += 1) { | |
| 1444 | + var slidesGridItem = snapGrid[i$1]; | |
| 1445 | + if (params.roundLengths) { slidesGridItem = Math.floor(slidesGridItem); } | |
| 1446 | + if (snapGrid[i$1] < swiper.virtualSize + snapGrid[0]) { newSlidesGrid.push(slidesGridItem); } | |
| 1447 | + } | |
| 1448 | + snapGrid = newSlidesGrid; | |
| 1449 | + } | |
| 1450 | + } | |
| 1451 | + | |
| 1452 | + // Remove last grid elements depending on width | |
| 1453 | + if (!params.centeredSlides) { | |
| 1454 | + newSlidesGrid = []; | |
| 1455 | + for (var i$2 = 0; i$2 < snapGrid.length; i$2 += 1) { | |
| 1456 | + var slidesGridItem$1 = snapGrid[i$2]; | |
| 1457 | + if (params.roundLengths) { slidesGridItem$1 = Math.floor(slidesGridItem$1); } | |
| 1458 | + if (snapGrid[i$2] <= swiper.virtualSize - swiperSize) { | |
| 1459 | + newSlidesGrid.push(slidesGridItem$1); | |
| 1460 | + } | |
| 1461 | + } | |
| 1462 | + snapGrid = newSlidesGrid; | |
| 1463 | + if (Math.floor(swiper.virtualSize - swiperSize) - Math.floor(snapGrid[snapGrid.length - 1]) > 1) { | |
| 1464 | + snapGrid.push(swiper.virtualSize - swiperSize); | |
| 1465 | + } | |
| 1466 | + } | |
| 1467 | + if (snapGrid.length === 0) { snapGrid = [0]; } | |
| 1468 | + | |
| 1469 | + if (params.spaceBetween !== 0) { | |
| 1470 | + if (swiper.isHorizontal()) { | |
| 1471 | + if (rtl) { slides.css({ marginLeft: (spaceBetween + "px") }); } | |
| 1472 | + else { slides.css({ marginRight: (spaceBetween + "px") }); } | |
| 1473 | + } else { slides.css({ marginBottom: (spaceBetween + "px") }); } | |
| 1474 | + } | |
| 1475 | + | |
| 1476 | + if (params.centerInsufficientSlides) { | |
| 1477 | + var allSlidesSize = 0; | |
| 1478 | + slidesSizesGrid.forEach(function (slideSizeValue) { | |
| 1479 | + allSlidesSize += slideSizeValue + (params.spaceBetween ? params.spaceBetween : 0); | |
| 1480 | + }); | |
| 1481 | + allSlidesSize -= params.spaceBetween; | |
| 1482 | + if (allSlidesSize < swiperSize) { | |
| 1483 | + var allSlidesOffset = (swiperSize - allSlidesSize) / 2; | |
| 1484 | + snapGrid.forEach(function (snap, snapIndex) { | |
| 1485 | + snapGrid[snapIndex] = snap - allSlidesOffset; | |
| 1486 | + }); | |
| 1487 | + slidesGrid.forEach(function (snap, snapIndex) { | |
| 1488 | + slidesGrid[snapIndex] = snap + allSlidesOffset; | |
| 1489 | + }); | |
| 1490 | + } | |
| 1491 | + } | |
| 1492 | + | |
| 1493 | + Utils.extend(swiper, { | |
| 1494 | + slides: slides, | |
| 1495 | + snapGrid: snapGrid, | |
| 1496 | + slidesGrid: slidesGrid, | |
| 1497 | + slidesSizesGrid: slidesSizesGrid, | |
| 1498 | + }); | |
| 1499 | + | |
| 1500 | + if (slidesLength !== previousSlidesLength) { | |
| 1501 | + swiper.emit('slidesLengthChange'); | |
| 1502 | + } | |
| 1503 | + if (snapGrid.length !== previousSnapGridLength) { | |
| 1504 | + if (swiper.params.watchOverflow) { swiper.checkOverflow(); } | |
| 1505 | + swiper.emit('snapGridLengthChange'); | |
| 1506 | + } | |
| 1507 | + if (slidesGrid.length !== previousSlidesGridLength) { | |
| 1508 | + swiper.emit('slidesGridLengthChange'); | |
| 1509 | + } | |
| 1510 | + | |
| 1511 | + if (params.watchSlidesProgress || params.watchSlidesVisibility) { | |
| 1512 | + swiper.updateSlidesOffset(); | |
| 1513 | + } | |
| 1514 | + } | |
| 1515 | + | |
| 1516 | + function updateAutoHeight (speed) { | |
| 1517 | + var swiper = this; | |
| 1518 | + var activeSlides = []; | |
| 1519 | + var newHeight = 0; | |
| 1520 | + var i; | |
| 1521 | + if (typeof speed === 'number') { | |
| 1522 | + swiper.setTransition(speed); | |
| 1523 | + } else if (speed === true) { | |
| 1524 | + swiper.setTransition(swiper.params.speed); | |
| 1525 | + } | |
| 1526 | + // Find slides currently in view | |
| 1527 | + if (swiper.params.slidesPerView !== 'auto' && swiper.params.slidesPerView > 1) { | |
| 1528 | + for (i = 0; i < Math.ceil(swiper.params.slidesPerView); i += 1) { | |
| 1529 | + var index = swiper.activeIndex + i; | |
| 1530 | + if (index > swiper.slides.length) { break; } | |
| 1531 | + activeSlides.push(swiper.slides.eq(index)[0]); | |
| 1532 | + } | |
| 1533 | + } else { | |
| 1534 | + activeSlides.push(swiper.slides.eq(swiper.activeIndex)[0]); | |
| 1535 | + } | |
| 1536 | + | |
| 1537 | + // Find new height from highest slide in view | |
| 1538 | + for (i = 0; i < activeSlides.length; i += 1) { | |
| 1539 | + if (typeof activeSlides[i] !== 'undefined') { | |
| 1540 | + var height = activeSlides[i].offsetHeight; | |
| 1541 | + newHeight = height > newHeight ? height : newHeight; | |
| 1542 | + } | |
| 1543 | + } | |
| 1544 | + | |
| 1545 | + // Update Height | |
| 1546 | + if (newHeight) { swiper.$wrapperEl.css('height', (newHeight + "px")); } | |
| 1547 | + } | |
| 1548 | + | |
| 1549 | + function updateSlidesOffset () { | |
| 1550 | + var swiper = this; | |
| 1551 | + var slides = swiper.slides; | |
| 1552 | + for (var i = 0; i < slides.length; i += 1) { | |
| 1553 | + slides[i].swiperSlideOffset = swiper.isHorizontal() ? slides[i].offsetLeft : slides[i].offsetTop; | |
| 1554 | + } | |
| 1555 | + } | |
| 1556 | + | |
| 1557 | + function updateSlidesProgress (translate) { | |
| 1558 | + if ( translate === void 0 ) translate = (this && this.translate) || 0; | |
| 1559 | + | |
| 1560 | + var swiper = this; | |
| 1561 | + var params = swiper.params; | |
| 1562 | + | |
| 1563 | + var slides = swiper.slides; | |
| 1564 | + var rtl = swiper.rtlTranslate; | |
| 1565 | + | |
| 1566 | + if (slides.length === 0) { return; } | |
| 1567 | + if (typeof slides[0].swiperSlideOffset === 'undefined') { swiper.updateSlidesOffset(); } | |
| 1568 | + | |
| 1569 | + var offsetCenter = -translate; | |
| 1570 | + if (rtl) { offsetCenter = translate; } | |
| 1571 | + | |
| 1572 | + // Visible Slides | |
| 1573 | + slides.removeClass(params.slideVisibleClass); | |
| 1574 | + | |
| 1575 | + swiper.visibleSlidesIndexes = []; | |
| 1576 | + swiper.visibleSlides = []; | |
| 1577 | + | |
| 1578 | + for (var i = 0; i < slides.length; i += 1) { | |
| 1579 | + var slide = slides[i]; | |
| 1580 | + var slideProgress = ( | |
| 1581 | + (offsetCenter + (params.centeredSlides ? swiper.minTranslate() : 0)) - slide.swiperSlideOffset | |
| 1582 | + ) / (slide.swiperSlideSize + params.spaceBetween); | |
| 1583 | + if (params.watchSlidesVisibility) { | |
| 1584 | + var slideBefore = -(offsetCenter - slide.swiperSlideOffset); | |
| 1585 | + var slideAfter = slideBefore + swiper.slidesSizesGrid[i]; | |
| 1586 | + var isVisible = (slideBefore >= 0 && slideBefore < swiper.size) | |
| 1587 | + || (slideAfter > 0 && slideAfter <= swiper.size) | |
| 1588 | + || (slideBefore <= 0 && slideAfter >= swiper.size); | |
| 1589 | + if (isVisible) { | |
| 1590 | + swiper.visibleSlides.push(slide); | |
| 1591 | + swiper.visibleSlidesIndexes.push(i); | |
| 1592 | + slides.eq(i).addClass(params.slideVisibleClass); | |
| 1593 | + } | |
| 1594 | + } | |
| 1595 | + slide.progress = rtl ? -slideProgress : slideProgress; | |
| 1596 | + } | |
| 1597 | + swiper.visibleSlides = $(swiper.visibleSlides); | |
| 1598 | + } | |
| 1599 | + | |
| 1600 | + function updateProgress (translate) { | |
| 1601 | + if ( translate === void 0 ) translate = (this && this.translate) || 0; | |
| 1602 | + | |
| 1603 | + var swiper = this; | |
| 1604 | + var params = swiper.params; | |
| 1605 | + | |
| 1606 | + var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); | |
| 1607 | + var progress = swiper.progress; | |
| 1608 | + var isBeginning = swiper.isBeginning; | |
| 1609 | + var isEnd = swiper.isEnd; | |
| 1610 | + var wasBeginning = isBeginning; | |
| 1611 | + var wasEnd = isEnd; | |
| 1612 | + if (translatesDiff === 0) { | |
| 1613 | + progress = 0; | |
| 1614 | + isBeginning = true; | |
| 1615 | + isEnd = true; | |
| 1616 | + } else { | |
| 1617 | + progress = (translate - swiper.minTranslate()) / (translatesDiff); | |
| 1618 | + isBeginning = progress <= 0; | |
| 1619 | + isEnd = progress >= 1; | |
| 1620 | + } | |
| 1621 | + Utils.extend(swiper, { | |
| 1622 | + progress: progress, | |
| 1623 | + isBeginning: isBeginning, | |
| 1624 | + isEnd: isEnd, | |
| 1625 | + }); | |
| 1626 | + | |
| 1627 | + if (params.watchSlidesProgress || params.watchSlidesVisibility) { swiper.updateSlidesProgress(translate); } | |
| 1628 | + | |
| 1629 | + if (isBeginning && !wasBeginning) { | |
| 1630 | + swiper.emit('reachBeginning toEdge'); | |
| 1631 | + } | |
| 1632 | + if (isEnd && !wasEnd) { | |
| 1633 | + swiper.emit('reachEnd toEdge'); | |
| 1634 | + } | |
| 1635 | + if ((wasBeginning && !isBeginning) || (wasEnd && !isEnd)) { | |
| 1636 | + swiper.emit('fromEdge'); | |
| 1637 | + } | |
| 1638 | + | |
| 1639 | + swiper.emit('progress', progress); | |
| 1640 | + } | |
| 1641 | + | |
| 1642 | + function updateSlidesClasses () { | |
| 1643 | + var swiper = this; | |
| 1644 | + | |
| 1645 | + var slides = swiper.slides; | |
| 1646 | + var params = swiper.params; | |
| 1647 | + var $wrapperEl = swiper.$wrapperEl; | |
| 1648 | + var activeIndex = swiper.activeIndex; | |
| 1649 | + var realIndex = swiper.realIndex; | |
| 1650 | + var isVirtual = swiper.virtual && params.virtual.enabled; | |
| 1651 | + | |
| 1652 | + slides.removeClass(((params.slideActiveClass) + " " + (params.slideNextClass) + " " + (params.slidePrevClass) + " " + (params.slideDuplicateActiveClass) + " " + (params.slideDuplicateNextClass) + " " + (params.slideDuplicatePrevClass))); | |
| 1653 | + | |
| 1654 | + var activeSlide; | |
| 1655 | + if (isVirtual) { | |
| 1656 | + activeSlide = swiper.$wrapperEl.find(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + activeIndex + "\"]")); | |
| 1657 | + } else { | |
| 1658 | + activeSlide = slides.eq(activeIndex); | |
| 1659 | + } | |
| 1660 | + | |
| 1661 | + // Active classes | |
| 1662 | + activeSlide.addClass(params.slideActiveClass); | |
| 1663 | + | |
| 1664 | + if (params.loop) { | |
| 1665 | + // Duplicate to all looped slides | |
| 1666 | + if (activeSlide.hasClass(params.slideDuplicateClass)) { | |
| 1667 | + $wrapperEl | |
| 1668 | + .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + realIndex + "\"]")) | |
| 1669 | + .addClass(params.slideDuplicateActiveClass); | |
| 1670 | + } else { | |
| 1671 | + $wrapperEl | |
| 1672 | + .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]")) | |
| 1673 | + .addClass(params.slideDuplicateActiveClass); | |
| 1674 | + } | |
| 1675 | + } | |
| 1676 | + // Next Slide | |
| 1677 | + var nextSlide = activeSlide.nextAll(("." + (params.slideClass))).eq(0).addClass(params.slideNextClass); | |
| 1678 | + if (params.loop && nextSlide.length === 0) { | |
| 1679 | + nextSlide = slides.eq(0); | |
| 1680 | + nextSlide.addClass(params.slideNextClass); | |
| 1681 | + } | |
| 1682 | + // Prev Slide | |
| 1683 | + var prevSlide = activeSlide.prevAll(("." + (params.slideClass))).eq(0).addClass(params.slidePrevClass); | |
| 1684 | + if (params.loop && prevSlide.length === 0) { | |
| 1685 | + prevSlide = slides.eq(-1); | |
| 1686 | + prevSlide.addClass(params.slidePrevClass); | |
| 1687 | + } | |
| 1688 | + if (params.loop) { | |
| 1689 | + // Duplicate to all looped slides | |
| 1690 | + if (nextSlide.hasClass(params.slideDuplicateClass)) { | |
| 1691 | + $wrapperEl | |
| 1692 | + .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + (nextSlide.attr('data-swiper-slide-index')) + "\"]")) | |
| 1693 | + .addClass(params.slideDuplicateNextClass); | |
| 1694 | + } else { | |
| 1695 | + $wrapperEl | |
| 1696 | + .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + (nextSlide.attr('data-swiper-slide-index')) + "\"]")) | |
| 1697 | + .addClass(params.slideDuplicateNextClass); | |
| 1698 | + } | |
| 1699 | + if (prevSlide.hasClass(params.slideDuplicateClass)) { | |
| 1700 | + $wrapperEl | |
| 1701 | + .children(("." + (params.slideClass) + ":not(." + (params.slideDuplicateClass) + ")[data-swiper-slide-index=\"" + (prevSlide.attr('data-swiper-slide-index')) + "\"]")) | |
| 1702 | + .addClass(params.slideDuplicatePrevClass); | |
| 1703 | + } else { | |
| 1704 | + $wrapperEl | |
| 1705 | + .children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + (prevSlide.attr('data-swiper-slide-index')) + "\"]")) | |
| 1706 | + .addClass(params.slideDuplicatePrevClass); | |
| 1707 | + } | |
| 1708 | + } | |
| 1709 | + } | |
| 1710 | + | |
| 1711 | + function updateActiveIndex (newActiveIndex) { | |
| 1712 | + var swiper = this; | |
| 1713 | + var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; | |
| 1714 | + var slidesGrid = swiper.slidesGrid; | |
| 1715 | + var snapGrid = swiper.snapGrid; | |
| 1716 | + var params = swiper.params; | |
| 1717 | + var previousIndex = swiper.activeIndex; | |
| 1718 | + var previousRealIndex = swiper.realIndex; | |
| 1719 | + var previousSnapIndex = swiper.snapIndex; | |
| 1720 | + var activeIndex = newActiveIndex; | |
| 1721 | + var snapIndex; | |
| 1722 | + if (typeof activeIndex === 'undefined') { | |
| 1723 | + for (var i = 0; i < slidesGrid.length; i += 1) { | |
| 1724 | + if (typeof slidesGrid[i + 1] !== 'undefined') { | |
| 1725 | + if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1] - ((slidesGrid[i + 1] - slidesGrid[i]) / 2)) { | |
| 1726 | + activeIndex = i; | |
| 1727 | + } else if (translate >= slidesGrid[i] && translate < slidesGrid[i + 1]) { | |
| 1728 | + activeIndex = i + 1; | |
| 1729 | + } | |
| 1730 | + } else if (translate >= slidesGrid[i]) { | |
| 1731 | + activeIndex = i; | |
| 1732 | + } | |
| 1733 | + } | |
| 1734 | + // Normalize slideIndex | |
| 1735 | + if (params.normalizeSlideIndex) { | |
| 1736 | + if (activeIndex < 0 || typeof activeIndex === 'undefined') { activeIndex = 0; } | |
| 1737 | + } | |
| 1738 | + } | |
| 1739 | + if (snapGrid.indexOf(translate) >= 0) { | |
| 1740 | + snapIndex = snapGrid.indexOf(translate); | |
| 1741 | + } else { | |
| 1742 | + snapIndex = Math.floor(activeIndex / params.slidesPerGroup); | |
| 1743 | + } | |
| 1744 | + if (snapIndex >= snapGrid.length) { snapIndex = snapGrid.length - 1; } | |
| 1745 | + if (activeIndex === previousIndex) { | |
| 1746 | + if (snapIndex !== previousSnapIndex) { | |
| 1747 | + swiper.snapIndex = snapIndex; | |
| 1748 | + swiper.emit('snapIndexChange'); | |
| 1749 | + } | |
| 1750 | + return; | |
| 1751 | + } | |
| 1752 | + | |
| 1753 | + // Get real index | |
| 1754 | + var realIndex = parseInt(swiper.slides.eq(activeIndex).attr('data-swiper-slide-index') || activeIndex, 10); | |
| 1755 | + | |
| 1756 | + Utils.extend(swiper, { | |
| 1757 | + snapIndex: snapIndex, | |
| 1758 | + realIndex: realIndex, | |
| 1759 | + previousIndex: previousIndex, | |
| 1760 | + activeIndex: activeIndex, | |
| 1761 | + }); | |
| 1762 | + swiper.emit('activeIndexChange'); | |
| 1763 | + swiper.emit('snapIndexChange'); | |
| 1764 | + if (previousRealIndex !== realIndex) { | |
| 1765 | + swiper.emit('realIndexChange'); | |
| 1766 | + } | |
| 1767 | + swiper.emit('slideChange'); | |
| 1768 | + } | |
| 1769 | + | |
| 1770 | + function updateClickedSlide (e) { | |
| 1771 | + var swiper = this; | |
| 1772 | + var params = swiper.params; | |
| 1773 | + var slide = $(e.target).closest(("." + (params.slideClass)))[0]; | |
| 1774 | + var slideFound = false; | |
| 1775 | + if (slide) { | |
| 1776 | + for (var i = 0; i < swiper.slides.length; i += 1) { | |
| 1777 | + if (swiper.slides[i] === slide) { slideFound = true; } | |
| 1778 | + } | |
| 1779 | + } | |
| 1780 | + | |
| 1781 | + if (slide && slideFound) { | |
| 1782 | + swiper.clickedSlide = slide; | |
| 1783 | + if (swiper.virtual && swiper.params.virtual.enabled) { | |
| 1784 | + swiper.clickedIndex = parseInt($(slide).attr('data-swiper-slide-index'), 10); | |
| 1785 | + } else { | |
| 1786 | + swiper.clickedIndex = $(slide).index(); | |
| 1787 | + } | |
| 1788 | + } else { | |
| 1789 | + swiper.clickedSlide = undefined; | |
| 1790 | + swiper.clickedIndex = undefined; | |
| 1791 | + return; | |
| 1792 | + } | |
| 1793 | + if (params.slideToClickedSlide && swiper.clickedIndex !== undefined && swiper.clickedIndex !== swiper.activeIndex) { | |
| 1794 | + swiper.slideToClickedSlide(); | |
| 1795 | + } | |
| 1796 | + } | |
| 1797 | + | |
| 1798 | + var update = { | |
| 1799 | + updateSize: updateSize, | |
| 1800 | + updateSlides: updateSlides, | |
| 1801 | + updateAutoHeight: updateAutoHeight, | |
| 1802 | + updateSlidesOffset: updateSlidesOffset, | |
| 1803 | + updateSlidesProgress: updateSlidesProgress, | |
| 1804 | + updateProgress: updateProgress, | |
| 1805 | + updateSlidesClasses: updateSlidesClasses, | |
| 1806 | + updateActiveIndex: updateActiveIndex, | |
| 1807 | + updateClickedSlide: updateClickedSlide, | |
| 1808 | + }; | |
| 1809 | + | |
| 1810 | + function getTranslate (axis) { | |
| 1811 | + if ( axis === void 0 ) axis = this.isHorizontal() ? 'x' : 'y'; | |
| 1812 | + | |
| 1813 | + var swiper = this; | |
| 1814 | + | |
| 1815 | + var params = swiper.params; | |
| 1816 | + var rtl = swiper.rtlTranslate; | |
| 1817 | + var translate = swiper.translate; | |
| 1818 | + var $wrapperEl = swiper.$wrapperEl; | |
| 1819 | + | |
| 1820 | + if (params.virtualTranslate) { | |
| 1821 | + return rtl ? -translate : translate; | |
| 1822 | + } | |
| 1823 | + | |
| 1824 | + var currentTranslate = Utils.getTranslate($wrapperEl[0], axis); | |
| 1825 | + if (rtl) { currentTranslate = -currentTranslate; } | |
| 1826 | + | |
| 1827 | + return currentTranslate || 0; | |
| 1828 | + } | |
| 1829 | + | |
| 1830 | + function setTranslate (translate, byController) { | |
| 1831 | + var swiper = this; | |
| 1832 | + var rtl = swiper.rtlTranslate; | |
| 1833 | + var params = swiper.params; | |
| 1834 | + var $wrapperEl = swiper.$wrapperEl; | |
| 1835 | + var progress = swiper.progress; | |
| 1836 | + var x = 0; | |
| 1837 | + var y = 0; | |
| 1838 | + var z = 0; | |
| 1839 | + | |
| 1840 | + if (swiper.isHorizontal()) { | |
| 1841 | + x = rtl ? -translate : translate; | |
| 1842 | + } else { | |
| 1843 | + y = translate; | |
| 1844 | + } | |
| 1845 | + | |
| 1846 | + if (params.roundLengths) { | |
| 1847 | + x = Math.floor(x); | |
| 1848 | + y = Math.floor(y); | |
| 1849 | + } | |
| 1850 | + | |
| 1851 | + if (!params.virtualTranslate) { | |
| 1852 | + if (Support.transforms3d) { $wrapperEl.transform(("translate3d(" + x + "px, " + y + "px, " + z + "px)")); } | |
| 1853 | + else { $wrapperEl.transform(("translate(" + x + "px, " + y + "px)")); } | |
| 1854 | + } | |
| 1855 | + swiper.previousTranslate = swiper.translate; | |
| 1856 | + swiper.translate = swiper.isHorizontal() ? x : y; | |
| 1857 | + | |
| 1858 | + // Check if we need to update progress | |
| 1859 | + var newProgress; | |
| 1860 | + var translatesDiff = swiper.maxTranslate() - swiper.minTranslate(); | |
| 1861 | + if (translatesDiff === 0) { | |
| 1862 | + newProgress = 0; | |
| 1863 | + } else { | |
| 1864 | + newProgress = (translate - swiper.minTranslate()) / (translatesDiff); | |
| 1865 | + } | |
| 1866 | + if (newProgress !== progress) { | |
| 1867 | + swiper.updateProgress(translate); | |
| 1868 | + } | |
| 1869 | + | |
| 1870 | + swiper.emit('setTranslate', swiper.translate, byController); | |
| 1871 | + } | |
| 1872 | + | |
| 1873 | + function minTranslate () { | |
| 1874 | + return (-this.snapGrid[0]); | |
| 1875 | + } | |
| 1876 | + | |
| 1877 | + function maxTranslate () { | |
| 1878 | + return (-this.snapGrid[this.snapGrid.length - 1]); | |
| 1879 | + } | |
| 1880 | + | |
| 1881 | + var translate = { | |
| 1882 | + getTranslate: getTranslate, | |
| 1883 | + setTranslate: setTranslate, | |
| 1884 | + minTranslate: minTranslate, | |
| 1885 | + maxTranslate: maxTranslate, | |
| 1886 | + }; | |
| 1887 | + | |
| 1888 | + function setTransition (duration, byController) { | |
| 1889 | + var swiper = this; | |
| 1890 | + | |
| 1891 | + swiper.$wrapperEl.transition(duration); | |
| 1892 | + | |
| 1893 | + swiper.emit('setTransition', duration, byController); | |
| 1894 | + } | |
| 1895 | + | |
| 1896 | + function transitionStart (runCallbacks, direction) { | |
| 1897 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 1898 | + | |
| 1899 | + var swiper = this; | |
| 1900 | + var activeIndex = swiper.activeIndex; | |
| 1901 | + var params = swiper.params; | |
| 1902 | + var previousIndex = swiper.previousIndex; | |
| 1903 | + if (params.autoHeight) { | |
| 1904 | + swiper.updateAutoHeight(); | |
| 1905 | + } | |
| 1906 | + | |
| 1907 | + var dir = direction; | |
| 1908 | + if (!dir) { | |
| 1909 | + if (activeIndex > previousIndex) { dir = 'next'; } | |
| 1910 | + else if (activeIndex < previousIndex) { dir = 'prev'; } | |
| 1911 | + else { dir = 'reset'; } | |
| 1912 | + } | |
| 1913 | + | |
| 1914 | + swiper.emit('transitionStart'); | |
| 1915 | + | |
| 1916 | + if (runCallbacks && activeIndex !== previousIndex) { | |
| 1917 | + if (dir === 'reset') { | |
| 1918 | + swiper.emit('slideResetTransitionStart'); | |
| 1919 | + return; | |
| 1920 | + } | |
| 1921 | + swiper.emit('slideChangeTransitionStart'); | |
| 1922 | + if (dir === 'next') { | |
| 1923 | + swiper.emit('slideNextTransitionStart'); | |
| 1924 | + } else { | |
| 1925 | + swiper.emit('slidePrevTransitionStart'); | |
| 1926 | + } | |
| 1927 | + } | |
| 1928 | + } | |
| 1929 | + | |
| 1930 | + function transitionEnd$1 (runCallbacks, direction) { | |
| 1931 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 1932 | + | |
| 1933 | + var swiper = this; | |
| 1934 | + var activeIndex = swiper.activeIndex; | |
| 1935 | + var previousIndex = swiper.previousIndex; | |
| 1936 | + swiper.animating = false; | |
| 1937 | + swiper.setTransition(0); | |
| 1938 | + | |
| 1939 | + var dir = direction; | |
| 1940 | + if (!dir) { | |
| 1941 | + if (activeIndex > previousIndex) { dir = 'next'; } | |
| 1942 | + else if (activeIndex < previousIndex) { dir = 'prev'; } | |
| 1943 | + else { dir = 'reset'; } | |
| 1944 | + } | |
| 1945 | + | |
| 1946 | + swiper.emit('transitionEnd'); | |
| 1947 | + | |
| 1948 | + if (runCallbacks && activeIndex !== previousIndex) { | |
| 1949 | + if (dir === 'reset') { | |
| 1950 | + swiper.emit('slideResetTransitionEnd'); | |
| 1951 | + return; | |
| 1952 | + } | |
| 1953 | + swiper.emit('slideChangeTransitionEnd'); | |
| 1954 | + if (dir === 'next') { | |
| 1955 | + swiper.emit('slideNextTransitionEnd'); | |
| 1956 | + } else { | |
| 1957 | + swiper.emit('slidePrevTransitionEnd'); | |
| 1958 | + } | |
| 1959 | + } | |
| 1960 | + } | |
| 1961 | + | |
| 1962 | + var transition$1 = { | |
| 1963 | + setTransition: setTransition, | |
| 1964 | + transitionStart: transitionStart, | |
| 1965 | + transitionEnd: transitionEnd$1, | |
| 1966 | + }; | |
| 1967 | + | |
| 1968 | + function slideTo (index, speed, runCallbacks, internal) { | |
| 1969 | + if ( index === void 0 ) index = 0; | |
| 1970 | + if ( speed === void 0 ) speed = this.params.speed; | |
| 1971 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 1972 | + | |
| 1973 | + var swiper = this; | |
| 1974 | + var slideIndex = index; | |
| 1975 | + if (slideIndex < 0) { slideIndex = 0; } | |
| 1976 | + | |
| 1977 | + var params = swiper.params; | |
| 1978 | + var snapGrid = swiper.snapGrid; | |
| 1979 | + var slidesGrid = swiper.slidesGrid; | |
| 1980 | + var previousIndex = swiper.previousIndex; | |
| 1981 | + var activeIndex = swiper.activeIndex; | |
| 1982 | + var rtl = swiper.rtlTranslate; | |
| 1983 | + if (swiper.animating && params.preventInteractionOnTransition) { | |
| 1984 | + return false; | |
| 1985 | + } | |
| 1986 | + | |
| 1987 | + var snapIndex = Math.floor(slideIndex / params.slidesPerGroup); | |
| 1988 | + if (snapIndex >= snapGrid.length) { snapIndex = snapGrid.length - 1; } | |
| 1989 | + | |
| 1990 | + if ((activeIndex || params.initialSlide || 0) === (previousIndex || 0) && runCallbacks) { | |
| 1991 | + swiper.emit('beforeSlideChangeStart'); | |
| 1992 | + } | |
| 1993 | + | |
| 1994 | + var translate = -snapGrid[snapIndex]; | |
| 1995 | + | |
| 1996 | + // Update progress | |
| 1997 | + swiper.updateProgress(translate); | |
| 1998 | + | |
| 1999 | + // Normalize slideIndex | |
| 2000 | + if (params.normalizeSlideIndex) { | |
| 2001 | + for (var i = 0; i < slidesGrid.length; i += 1) { | |
| 2002 | + if (-Math.floor(translate * 100) >= Math.floor(slidesGrid[i] * 100)) { | |
| 2003 | + slideIndex = i; | |
| 2004 | + } | |
| 2005 | + } | |
| 2006 | + } | |
| 2007 | + // Directions locks | |
| 2008 | + if (swiper.initialized && slideIndex !== activeIndex) { | |
| 2009 | + if (!swiper.allowSlideNext && translate < swiper.translate && translate < swiper.minTranslate()) { | |
| 2010 | + return false; | |
| 2011 | + } | |
| 2012 | + if (!swiper.allowSlidePrev && translate > swiper.translate && translate > swiper.maxTranslate()) { | |
| 2013 | + if ((activeIndex || 0) !== slideIndex) { return false; } | |
| 2014 | + } | |
| 2015 | + } | |
| 2016 | + | |
| 2017 | + var direction; | |
| 2018 | + if (slideIndex > activeIndex) { direction = 'next'; } | |
| 2019 | + else if (slideIndex < activeIndex) { direction = 'prev'; } | |
| 2020 | + else { direction = 'reset'; } | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + // Update Index | |
| 2024 | + if ((rtl && -translate === swiper.translate) || (!rtl && translate === swiper.translate)) { | |
| 2025 | + swiper.updateActiveIndex(slideIndex); | |
| 2026 | + // Update Height | |
| 2027 | + if (params.autoHeight) { | |
| 2028 | + swiper.updateAutoHeight(); | |
| 2029 | + } | |
| 2030 | + swiper.updateSlidesClasses(); | |
| 2031 | + if (params.effect !== 'slide') { | |
| 2032 | + swiper.setTranslate(translate); | |
| 2033 | + } | |
| 2034 | + if (direction !== 'reset') { | |
| 2035 | + swiper.transitionStart(runCallbacks, direction); | |
| 2036 | + swiper.transitionEnd(runCallbacks, direction); | |
| 2037 | + } | |
| 2038 | + return false; | |
| 2039 | + } | |
| 2040 | + | |
| 2041 | + if (speed === 0 || !Support.transition) { | |
| 2042 | + swiper.setTransition(0); | |
| 2043 | + swiper.setTranslate(translate); | |
| 2044 | + swiper.updateActiveIndex(slideIndex); | |
| 2045 | + swiper.updateSlidesClasses(); | |
| 2046 | + swiper.emit('beforeTransitionStart', speed, internal); | |
| 2047 | + swiper.transitionStart(runCallbacks, direction); | |
| 2048 | + swiper.transitionEnd(runCallbacks, direction); | |
| 2049 | + } else { | |
| 2050 | + swiper.setTransition(speed); | |
| 2051 | + swiper.setTranslate(translate); | |
| 2052 | + swiper.updateActiveIndex(slideIndex); | |
| 2053 | + swiper.updateSlidesClasses(); | |
| 2054 | + swiper.emit('beforeTransitionStart', speed, internal); | |
| 2055 | + swiper.transitionStart(runCallbacks, direction); | |
| 2056 | + if (!swiper.animating) { | |
| 2057 | + swiper.animating = true; | |
| 2058 | + if (!swiper.onSlideToWrapperTransitionEnd) { | |
| 2059 | + swiper.onSlideToWrapperTransitionEnd = function transitionEnd(e) { | |
| 2060 | + if (!swiper || swiper.destroyed) { return; } | |
| 2061 | + if (e.target !== this) { return; } | |
| 2062 | + swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); | |
| 2063 | + swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); | |
| 2064 | + swiper.onSlideToWrapperTransitionEnd = null; | |
| 2065 | + delete swiper.onSlideToWrapperTransitionEnd; | |
| 2066 | + swiper.transitionEnd(runCallbacks, direction); | |
| 2067 | + }; | |
| 2068 | + } | |
| 2069 | + swiper.$wrapperEl[0].addEventListener('transitionend', swiper.onSlideToWrapperTransitionEnd); | |
| 2070 | + swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.onSlideToWrapperTransitionEnd); | |
| 2071 | + } | |
| 2072 | + } | |
| 2073 | + | |
| 2074 | + return true; | |
| 2075 | + } | |
| 2076 | + | |
| 2077 | + function slideToLoop (index, speed, runCallbacks, internal) { | |
| 2078 | + if ( index === void 0 ) index = 0; | |
| 2079 | + if ( speed === void 0 ) speed = this.params.speed; | |
| 2080 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 2081 | + | |
| 2082 | + var swiper = this; | |
| 2083 | + var newIndex = index; | |
| 2084 | + if (swiper.params.loop) { | |
| 2085 | + newIndex += swiper.loopedSlides; | |
| 2086 | + } | |
| 2087 | + | |
| 2088 | + return swiper.slideTo(newIndex, speed, runCallbacks, internal); | |
| 2089 | + } | |
| 2090 | + | |
| 2091 | + /* eslint no-unused-vars: "off" */ | |
| 2092 | + function slideNext (speed, runCallbacks, internal) { | |
| 2093 | + if ( speed === void 0 ) speed = this.params.speed; | |
| 2094 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 2095 | + | |
| 2096 | + var swiper = this; | |
| 2097 | + var params = swiper.params; | |
| 2098 | + var animating = swiper.animating; | |
| 2099 | + if (params.loop) { | |
| 2100 | + if (animating) { return false; } | |
| 2101 | + swiper.loopFix(); | |
| 2102 | + // eslint-disable-next-line | |
| 2103 | + swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; | |
| 2104 | + return swiper.slideTo(swiper.activeIndex + params.slidesPerGroup, speed, runCallbacks, internal); | |
| 2105 | + } | |
| 2106 | + return swiper.slideTo(swiper.activeIndex + params.slidesPerGroup, speed, runCallbacks, internal); | |
| 2107 | + } | |
| 2108 | + | |
| 2109 | + /* eslint no-unused-vars: "off" */ | |
| 2110 | + function slidePrev (speed, runCallbacks, internal) { | |
| 2111 | + if ( speed === void 0 ) speed = this.params.speed; | |
| 2112 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 2113 | + | |
| 2114 | + var swiper = this; | |
| 2115 | + var params = swiper.params; | |
| 2116 | + var animating = swiper.animating; | |
| 2117 | + var snapGrid = swiper.snapGrid; | |
| 2118 | + var slidesGrid = swiper.slidesGrid; | |
| 2119 | + var rtlTranslate = swiper.rtlTranslate; | |
| 2120 | + | |
| 2121 | + if (params.loop) { | |
| 2122 | + if (animating) { return false; } | |
| 2123 | + swiper.loopFix(); | |
| 2124 | + // eslint-disable-next-line | |
| 2125 | + swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; | |
| 2126 | + } | |
| 2127 | + var translate = rtlTranslate ? swiper.translate : -swiper.translate; | |
| 2128 | + function normalize(val) { | |
| 2129 | + if (val < 0) { return -Math.floor(Math.abs(val)); } | |
| 2130 | + return Math.floor(val); | |
| 2131 | + } | |
| 2132 | + var normalizedTranslate = normalize(translate); | |
| 2133 | + var normalizedSnapGrid = snapGrid.map(function (val) { return normalize(val); }); | |
| 2134 | + var normalizedSlidesGrid = slidesGrid.map(function (val) { return normalize(val); }); | |
| 2135 | + | |
| 2136 | + var currentSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate)]; | |
| 2137 | + var prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1]; | |
| 2138 | + var prevIndex; | |
| 2139 | + if (typeof prevSnap !== 'undefined') { | |
| 2140 | + prevIndex = slidesGrid.indexOf(prevSnap); | |
| 2141 | + if (prevIndex < 0) { prevIndex = swiper.activeIndex - 1; } | |
| 2142 | + } | |
| 2143 | + return swiper.slideTo(prevIndex, speed, runCallbacks, internal); | |
| 2144 | + } | |
| 2145 | + | |
| 2146 | + /* eslint no-unused-vars: "off" */ | |
| 2147 | + function slideReset (speed, runCallbacks, internal) { | |
| 2148 | + if ( speed === void 0 ) speed = this.params.speed; | |
| 2149 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 2150 | + | |
| 2151 | + var swiper = this; | |
| 2152 | + return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); | |
| 2153 | + } | |
| 2154 | + | |
| 2155 | + /* eslint no-unused-vars: "off" */ | |
| 2156 | + function slideToClosest (speed, runCallbacks, internal) { | |
| 2157 | + if ( speed === void 0 ) speed = this.params.speed; | |
| 2158 | + if ( runCallbacks === void 0 ) runCallbacks = true; | |
| 2159 | + | |
| 2160 | + var swiper = this; | |
| 2161 | + var index = swiper.activeIndex; | |
| 2162 | + var snapIndex = Math.floor(index / swiper.params.slidesPerGroup); | |
| 2163 | + | |
| 2164 | + if (snapIndex < swiper.snapGrid.length - 1) { | |
| 2165 | + var translate = swiper.rtlTranslate ? swiper.translate : -swiper.translate; | |
| 2166 | + | |
| 2167 | + var currentSnap = swiper.snapGrid[snapIndex]; | |
| 2168 | + var nextSnap = swiper.snapGrid[snapIndex + 1]; | |
| 2169 | + | |
| 2170 | + if ((translate - currentSnap) > (nextSnap - currentSnap) / 2) { | |
| 2171 | + index = swiper.params.slidesPerGroup; | |
| 2172 | + } | |
| 2173 | + } | |
| 2174 | + | |
| 2175 | + return swiper.slideTo(index, speed, runCallbacks, internal); | |
| 2176 | + } | |
| 2177 | + | |
| 2178 | + function slideToClickedSlide () { | |
| 2179 | + var swiper = this; | |
| 2180 | + var params = swiper.params; | |
| 2181 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2182 | + | |
| 2183 | + var slidesPerView = params.slidesPerView === 'auto' ? swiper.slidesPerViewDynamic() : params.slidesPerView; | |
| 2184 | + var slideToIndex = swiper.clickedIndex; | |
| 2185 | + var realIndex; | |
| 2186 | + if (params.loop) { | |
| 2187 | + if (swiper.animating) { return; } | |
| 2188 | + realIndex = parseInt($(swiper.clickedSlide).attr('data-swiper-slide-index'), 10); | |
| 2189 | + if (params.centeredSlides) { | |
| 2190 | + if ( | |
| 2191 | + (slideToIndex < swiper.loopedSlides - (slidesPerView / 2)) | |
| 2192 | + || (slideToIndex > (swiper.slides.length - swiper.loopedSlides) + (slidesPerView / 2)) | |
| 2193 | + ) { | |
| 2194 | + swiper.loopFix(); | |
| 2195 | + slideToIndex = $wrapperEl | |
| 2196 | + .children(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + (params.slideDuplicateClass) + ")")) | |
| 2197 | + .eq(0) | |
| 2198 | + .index(); | |
| 2199 | + | |
| 2200 | + Utils.nextTick(function () { | |
| 2201 | + swiper.slideTo(slideToIndex); | |
| 2202 | + }); | |
| 2203 | + } else { | |
| 2204 | + swiper.slideTo(slideToIndex); | |
| 2205 | + } | |
| 2206 | + } else if (slideToIndex > swiper.slides.length - slidesPerView) { | |
| 2207 | + swiper.loopFix(); | |
| 2208 | + slideToIndex = $wrapperEl | |
| 2209 | + .children(("." + (params.slideClass) + "[data-swiper-slide-index=\"" + realIndex + "\"]:not(." + (params.slideDuplicateClass) + ")")) | |
| 2210 | + .eq(0) | |
| 2211 | + .index(); | |
| 2212 | + | |
| 2213 | + Utils.nextTick(function () { | |
| 2214 | + swiper.slideTo(slideToIndex); | |
| 2215 | + }); | |
| 2216 | + } else { | |
| 2217 | + swiper.slideTo(slideToIndex); | |
| 2218 | + } | |
| 2219 | + } else { | |
| 2220 | + swiper.slideTo(slideToIndex); | |
| 2221 | + } | |
| 2222 | + } | |
| 2223 | + | |
| 2224 | + var slide = { | |
| 2225 | + slideTo: slideTo, | |
| 2226 | + slideToLoop: slideToLoop, | |
| 2227 | + slideNext: slideNext, | |
| 2228 | + slidePrev: slidePrev, | |
| 2229 | + slideReset: slideReset, | |
| 2230 | + slideToClosest: slideToClosest, | |
| 2231 | + slideToClickedSlide: slideToClickedSlide, | |
| 2232 | + }; | |
| 2233 | + | |
| 2234 | + function loopCreate () { | |
| 2235 | + var swiper = this; | |
| 2236 | + var params = swiper.params; | |
| 2237 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2238 | + // Remove duplicated slides | |
| 2239 | + $wrapperEl.children(("." + (params.slideClass) + "." + (params.slideDuplicateClass))).remove(); | |
| 2240 | + | |
| 2241 | + var slides = $wrapperEl.children(("." + (params.slideClass))); | |
| 2242 | + | |
| 2243 | + if (params.loopFillGroupWithBlank) { | |
| 2244 | + var blankSlidesNum = params.slidesPerGroup - (slides.length % params.slidesPerGroup); | |
| 2245 | + if (blankSlidesNum !== params.slidesPerGroup) { | |
| 2246 | + for (var i = 0; i < blankSlidesNum; i += 1) { | |
| 2247 | + var blankNode = $(doc.createElement('div')).addClass(((params.slideClass) + " " + (params.slideBlankClass))); | |
| 2248 | + $wrapperEl.append(blankNode); | |
| 2249 | + } | |
| 2250 | + slides = $wrapperEl.children(("." + (params.slideClass))); | |
| 2251 | + } | |
| 2252 | + } | |
| 2253 | + | |
| 2254 | + if (params.slidesPerView === 'auto' && !params.loopedSlides) { params.loopedSlides = slides.length; } | |
| 2255 | + | |
| 2256 | + swiper.loopedSlides = parseInt(params.loopedSlides || params.slidesPerView, 10); | |
| 2257 | + swiper.loopedSlides += params.loopAdditionalSlides; | |
| 2258 | + if (swiper.loopedSlides > slides.length) { | |
| 2259 | + swiper.loopedSlides = slides.length; | |
| 2260 | + } | |
| 2261 | + | |
| 2262 | + var prependSlides = []; | |
| 2263 | + var appendSlides = []; | |
| 2264 | + slides.each(function (index, el) { | |
| 2265 | + var slide = $(el); | |
| 2266 | + if (index < swiper.loopedSlides) { appendSlides.push(el); } | |
| 2267 | + if (index < slides.length && index >= slides.length - swiper.loopedSlides) { prependSlides.push(el); } | |
| 2268 | + slide.attr('data-swiper-slide-index', index); | |
| 2269 | + }); | |
| 2270 | + for (var i$1 = 0; i$1 < appendSlides.length; i$1 += 1) { | |
| 2271 | + $wrapperEl.append($(appendSlides[i$1].cloneNode(true)).addClass(params.slideDuplicateClass)); | |
| 2272 | + } | |
| 2273 | + for (var i$2 = prependSlides.length - 1; i$2 >= 0; i$2 -= 1) { | |
| 2274 | + $wrapperEl.prepend($(prependSlides[i$2].cloneNode(true)).addClass(params.slideDuplicateClass)); | |
| 2275 | + } | |
| 2276 | + } | |
| 2277 | + | |
| 2278 | + function loopFix () { | |
| 2279 | + var swiper = this; | |
| 2280 | + var params = swiper.params; | |
| 2281 | + var activeIndex = swiper.activeIndex; | |
| 2282 | + var slides = swiper.slides; | |
| 2283 | + var loopedSlides = swiper.loopedSlides; | |
| 2284 | + var allowSlidePrev = swiper.allowSlidePrev; | |
| 2285 | + var allowSlideNext = swiper.allowSlideNext; | |
| 2286 | + var snapGrid = swiper.snapGrid; | |
| 2287 | + var rtl = swiper.rtlTranslate; | |
| 2288 | + var newIndex; | |
| 2289 | + swiper.allowSlidePrev = true; | |
| 2290 | + swiper.allowSlideNext = true; | |
| 2291 | + | |
| 2292 | + var snapTranslate = -snapGrid[activeIndex]; | |
| 2293 | + var diff = snapTranslate - swiper.getTranslate(); | |
| 2294 | + | |
| 2295 | + | |
| 2296 | + // Fix For Negative Oversliding | |
| 2297 | + if (activeIndex < loopedSlides) { | |
| 2298 | + newIndex = (slides.length - (loopedSlides * 3)) + activeIndex; | |
| 2299 | + newIndex += loopedSlides; | |
| 2300 | + var slideChanged = swiper.slideTo(newIndex, 0, false, true); | |
| 2301 | + if (slideChanged && diff !== 0) { | |
| 2302 | + swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); | |
| 2303 | + } | |
| 2304 | + } else if ((params.slidesPerView === 'auto' && activeIndex >= loopedSlides * 2) || (activeIndex >= slides.length - loopedSlides)) { | |
| 2305 | + // Fix For Positive Oversliding | |
| 2306 | + newIndex = -slides.length + activeIndex + loopedSlides; | |
| 2307 | + newIndex += loopedSlides; | |
| 2308 | + var slideChanged$1 = swiper.slideTo(newIndex, 0, false, true); | |
| 2309 | + if (slideChanged$1 && diff !== 0) { | |
| 2310 | + swiper.setTranslate((rtl ? -swiper.translate : swiper.translate) - diff); | |
| 2311 | + } | |
| 2312 | + } | |
| 2313 | + swiper.allowSlidePrev = allowSlidePrev; | |
| 2314 | + swiper.allowSlideNext = allowSlideNext; | |
| 2315 | + } | |
| 2316 | + | |
| 2317 | + function loopDestroy () { | |
| 2318 | + var swiper = this; | |
| 2319 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2320 | + var params = swiper.params; | |
| 2321 | + var slides = swiper.slides; | |
| 2322 | + $wrapperEl.children(("." + (params.slideClass) + "." + (params.slideDuplicateClass) + ",." + (params.slideClass) + "." + (params.slideBlankClass))).remove(); | |
| 2323 | + slides.removeAttr('data-swiper-slide-index'); | |
| 2324 | + } | |
| 2325 | + | |
| 2326 | + var loop = { | |
| 2327 | + loopCreate: loopCreate, | |
| 2328 | + loopFix: loopFix, | |
| 2329 | + loopDestroy: loopDestroy, | |
| 2330 | + }; | |
| 2331 | + | |
| 2332 | + function setGrabCursor (moving) { | |
| 2333 | + var swiper = this; | |
| 2334 | + if (Support.touch || !swiper.params.simulateTouch || (swiper.params.watchOverflow && swiper.isLocked)) { return; } | |
| 2335 | + var el = swiper.el; | |
| 2336 | + el.style.cursor = 'move'; | |
| 2337 | + el.style.cursor = moving ? '-webkit-grabbing' : '-webkit-grab'; | |
| 2338 | + el.style.cursor = moving ? '-moz-grabbin' : '-moz-grab'; | |
| 2339 | + el.style.cursor = moving ? 'grabbing' : 'grab'; | |
| 2340 | + } | |
| 2341 | + | |
| 2342 | + function unsetGrabCursor () { | |
| 2343 | + var swiper = this; | |
| 2344 | + if (Support.touch || (swiper.params.watchOverflow && swiper.isLocked)) { return; } | |
| 2345 | + swiper.el.style.cursor = ''; | |
| 2346 | + } | |
| 2347 | + | |
| 2348 | + var grabCursor = { | |
| 2349 | + setGrabCursor: setGrabCursor, | |
| 2350 | + unsetGrabCursor: unsetGrabCursor, | |
| 2351 | + }; | |
| 2352 | + | |
| 2353 | + function appendSlide (slides) { | |
| 2354 | + var swiper = this; | |
| 2355 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2356 | + var params = swiper.params; | |
| 2357 | + if (params.loop) { | |
| 2358 | + swiper.loopDestroy(); | |
| 2359 | + } | |
| 2360 | + if (typeof slides === 'object' && 'length' in slides) { | |
| 2361 | + for (var i = 0; i < slides.length; i += 1) { | |
| 2362 | + if (slides[i]) { $wrapperEl.append(slides[i]); } | |
| 2363 | + } | |
| 2364 | + } else { | |
| 2365 | + $wrapperEl.append(slides); | |
| 2366 | + } | |
| 2367 | + if (params.loop) { | |
| 2368 | + swiper.loopCreate(); | |
| 2369 | + } | |
| 2370 | + if (!(params.observer && Support.observer)) { | |
| 2371 | + swiper.update(); | |
| 2372 | + } | |
| 2373 | + } | |
| 2374 | + | |
| 2375 | + function prependSlide (slides) { | |
| 2376 | + var swiper = this; | |
| 2377 | + var params = swiper.params; | |
| 2378 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2379 | + var activeIndex = swiper.activeIndex; | |
| 2380 | + | |
| 2381 | + if (params.loop) { | |
| 2382 | + swiper.loopDestroy(); | |
| 2383 | + } | |
| 2384 | + var newActiveIndex = activeIndex + 1; | |
| 2385 | + if (typeof slides === 'object' && 'length' in slides) { | |
| 2386 | + for (var i = 0; i < slides.length; i += 1) { | |
| 2387 | + if (slides[i]) { $wrapperEl.prepend(slides[i]); } | |
| 2388 | + } | |
| 2389 | + newActiveIndex = activeIndex + slides.length; | |
| 2390 | + } else { | |
| 2391 | + $wrapperEl.prepend(slides); | |
| 2392 | + } | |
| 2393 | + if (params.loop) { | |
| 2394 | + swiper.loopCreate(); | |
| 2395 | + } | |
| 2396 | + if (!(params.observer && Support.observer)) { | |
| 2397 | + swiper.update(); | |
| 2398 | + } | |
| 2399 | + swiper.slideTo(newActiveIndex, 0, false); | |
| 2400 | + } | |
| 2401 | + | |
| 2402 | + function addSlide (index, slides) { | |
| 2403 | + var swiper = this; | |
| 2404 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2405 | + var params = swiper.params; | |
| 2406 | + var activeIndex = swiper.activeIndex; | |
| 2407 | + var activeIndexBuffer = activeIndex; | |
| 2408 | + if (params.loop) { | |
| 2409 | + activeIndexBuffer -= swiper.loopedSlides; | |
| 2410 | + swiper.loopDestroy(); | |
| 2411 | + swiper.slides = $wrapperEl.children(("." + (params.slideClass))); | |
| 2412 | + } | |
| 2413 | + var baseLength = swiper.slides.length; | |
| 2414 | + if (index <= 0) { | |
| 2415 | + swiper.prependSlide(slides); | |
| 2416 | + return; | |
| 2417 | + } | |
| 2418 | + if (index >= baseLength) { | |
| 2419 | + swiper.appendSlide(slides); | |
| 2420 | + return; | |
| 2421 | + } | |
| 2422 | + var newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + 1 : activeIndexBuffer; | |
| 2423 | + | |
| 2424 | + var slidesBuffer = []; | |
| 2425 | + for (var i = baseLength - 1; i >= index; i -= 1) { | |
| 2426 | + var currentSlide = swiper.slides.eq(i); | |
| 2427 | + currentSlide.remove(); | |
| 2428 | + slidesBuffer.unshift(currentSlide); | |
| 2429 | + } | |
| 2430 | + | |
| 2431 | + if (typeof slides === 'object' && 'length' in slides) { | |
| 2432 | + for (var i$1 = 0; i$1 < slides.length; i$1 += 1) { | |
| 2433 | + if (slides[i$1]) { $wrapperEl.append(slides[i$1]); } | |
| 2434 | + } | |
| 2435 | + newActiveIndex = activeIndexBuffer > index ? activeIndexBuffer + slides.length : activeIndexBuffer; | |
| 2436 | + } else { | |
| 2437 | + $wrapperEl.append(slides); | |
| 2438 | + } | |
| 2439 | + | |
| 2440 | + for (var i$2 = 0; i$2 < slidesBuffer.length; i$2 += 1) { | |
| 2441 | + $wrapperEl.append(slidesBuffer[i$2]); | |
| 2442 | + } | |
| 2443 | + | |
| 2444 | + if (params.loop) { | |
| 2445 | + swiper.loopCreate(); | |
| 2446 | + } | |
| 2447 | + if (!(params.observer && Support.observer)) { | |
| 2448 | + swiper.update(); | |
| 2449 | + } | |
| 2450 | + if (params.loop) { | |
| 2451 | + swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); | |
| 2452 | + } else { | |
| 2453 | + swiper.slideTo(newActiveIndex, 0, false); | |
| 2454 | + } | |
| 2455 | + } | |
| 2456 | + | |
| 2457 | + function removeSlide (slidesIndexes) { | |
| 2458 | + var swiper = this; | |
| 2459 | + var params = swiper.params; | |
| 2460 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2461 | + var activeIndex = swiper.activeIndex; | |
| 2462 | + | |
| 2463 | + var activeIndexBuffer = activeIndex; | |
| 2464 | + if (params.loop) { | |
| 2465 | + activeIndexBuffer -= swiper.loopedSlides; | |
| 2466 | + swiper.loopDestroy(); | |
| 2467 | + swiper.slides = $wrapperEl.children(("." + (params.slideClass))); | |
| 2468 | + } | |
| 2469 | + var newActiveIndex = activeIndexBuffer; | |
| 2470 | + var indexToRemove; | |
| 2471 | + | |
| 2472 | + if (typeof slidesIndexes === 'object' && 'length' in slidesIndexes) { | |
| 2473 | + for (var i = 0; i < slidesIndexes.length; i += 1) { | |
| 2474 | + indexToRemove = slidesIndexes[i]; | |
| 2475 | + if (swiper.slides[indexToRemove]) { swiper.slides.eq(indexToRemove).remove(); } | |
| 2476 | + if (indexToRemove < newActiveIndex) { newActiveIndex -= 1; } | |
| 2477 | + } | |
| 2478 | + newActiveIndex = Math.max(newActiveIndex, 0); | |
| 2479 | + } else { | |
| 2480 | + indexToRemove = slidesIndexes; | |
| 2481 | + if (swiper.slides[indexToRemove]) { swiper.slides.eq(indexToRemove).remove(); } | |
| 2482 | + if (indexToRemove < newActiveIndex) { newActiveIndex -= 1; } | |
| 2483 | + newActiveIndex = Math.max(newActiveIndex, 0); | |
| 2484 | + } | |
| 2485 | + | |
| 2486 | + if (params.loop) { | |
| 2487 | + swiper.loopCreate(); | |
| 2488 | + } | |
| 2489 | + | |
| 2490 | + if (!(params.observer && Support.observer)) { | |
| 2491 | + swiper.update(); | |
| 2492 | + } | |
| 2493 | + if (params.loop) { | |
| 2494 | + swiper.slideTo(newActiveIndex + swiper.loopedSlides, 0, false); | |
| 2495 | + } else { | |
| 2496 | + swiper.slideTo(newActiveIndex, 0, false); | |
| 2497 | + } | |
| 2498 | + } | |
| 2499 | + | |
| 2500 | + function removeAllSlides () { | |
| 2501 | + var swiper = this; | |
| 2502 | + | |
| 2503 | + var slidesIndexes = []; | |
| 2504 | + for (var i = 0; i < swiper.slides.length; i += 1) { | |
| 2505 | + slidesIndexes.push(i); | |
| 2506 | + } | |
| 2507 | + swiper.removeSlide(slidesIndexes); | |
| 2508 | + } | |
| 2509 | + | |
| 2510 | + var manipulation = { | |
| 2511 | + appendSlide: appendSlide, | |
| 2512 | + prependSlide: prependSlide, | |
| 2513 | + addSlide: addSlide, | |
| 2514 | + removeSlide: removeSlide, | |
| 2515 | + removeAllSlides: removeAllSlides, | |
| 2516 | + }; | |
| 2517 | + | |
| 2518 | + var Device = (function Device() { | |
| 2519 | + var ua = win.navigator.userAgent; | |
| 2520 | + | |
| 2521 | + var device = { | |
| 2522 | + ios: false, | |
| 2523 | + android: false, | |
| 2524 | + androidChrome: false, | |
| 2525 | + desktop: false, | |
| 2526 | + windows: false, | |
| 2527 | + iphone: false, | |
| 2528 | + ipod: false, | |
| 2529 | + ipad: false, | |
| 2530 | + cordova: win.cordova || win.phonegap, | |
| 2531 | + phonegap: win.cordova || win.phonegap, | |
| 2532 | + }; | |
| 2533 | + | |
| 2534 | + var windows = ua.match(/(Windows Phone);?[\s\/]+([\d.]+)?/); // eslint-disable-line | |
| 2535 | + var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/); // eslint-disable-line | |
| 2536 | + var ipad = ua.match(/(iPad).*OS\s([\d_]+)/); | |
| 2537 | + var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/); | |
| 2538 | + var iphone = !ipad && ua.match(/(iPhone\sOS|iOS)\s([\d_]+)/); | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + // Windows | |
| 2542 | + if (windows) { | |
| 2543 | + device.os = 'windows'; | |
| 2544 | + device.osVersion = windows[2]; | |
| 2545 | + device.windows = true; | |
| 2546 | + } | |
| 2547 | + // Android | |
| 2548 | + if (android && !windows) { | |
| 2549 | + device.os = 'android'; | |
| 2550 | + device.osVersion = android[2]; | |
| 2551 | + device.android = true; | |
| 2552 | + device.androidChrome = ua.toLowerCase().indexOf('chrome') >= 0; | |
| 2553 | + } | |
| 2554 | + if (ipad || iphone || ipod) { | |
| 2555 | + device.os = 'ios'; | |
| 2556 | + device.ios = true; | |
| 2557 | + } | |
| 2558 | + // iOS | |
| 2559 | + if (iphone && !ipod) { | |
| 2560 | + device.osVersion = iphone[2].replace(/_/g, '.'); | |
| 2561 | + device.iphone = true; | |
| 2562 | + } | |
| 2563 | + if (ipad) { | |
| 2564 | + device.osVersion = ipad[2].replace(/_/g, '.'); | |
| 2565 | + device.ipad = true; | |
| 2566 | + } | |
| 2567 | + if (ipod) { | |
| 2568 | + device.osVersion = ipod[3] ? ipod[3].replace(/_/g, '.') : null; | |
| 2569 | + device.iphone = true; | |
| 2570 | + } | |
| 2571 | + // iOS 8+ changed UA | |
| 2572 | + if (device.ios && device.osVersion && ua.indexOf('Version/') >= 0) { | |
| 2573 | + if (device.osVersion.split('.')[0] === '10') { | |
| 2574 | + device.osVersion = ua.toLowerCase().split('version/')[1].split(' ')[0]; | |
| 2575 | + } | |
| 2576 | + } | |
| 2577 | + | |
| 2578 | + // Desktop | |
| 2579 | + device.desktop = !(device.os || device.android || device.webView); | |
| 2580 | + | |
| 2581 | + // Webview | |
| 2582 | + device.webView = (iphone || ipad || ipod) && ua.match(/.*AppleWebKit(?!.*Safari)/i); | |
| 2583 | + | |
| 2584 | + // Minimal UI | |
| 2585 | + if (device.os && device.os === 'ios') { | |
| 2586 | + var osVersionArr = device.osVersion.split('.'); | |
| 2587 | + var metaViewport = doc.querySelector('meta[name="viewport"]'); | |
| 2588 | + device.minimalUi = !device.webView | |
| 2589 | + && (ipod || iphone) | |
| 2590 | + && (osVersionArr[0] * 1 === 7 ? osVersionArr[1] * 1 >= 1 : osVersionArr[0] * 1 > 7) | |
| 2591 | + && metaViewport && metaViewport.getAttribute('content').indexOf('minimal-ui') >= 0; | |
| 2592 | + } | |
| 2593 | + | |
| 2594 | + // Pixel Ratio | |
| 2595 | + device.pixelRatio = win.devicePixelRatio || 1; | |
| 2596 | + | |
| 2597 | + // Export object | |
| 2598 | + return device; | |
| 2599 | + }()); | |
| 2600 | + | |
| 2601 | + function onTouchStart (event) { | |
| 2602 | + var swiper = this; | |
| 2603 | + var data = swiper.touchEventsData; | |
| 2604 | + var params = swiper.params; | |
| 2605 | + var touches = swiper.touches; | |
| 2606 | + if (swiper.animating && params.preventInteractionOnTransition) { | |
| 2607 | + return; | |
| 2608 | + } | |
| 2609 | + var e = event; | |
| 2610 | + if (e.originalEvent) { e = e.originalEvent; } | |
| 2611 | + data.isTouchEvent = e.type === 'touchstart'; | |
| 2612 | + if (!data.isTouchEvent && 'which' in e && e.which === 3) { return; } | |
| 2613 | + if (!data.isTouchEvent && 'button' in e && e.button > 0) { return; } | |
| 2614 | + if (data.isTouched && data.isMoved) { return; } | |
| 2615 | + if (params.noSwiping && $(e.target).closest(params.noSwipingSelector ? params.noSwipingSelector : ("." + (params.noSwipingClass)))[0]) { | |
| 2616 | + swiper.allowClick = true; | |
| 2617 | + return; | |
| 2618 | + } | |
| 2619 | + if (params.swipeHandler) { | |
| 2620 | + if (!$(e).closest(params.swipeHandler)[0]) { return; } | |
| 2621 | + } | |
| 2622 | + | |
| 2623 | + touches.currentX = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; | |
| 2624 | + touches.currentY = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; | |
| 2625 | + var startX = touches.currentX; | |
| 2626 | + var startY = touches.currentY; | |
| 2627 | + | |
| 2628 | + // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore | |
| 2629 | + | |
| 2630 | + var edgeSwipeDetection = params.edgeSwipeDetection || params.iOSEdgeSwipeDetection; | |
| 2631 | + var edgeSwipeThreshold = params.edgeSwipeThreshold || params.iOSEdgeSwipeThreshold; | |
| 2632 | + if ( | |
| 2633 | + edgeSwipeDetection | |
| 2634 | + && ((startX <= edgeSwipeThreshold) | |
| 2635 | + || (startX >= win.screen.width - edgeSwipeThreshold)) | |
| 2636 | + ) { | |
| 2637 | + return; | |
| 2638 | + } | |
| 2639 | + | |
| 2640 | + Utils.extend(data, { | |
| 2641 | + isTouched: true, | |
| 2642 | + isMoved: false, | |
| 2643 | + allowTouchCallbacks: true, | |
| 2644 | + isScrolling: undefined, | |
| 2645 | + startMoving: undefined, | |
| 2646 | + }); | |
| 2647 | + | |
| 2648 | + touches.startX = startX; | |
| 2649 | + touches.startY = startY; | |
| 2650 | + data.touchStartTime = Utils.now(); | |
| 2651 | + swiper.allowClick = true; | |
| 2652 | + swiper.updateSize(); | |
| 2653 | + swiper.swipeDirection = undefined; | |
| 2654 | + if (params.threshold > 0) { data.allowThresholdMove = false; } | |
| 2655 | + if (e.type !== 'touchstart') { | |
| 2656 | + var preventDefault = true; | |
| 2657 | + if ($(e.target).is(data.formElements)) { preventDefault = false; } | |
| 2658 | + if ( | |
| 2659 | + doc.activeElement | |
| 2660 | + && $(doc.activeElement).is(data.formElements) | |
| 2661 | + && doc.activeElement !== e.target | |
| 2662 | + ) { | |
| 2663 | + doc.activeElement.blur(); | |
| 2664 | + } | |
| 2665 | + | |
| 2666 | + var shouldPreventDefault = preventDefault && swiper.allowTouchMove && params.touchStartPreventDefault; | |
| 2667 | + if (params.touchStartForcePreventDefault || shouldPreventDefault) { | |
| 2668 | + e.preventDefault(); | |
| 2669 | + } | |
| 2670 | + } | |
| 2671 | + swiper.emit('touchStart', e); | |
| 2672 | + } | |
| 2673 | + | |
| 2674 | + function onTouchMove (event) { | |
| 2675 | + var swiper = this; | |
| 2676 | + var data = swiper.touchEventsData; | |
| 2677 | + var params = swiper.params; | |
| 2678 | + var touches = swiper.touches; | |
| 2679 | + var rtl = swiper.rtlTranslate; | |
| 2680 | + var e = event; | |
| 2681 | + if (e.originalEvent) { e = e.originalEvent; } | |
| 2682 | + if (!data.isTouched) { | |
| 2683 | + if (data.startMoving && data.isScrolling) { | |
| 2684 | + swiper.emit('touchMoveOpposite', e); | |
| 2685 | + } | |
| 2686 | + return; | |
| 2687 | + } | |
| 2688 | + if (data.isTouchEvent && e.type === 'mousemove') { return; } | |
| 2689 | + var pageX = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; | |
| 2690 | + var pageY = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; | |
| 2691 | + if (e.preventedByNestedSwiper) { | |
| 2692 | + touches.startX = pageX; | |
| 2693 | + touches.startY = pageY; | |
| 2694 | + return; | |
| 2695 | + } | |
| 2696 | + if (!swiper.allowTouchMove) { | |
| 2697 | + // isMoved = true; | |
| 2698 | + swiper.allowClick = false; | |
| 2699 | + if (data.isTouched) { | |
| 2700 | + Utils.extend(touches, { | |
| 2701 | + startX: pageX, | |
| 2702 | + startY: pageY, | |
| 2703 | + currentX: pageX, | |
| 2704 | + currentY: pageY, | |
| 2705 | + }); | |
| 2706 | + data.touchStartTime = Utils.now(); | |
| 2707 | + } | |
| 2708 | + return; | |
| 2709 | + } | |
| 2710 | + if (data.isTouchEvent && params.touchReleaseOnEdges && !params.loop) { | |
| 2711 | + if (swiper.isVertical()) { | |
| 2712 | + // Vertical | |
| 2713 | + if ( | |
| 2714 | + (pageY < touches.startY && swiper.translate <= swiper.maxTranslate()) | |
| 2715 | + || (pageY > touches.startY && swiper.translate >= swiper.minTranslate()) | |
| 2716 | + ) { | |
| 2717 | + data.isTouched = false; | |
| 2718 | + data.isMoved = false; | |
| 2719 | + return; | |
| 2720 | + } | |
| 2721 | + } else if ( | |
| 2722 | + (pageX < touches.startX && swiper.translate <= swiper.maxTranslate()) | |
| 2723 | + || (pageX > touches.startX && swiper.translate >= swiper.minTranslate()) | |
| 2724 | + ) { | |
| 2725 | + return; | |
| 2726 | + } | |
| 2727 | + } | |
| 2728 | + if (data.isTouchEvent && doc.activeElement) { | |
| 2729 | + if (e.target === doc.activeElement && $(e.target).is(data.formElements)) { | |
| 2730 | + data.isMoved = true; | |
| 2731 | + swiper.allowClick = false; | |
| 2732 | + return; | |
| 2733 | + } | |
| 2734 | + } | |
| 2735 | + if (data.allowTouchCallbacks) { | |
| 2736 | + swiper.emit('touchMove', e); | |
| 2737 | + } | |
| 2738 | + if (e.targetTouches && e.targetTouches.length > 1) { return; } | |
| 2739 | + | |
| 2740 | + touches.currentX = pageX; | |
| 2741 | + touches.currentY = pageY; | |
| 2742 | + | |
| 2743 | + var diffX = touches.currentX - touches.startX; | |
| 2744 | + var diffY = touches.currentY - touches.startY; | |
| 2745 | + if (swiper.params.threshold && Math.sqrt((Math.pow( diffX, 2 )) + (Math.pow( diffY, 2 ))) < swiper.params.threshold) { return; } | |
| 2746 | + | |
| 2747 | + if (typeof data.isScrolling === 'undefined') { | |
| 2748 | + var touchAngle; | |
| 2749 | + if ((swiper.isHorizontal() && touches.currentY === touches.startY) || (swiper.isVertical() && touches.currentX === touches.startX)) { | |
| 2750 | + data.isScrolling = false; | |
| 2751 | + } else { | |
| 2752 | + // eslint-disable-next-line | |
| 2753 | + if ((diffX * diffX) + (diffY * diffY) >= 25) { | |
| 2754 | + touchAngle = (Math.atan2(Math.abs(diffY), Math.abs(diffX)) * 180) / Math.PI; | |
| 2755 | + data.isScrolling = swiper.isHorizontal() ? touchAngle > params.touchAngle : (90 - touchAngle > params.touchAngle); | |
| 2756 | + } | |
| 2757 | + } | |
| 2758 | + } | |
| 2759 | + if (data.isScrolling) { | |
| 2760 | + swiper.emit('touchMoveOpposite', e); | |
| 2761 | + } | |
| 2762 | + if (typeof data.startMoving === 'undefined') { | |
| 2763 | + if (touches.currentX !== touches.startX || touches.currentY !== touches.startY) { | |
| 2764 | + data.startMoving = true; | |
| 2765 | + } | |
| 2766 | + } | |
| 2767 | + if (data.isScrolling) { | |
| 2768 | + data.isTouched = false; | |
| 2769 | + return; | |
| 2770 | + } | |
| 2771 | + if (!data.startMoving) { | |
| 2772 | + return; | |
| 2773 | + } | |
| 2774 | + swiper.allowClick = false; | |
| 2775 | + e.preventDefault(); | |
| 2776 | + if (params.touchMoveStopPropagation && !params.nested) { | |
| 2777 | + e.stopPropagation(); | |
| 2778 | + } | |
| 2779 | + | |
| 2780 | + if (!data.isMoved) { | |
| 2781 | + if (params.loop) { | |
| 2782 | + swiper.loopFix(); | |
| 2783 | + } | |
| 2784 | + data.startTranslate = swiper.getTranslate(); | |
| 2785 | + swiper.setTransition(0); | |
| 2786 | + if (swiper.animating) { | |
| 2787 | + swiper.$wrapperEl.trigger('webkitTransitionEnd transitionend'); | |
| 2788 | + } | |
| 2789 | + data.allowMomentumBounce = false; | |
| 2790 | + // Grab Cursor | |
| 2791 | + if (params.grabCursor && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { | |
| 2792 | + swiper.setGrabCursor(true); | |
| 2793 | + } | |
| 2794 | + swiper.emit('sliderFirstMove', e); | |
| 2795 | + } | |
| 2796 | + swiper.emit('sliderMove', e); | |
| 2797 | + data.isMoved = true; | |
| 2798 | + | |
| 2799 | + var diff = swiper.isHorizontal() ? diffX : diffY; | |
| 2800 | + touches.diff = diff; | |
| 2801 | + | |
| 2802 | + diff *= params.touchRatio; | |
| 2803 | + if (rtl) { diff = -diff; } | |
| 2804 | + | |
| 2805 | + swiper.swipeDirection = diff > 0 ? 'prev' : 'next'; | |
| 2806 | + data.currentTranslate = diff + data.startTranslate; | |
| 2807 | + | |
| 2808 | + var disableParentSwiper = true; | |
| 2809 | + var resistanceRatio = params.resistanceRatio; | |
| 2810 | + if (params.touchReleaseOnEdges) { | |
| 2811 | + resistanceRatio = 0; | |
| 2812 | + } | |
| 2813 | + if ((diff > 0 && data.currentTranslate > swiper.minTranslate())) { | |
| 2814 | + disableParentSwiper = false; | |
| 2815 | + if (params.resistance) { data.currentTranslate = (swiper.minTranslate() - 1) + (Math.pow( (-swiper.minTranslate() + data.startTranslate + diff), resistanceRatio )); } | |
| 2816 | + } else if (diff < 0 && data.currentTranslate < swiper.maxTranslate()) { | |
| 2817 | + disableParentSwiper = false; | |
| 2818 | + if (params.resistance) { data.currentTranslate = (swiper.maxTranslate() + 1) - (Math.pow( (swiper.maxTranslate() - data.startTranslate - diff), resistanceRatio )); } | |
| 2819 | + } | |
| 2820 | + | |
| 2821 | + if (disableParentSwiper) { | |
| 2822 | + e.preventedByNestedSwiper = true; | |
| 2823 | + } | |
| 2824 | + | |
| 2825 | + // Directions locks | |
| 2826 | + if (!swiper.allowSlideNext && swiper.swipeDirection === 'next' && data.currentTranslate < data.startTranslate) { | |
| 2827 | + data.currentTranslate = data.startTranslate; | |
| 2828 | + } | |
| 2829 | + if (!swiper.allowSlidePrev && swiper.swipeDirection === 'prev' && data.currentTranslate > data.startTranslate) { | |
| 2830 | + data.currentTranslate = data.startTranslate; | |
| 2831 | + } | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + // Threshold | |
| 2835 | + if (params.threshold > 0) { | |
| 2836 | + if (Math.abs(diff) > params.threshold || data.allowThresholdMove) { | |
| 2837 | + if (!data.allowThresholdMove) { | |
| 2838 | + data.allowThresholdMove = true; | |
| 2839 | + touches.startX = touches.currentX; | |
| 2840 | + touches.startY = touches.currentY; | |
| 2841 | + data.currentTranslate = data.startTranslate; | |
| 2842 | + touches.diff = swiper.isHorizontal() ? touches.currentX - touches.startX : touches.currentY - touches.startY; | |
| 2843 | + return; | |
| 2844 | + } | |
| 2845 | + } else { | |
| 2846 | + data.currentTranslate = data.startTranslate; | |
| 2847 | + return; | |
| 2848 | + } | |
| 2849 | + } | |
| 2850 | + | |
| 2851 | + if (!params.followFinger) { return; } | |
| 2852 | + | |
| 2853 | + // Update active index in free mode | |
| 2854 | + if (params.freeMode || params.watchSlidesProgress || params.watchSlidesVisibility) { | |
| 2855 | + swiper.updateActiveIndex(); | |
| 2856 | + swiper.updateSlidesClasses(); | |
| 2857 | + } | |
| 2858 | + if (params.freeMode) { | |
| 2859 | + // Velocity | |
| 2860 | + if (data.velocities.length === 0) { | |
| 2861 | + data.velocities.push({ | |
| 2862 | + position: touches[swiper.isHorizontal() ? 'startX' : 'startY'], | |
| 2863 | + time: data.touchStartTime, | |
| 2864 | + }); | |
| 2865 | + } | |
| 2866 | + data.velocities.push({ | |
| 2867 | + position: touches[swiper.isHorizontal() ? 'currentX' : 'currentY'], | |
| 2868 | + time: Utils.now(), | |
| 2869 | + }); | |
| 2870 | + } | |
| 2871 | + // Update progress | |
| 2872 | + swiper.updateProgress(data.currentTranslate); | |
| 2873 | + // Update translate | |
| 2874 | + swiper.setTranslate(data.currentTranslate); | |
| 2875 | + } | |
| 2876 | + | |
| 2877 | + function onTouchEnd (event) { | |
| 2878 | + var swiper = this; | |
| 2879 | + var data = swiper.touchEventsData; | |
| 2880 | + | |
| 2881 | + var params = swiper.params; | |
| 2882 | + var touches = swiper.touches; | |
| 2883 | + var rtl = swiper.rtlTranslate; | |
| 2884 | + var $wrapperEl = swiper.$wrapperEl; | |
| 2885 | + var slidesGrid = swiper.slidesGrid; | |
| 2886 | + var snapGrid = swiper.snapGrid; | |
| 2887 | + var e = event; | |
| 2888 | + if (e.originalEvent) { e = e.originalEvent; } | |
| 2889 | + if (data.allowTouchCallbacks) { | |
| 2890 | + swiper.emit('touchEnd', e); | |
| 2891 | + } | |
| 2892 | + data.allowTouchCallbacks = false; | |
| 2893 | + if (!data.isTouched) { | |
| 2894 | + if (data.isMoved && params.grabCursor) { | |
| 2895 | + swiper.setGrabCursor(false); | |
| 2896 | + } | |
| 2897 | + data.isMoved = false; | |
| 2898 | + data.startMoving = false; | |
| 2899 | + return; | |
| 2900 | + } | |
| 2901 | + // Return Grab Cursor | |
| 2902 | + if (params.grabCursor && data.isMoved && data.isTouched && (swiper.allowSlideNext === true || swiper.allowSlidePrev === true)) { | |
| 2903 | + swiper.setGrabCursor(false); | |
| 2904 | + } | |
| 2905 | + | |
| 2906 | + // Time diff | |
| 2907 | + var touchEndTime = Utils.now(); | |
| 2908 | + var timeDiff = touchEndTime - data.touchStartTime; | |
| 2909 | + | |
| 2910 | + // Tap, doubleTap, Click | |
| 2911 | + if (swiper.allowClick) { | |
| 2912 | + swiper.updateClickedSlide(e); | |
| 2913 | + swiper.emit('tap', e); | |
| 2914 | + if (timeDiff < 300 && (touchEndTime - data.lastClickTime) > 300) { | |
| 2915 | + if (data.clickTimeout) { clearTimeout(data.clickTimeout); } | |
| 2916 | + data.clickTimeout = Utils.nextTick(function () { | |
| 2917 | + if (!swiper || swiper.destroyed) { return; } | |
| 2918 | + swiper.emit('click', e); | |
| 2919 | + }, 300); | |
| 2920 | + } | |
| 2921 | + if (timeDiff < 300 && (touchEndTime - data.lastClickTime) < 300) { | |
| 2922 | + if (data.clickTimeout) { clearTimeout(data.clickTimeout); } | |
| 2923 | + swiper.emit('doubleTap', e); | |
| 2924 | + } | |
| 2925 | + } | |
| 2926 | + | |
| 2927 | + data.lastClickTime = Utils.now(); | |
| 2928 | + Utils.nextTick(function () { | |
| 2929 | + if (!swiper.destroyed) { swiper.allowClick = true; } | |
| 2930 | + }); | |
| 2931 | + | |
| 2932 | + if (!data.isTouched || !data.isMoved || !swiper.swipeDirection || touches.diff === 0 || data.currentTranslate === data.startTranslate) { | |
| 2933 | + data.isTouched = false; | |
| 2934 | + data.isMoved = false; | |
| 2935 | + data.startMoving = false; | |
| 2936 | + return; | |
| 2937 | + } | |
| 2938 | + data.isTouched = false; | |
| 2939 | + data.isMoved = false; | |
| 2940 | + data.startMoving = false; | |
| 2941 | + | |
| 2942 | + var currentPos; | |
| 2943 | + if (params.followFinger) { | |
| 2944 | + currentPos = rtl ? swiper.translate : -swiper.translate; | |
| 2945 | + } else { | |
| 2946 | + currentPos = -data.currentTranslate; | |
| 2947 | + } | |
| 2948 | + | |
| 2949 | + if (params.freeMode) { | |
| 2950 | + if (currentPos < -swiper.minTranslate()) { | |
| 2951 | + swiper.slideTo(swiper.activeIndex); | |
| 2952 | + return; | |
| 2953 | + } | |
| 2954 | + if (currentPos > -swiper.maxTranslate()) { | |
| 2955 | + if (swiper.slides.length < snapGrid.length) { | |
| 2956 | + swiper.slideTo(snapGrid.length - 1); | |
| 2957 | + } else { | |
| 2958 | + swiper.slideTo(swiper.slides.length - 1); | |
| 2959 | + } | |
| 2960 | + return; | |
| 2961 | + } | |
| 2962 | + | |
| 2963 | + if (params.freeModeMomentum) { | |
| 2964 | + if (data.velocities.length > 1) { | |
| 2965 | + var lastMoveEvent = data.velocities.pop(); | |
| 2966 | + var velocityEvent = data.velocities.pop(); | |
| 2967 | + | |
| 2968 | + var distance = lastMoveEvent.position - velocityEvent.position; | |
| 2969 | + var time = lastMoveEvent.time - velocityEvent.time; | |
| 2970 | + swiper.velocity = distance / time; | |
| 2971 | + swiper.velocity /= 2; | |
| 2972 | + if (Math.abs(swiper.velocity) < params.freeModeMinimumVelocity) { | |
| 2973 | + swiper.velocity = 0; | |
| 2974 | + } | |
| 2975 | + // this implies that the user stopped moving a finger then released. | |
| 2976 | + // There would be no events with distance zero, so the last event is stale. | |
| 2977 | + if (time > 150 || (Utils.now() - lastMoveEvent.time) > 300) { | |
| 2978 | + swiper.velocity = 0; | |
| 2979 | + } | |
| 2980 | + } else { | |
| 2981 | + swiper.velocity = 0; | |
| 2982 | + } | |
| 2983 | + swiper.velocity *= params.freeModeMomentumVelocityRatio; | |
| 2984 | + | |
| 2985 | + data.velocities.length = 0; | |
| 2986 | + var momentumDuration = 1000 * params.freeModeMomentumRatio; | |
| 2987 | + var momentumDistance = swiper.velocity * momentumDuration; | |
| 2988 | + | |
| 2989 | + var newPosition = swiper.translate + momentumDistance; | |
| 2990 | + if (rtl) { newPosition = -newPosition; } | |
| 2991 | + | |
| 2992 | + var doBounce = false; | |
| 2993 | + var afterBouncePosition; | |
| 2994 | + var bounceAmount = Math.abs(swiper.velocity) * 20 * params.freeModeMomentumBounceRatio; | |
| 2995 | + var needsLoopFix; | |
| 2996 | + if (newPosition < swiper.maxTranslate()) { | |
| 2997 | + if (params.freeModeMomentumBounce) { | |
| 2998 | + if (newPosition + swiper.maxTranslate() < -bounceAmount) { | |
| 2999 | + newPosition = swiper.maxTranslate() - bounceAmount; | |
| 3000 | + } | |
| 3001 | + afterBouncePosition = swiper.maxTranslate(); | |
| 3002 | + doBounce = true; | |
| 3003 | + data.allowMomentumBounce = true; | |
| 3004 | + } else { | |
| 3005 | + newPosition = swiper.maxTranslate(); | |
| 3006 | + } | |
| 3007 | + if (params.loop && params.centeredSlides) { needsLoopFix = true; } | |
| 3008 | + } else if (newPosition > swiper.minTranslate()) { | |
| 3009 | + if (params.freeModeMomentumBounce) { | |
| 3010 | + if (newPosition - swiper.minTranslate() > bounceAmount) { | |
| 3011 | + newPosition = swiper.minTranslate() + bounceAmount; | |
| 3012 | + } | |
| 3013 | + afterBouncePosition = swiper.minTranslate(); | |
| 3014 | + doBounce = true; | |
| 3015 | + data.allowMomentumBounce = true; | |
| 3016 | + } else { | |
| 3017 | + newPosition = swiper.minTranslate(); | |
| 3018 | + } | |
| 3019 | + if (params.loop && params.centeredSlides) { needsLoopFix = true; } | |
| 3020 | + } else if (params.freeModeSticky) { | |
| 3021 | + var nextSlide; | |
| 3022 | + for (var j = 0; j < snapGrid.length; j += 1) { | |
| 3023 | + if (snapGrid[j] > -newPosition) { | |
| 3024 | + nextSlide = j; | |
| 3025 | + break; | |
| 3026 | + } | |
| 3027 | + } | |
| 3028 | + | |
| 3029 | + if (Math.abs(snapGrid[nextSlide] - newPosition) < Math.abs(snapGrid[nextSlide - 1] - newPosition) || swiper.swipeDirection === 'next') { | |
| 3030 | + newPosition = snapGrid[nextSlide]; | |
| 3031 | + } else { | |
| 3032 | + newPosition = snapGrid[nextSlide - 1]; | |
| 3033 | + } | |
| 3034 | + newPosition = -newPosition; | |
| 3035 | + } | |
| 3036 | + if (needsLoopFix) { | |
| 3037 | + swiper.once('transitionEnd', function () { | |
| 3038 | + swiper.loopFix(); | |
| 3039 | + }); | |
| 3040 | + } | |
| 3041 | + // Fix duration | |
| 3042 | + if (swiper.velocity !== 0) { | |
| 3043 | + if (rtl) { | |
| 3044 | + momentumDuration = Math.abs((-newPosition - swiper.translate) / swiper.velocity); | |
| 3045 | + } else { | |
| 3046 | + momentumDuration = Math.abs((newPosition - swiper.translate) / swiper.velocity); | |
| 3047 | + } | |
| 3048 | + } else if (params.freeModeSticky) { | |
| 3049 | + swiper.slideToClosest(); | |
| 3050 | + return; | |
| 3051 | + } | |
| 3052 | + | |
| 3053 | + if (params.freeModeMomentumBounce && doBounce) { | |
| 3054 | + swiper.updateProgress(afterBouncePosition); | |
| 3055 | + swiper.setTransition(momentumDuration); | |
| 3056 | + swiper.setTranslate(newPosition); | |
| 3057 | + swiper.transitionStart(true, swiper.swipeDirection); | |
| 3058 | + swiper.animating = true; | |
| 3059 | + $wrapperEl.transitionEnd(function () { | |
| 3060 | + if (!swiper || swiper.destroyed || !data.allowMomentumBounce) { return; } | |
| 3061 | + swiper.emit('momentumBounce'); | |
| 3062 | + | |
| 3063 | + swiper.setTransition(params.speed); | |
| 3064 | + swiper.setTranslate(afterBouncePosition); | |
| 3065 | + $wrapperEl.transitionEnd(function () { | |
| 3066 | + if (!swiper || swiper.destroyed) { return; } | |
| 3067 | + swiper.transitionEnd(); | |
| 3068 | + }); | |
| 3069 | + }); | |
| 3070 | + } else if (swiper.velocity) { | |
| 3071 | + swiper.updateProgress(newPosition); | |
| 3072 | + swiper.setTransition(momentumDuration); | |
| 3073 | + swiper.setTranslate(newPosition); | |
| 3074 | + swiper.transitionStart(true, swiper.swipeDirection); | |
| 3075 | + if (!swiper.animating) { | |
| 3076 | + swiper.animating = true; | |
| 3077 | + $wrapperEl.transitionEnd(function () { | |
| 3078 | + if (!swiper || swiper.destroyed) { return; } | |
| 3079 | + swiper.transitionEnd(); | |
| 3080 | + }); | |
| 3081 | + } | |
| 3082 | + } else { | |
| 3083 | + swiper.updateProgress(newPosition); | |
| 3084 | + } | |
| 3085 | + | |
| 3086 | + swiper.updateActiveIndex(); | |
| 3087 | + swiper.updateSlidesClasses(); | |
| 3088 | + } else if (params.freeModeSticky) { | |
| 3089 | + swiper.slideToClosest(); | |
| 3090 | + return; | |
| 3091 | + } | |
| 3092 | + | |
| 3093 | + if (!params.freeModeMomentum || timeDiff >= params.longSwipesMs) { | |
| 3094 | + swiper.updateProgress(); | |
| 3095 | + swiper.updateActiveIndex(); | |
| 3096 | + swiper.updateSlidesClasses(); | |
| 3097 | + } | |
| 3098 | + return; | |
| 3099 | + } | |
| 3100 | + | |
| 3101 | + // Find current slide | |
| 3102 | + var stopIndex = 0; | |
| 3103 | + var groupSize = swiper.slidesSizesGrid[0]; | |
| 3104 | + for (var i = 0; i < slidesGrid.length; i += params.slidesPerGroup) { | |
| 3105 | + if (typeof slidesGrid[i + params.slidesPerGroup] !== 'undefined') { | |
| 3106 | + if (currentPos >= slidesGrid[i] && currentPos < slidesGrid[i + params.slidesPerGroup]) { | |
| 3107 | + stopIndex = i; | |
| 3108 | + groupSize = slidesGrid[i + params.slidesPerGroup] - slidesGrid[i]; | |
| 3109 | + } | |
| 3110 | + } else if (currentPos >= slidesGrid[i]) { | |
| 3111 | + stopIndex = i; | |
| 3112 | + groupSize = slidesGrid[slidesGrid.length - 1] - slidesGrid[slidesGrid.length - 2]; | |
| 3113 | + } | |
| 3114 | + } | |
| 3115 | + | |
| 3116 | + // Find current slide size | |
| 3117 | + var ratio = (currentPos - slidesGrid[stopIndex]) / groupSize; | |
| 3118 | + | |
| 3119 | + if (timeDiff > params.longSwipesMs) { | |
| 3120 | + // Long touches | |
| 3121 | + if (!params.longSwipes) { | |
| 3122 | + swiper.slideTo(swiper.activeIndex); | |
| 3123 | + return; | |
| 3124 | + } | |
| 3125 | + if (swiper.swipeDirection === 'next') { | |
| 3126 | + if (ratio >= params.longSwipesRatio) { swiper.slideTo(stopIndex + params.slidesPerGroup); } | |
| 3127 | + else { swiper.slideTo(stopIndex); } | |
| 3128 | + } | |
| 3129 | + if (swiper.swipeDirection === 'prev') { | |
| 3130 | + if (ratio > (1 - params.longSwipesRatio)) { swiper.slideTo(stopIndex + params.slidesPerGroup); } | |
| 3131 | + else { swiper.slideTo(stopIndex); } | |
| 3132 | + } | |
| 3133 | + } else { | |
| 3134 | + // Short swipes | |
| 3135 | + if (!params.shortSwipes) { | |
| 3136 | + swiper.slideTo(swiper.activeIndex); | |
| 3137 | + return; | |
| 3138 | + } | |
| 3139 | + if (swiper.swipeDirection === 'next') { | |
| 3140 | + swiper.slideTo(stopIndex + params.slidesPerGroup); | |
| 3141 | + } | |
| 3142 | + if (swiper.swipeDirection === 'prev') { | |
| 3143 | + swiper.slideTo(stopIndex); | |
| 3144 | + } | |
| 3145 | + } | |
| 3146 | + } | |
| 3147 | + | |
| 3148 | + function onResize () { | |
| 3149 | + var swiper = this; | |
| 3150 | + | |
| 3151 | + var params = swiper.params; | |
| 3152 | + var el = swiper.el; | |
| 3153 | + | |
| 3154 | + if (el && el.offsetWidth === 0) { return; } | |
| 3155 | + | |
| 3156 | + // Breakpoints | |
| 3157 | + if (params.breakpoints) { | |
| 3158 | + swiper.setBreakpoint(); | |
| 3159 | + } | |
| 3160 | + | |
| 3161 | + // Save locks | |
| 3162 | + var allowSlideNext = swiper.allowSlideNext; | |
| 3163 | + var allowSlidePrev = swiper.allowSlidePrev; | |
| 3164 | + var snapGrid = swiper.snapGrid; | |
| 3165 | + | |
| 3166 | + // Disable locks on resize | |
| 3167 | + swiper.allowSlideNext = true; | |
| 3168 | + swiper.allowSlidePrev = true; | |
| 3169 | + | |
| 3170 | + swiper.updateSize(); | |
| 3171 | + swiper.updateSlides(); | |
| 3172 | + | |
| 3173 | + if (params.freeMode) { | |
| 3174 | + var newTranslate = Math.min(Math.max(swiper.translate, swiper.maxTranslate()), swiper.minTranslate()); | |
| 3175 | + swiper.setTranslate(newTranslate); | |
| 3176 | + swiper.updateActiveIndex(); | |
| 3177 | + swiper.updateSlidesClasses(); | |
| 3178 | + | |
| 3179 | + if (params.autoHeight) { | |
| 3180 | + swiper.updateAutoHeight(); | |
| 3181 | + } | |
| 3182 | + } else { | |
| 3183 | + swiper.updateSlidesClasses(); | |
| 3184 | + if ((params.slidesPerView === 'auto' || params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { | |
| 3185 | + swiper.slideTo(swiper.slides.length - 1, 0, false, true); | |
| 3186 | + } else { | |
| 3187 | + swiper.slideTo(swiper.activeIndex, 0, false, true); | |
| 3188 | + } | |
| 3189 | + } | |
| 3190 | + // Return locks after resize | |
| 3191 | + swiper.allowSlidePrev = allowSlidePrev; | |
| 3192 | + swiper.allowSlideNext = allowSlideNext; | |
| 3193 | + | |
| 3194 | + if (swiper.params.watchOverflow && snapGrid !== swiper.snapGrid) { | |
| 3195 | + swiper.checkOverflow(); | |
| 3196 | + } | |
| 3197 | + } | |
| 3198 | + | |
| 3199 | + function onClick (e) { | |
| 3200 | + var swiper = this; | |
| 3201 | + if (!swiper.allowClick) { | |
| 3202 | + if (swiper.params.preventClicks) { e.preventDefault(); } | |
| 3203 | + if (swiper.params.preventClicksPropagation && swiper.animating) { | |
| 3204 | + e.stopPropagation(); | |
| 3205 | + e.stopImmediatePropagation(); | |
| 3206 | + } | |
| 3207 | + } | |
| 3208 | + } | |
| 3209 | + | |
| 3210 | + function attachEvents() { | |
| 3211 | + var swiper = this; | |
| 3212 | + var params = swiper.params; | |
| 3213 | + var touchEvents = swiper.touchEvents; | |
| 3214 | + var el = swiper.el; | |
| 3215 | + var wrapperEl = swiper.wrapperEl; | |
| 3216 | + | |
| 3217 | + { | |
| 3218 | + swiper.onTouchStart = onTouchStart.bind(swiper); | |
| 3219 | + swiper.onTouchMove = onTouchMove.bind(swiper); | |
| 3220 | + swiper.onTouchEnd = onTouchEnd.bind(swiper); | |
| 3221 | + } | |
| 3222 | + | |
| 3223 | + swiper.onClick = onClick.bind(swiper); | |
| 3224 | + | |
| 3225 | + var target = params.touchEventsTarget === 'container' ? el : wrapperEl; | |
| 3226 | + var capture = !!params.nested; | |
| 3227 | + | |
| 3228 | + // Touch Events | |
| 3229 | + { | |
| 3230 | + if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) { | |
| 3231 | + target.addEventListener(touchEvents.start, swiper.onTouchStart, false); | |
| 3232 | + doc.addEventListener(touchEvents.move, swiper.onTouchMove, capture); | |
| 3233 | + doc.addEventListener(touchEvents.end, swiper.onTouchEnd, false); | |
| 3234 | + } else { | |
| 3235 | + if (Support.touch) { | |
| 3236 | + var passiveListener = touchEvents.start === 'touchstart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; | |
| 3237 | + target.addEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); | |
| 3238 | + target.addEventListener(touchEvents.move, swiper.onTouchMove, Support.passiveListener ? { passive: false, capture: capture } : capture); | |
| 3239 | + target.addEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); | |
| 3240 | + } | |
| 3241 | + if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) { | |
| 3242 | + target.addEventListener('mousedown', swiper.onTouchStart, false); | |
| 3243 | + doc.addEventListener('mousemove', swiper.onTouchMove, capture); | |
| 3244 | + doc.addEventListener('mouseup', swiper.onTouchEnd, false); | |
| 3245 | + } | |
| 3246 | + } | |
| 3247 | + // Prevent Links Clicks | |
| 3248 | + if (params.preventClicks || params.preventClicksPropagation) { | |
| 3249 | + target.addEventListener('click', swiper.onClick, true); | |
| 3250 | + } | |
| 3251 | + } | |
| 3252 | + | |
| 3253 | + // Resize handler | |
| 3254 | + swiper.on((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize, true); | |
| 3255 | + } | |
| 3256 | + | |
| 3257 | + function detachEvents() { | |
| 3258 | + var swiper = this; | |
| 3259 | + | |
| 3260 | + var params = swiper.params; | |
| 3261 | + var touchEvents = swiper.touchEvents; | |
| 3262 | + var el = swiper.el; | |
| 3263 | + var wrapperEl = swiper.wrapperEl; | |
| 3264 | + | |
| 3265 | + var target = params.touchEventsTarget === 'container' ? el : wrapperEl; | |
| 3266 | + var capture = !!params.nested; | |
| 3267 | + | |
| 3268 | + // Touch Events | |
| 3269 | + { | |
| 3270 | + if (!Support.touch && (Support.pointerEvents || Support.prefixedPointerEvents)) { | |
| 3271 | + target.removeEventListener(touchEvents.start, swiper.onTouchStart, false); | |
| 3272 | + doc.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); | |
| 3273 | + doc.removeEventListener(touchEvents.end, swiper.onTouchEnd, false); | |
| 3274 | + } else { | |
| 3275 | + if (Support.touch) { | |
| 3276 | + var passiveListener = touchEvents.start === 'onTouchStart' && Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; | |
| 3277 | + target.removeEventListener(touchEvents.start, swiper.onTouchStart, passiveListener); | |
| 3278 | + target.removeEventListener(touchEvents.move, swiper.onTouchMove, capture); | |
| 3279 | + target.removeEventListener(touchEvents.end, swiper.onTouchEnd, passiveListener); | |
| 3280 | + } | |
| 3281 | + if ((params.simulateTouch && !Device.ios && !Device.android) || (params.simulateTouch && !Support.touch && Device.ios)) { | |
| 3282 | + target.removeEventListener('mousedown', swiper.onTouchStart, false); | |
| 3283 | + doc.removeEventListener('mousemove', swiper.onTouchMove, capture); | |
| 3284 | + doc.removeEventListener('mouseup', swiper.onTouchEnd, false); | |
| 3285 | + } | |
| 3286 | + } | |
| 3287 | + // Prevent Links Clicks | |
| 3288 | + if (params.preventClicks || params.preventClicksPropagation) { | |
| 3289 | + target.removeEventListener('click', swiper.onClick, true); | |
| 3290 | + } | |
| 3291 | + } | |
| 3292 | + | |
| 3293 | + // Resize handler | |
| 3294 | + swiper.off((Device.ios || Device.android ? 'resize orientationchange observerUpdate' : 'resize observerUpdate'), onResize); | |
| 3295 | + } | |
| 3296 | + | |
| 3297 | + var events = { | |
| 3298 | + attachEvents: attachEvents, | |
| 3299 | + detachEvents: detachEvents, | |
| 3300 | + }; | |
| 3301 | + | |
| 3302 | + function setBreakpoint () { | |
| 3303 | + var swiper = this; | |
| 3304 | + var activeIndex = swiper.activeIndex; | |
| 3305 | + var initialized = swiper.initialized; | |
| 3306 | + var loopedSlides = swiper.loopedSlides; if ( loopedSlides === void 0 ) loopedSlides = 0; | |
| 3307 | + var params = swiper.params; | |
| 3308 | + var breakpoints = params.breakpoints; | |
| 3309 | + if (!breakpoints || (breakpoints && Object.keys(breakpoints).length === 0)) { return; } | |
| 3310 | + | |
| 3311 | + // Set breakpoint for window width and update parameters | |
| 3312 | + var breakpoint = swiper.getBreakpoint(breakpoints); | |
| 3313 | + | |
| 3314 | + if (breakpoint && swiper.currentBreakpoint !== breakpoint) { | |
| 3315 | + var breakpointOnlyParams = breakpoint in breakpoints ? breakpoints[breakpoint] : undefined; | |
| 3316 | + if (breakpointOnlyParams) { | |
| 3317 | + ['slidesPerView', 'spaceBetween', 'slidesPerGroup'].forEach(function (param) { | |
| 3318 | + var paramValue = breakpointOnlyParams[param]; | |
| 3319 | + if (typeof paramValue === 'undefined') { return; } | |
| 3320 | + if (param === 'slidesPerView' && (paramValue === 'AUTO' || paramValue === 'auto')) { | |
| 3321 | + breakpointOnlyParams[param] = 'auto'; | |
| 3322 | + } else if (param === 'slidesPerView') { | |
| 3323 | + breakpointOnlyParams[param] = parseFloat(paramValue); | |
| 3324 | + } else { | |
| 3325 | + breakpointOnlyParams[param] = parseInt(paramValue, 10); | |
| 3326 | + } | |
| 3327 | + }); | |
| 3328 | + } | |
| 3329 | + | |
| 3330 | + var breakpointParams = breakpointOnlyParams || swiper.originalParams; | |
| 3331 | + var needsReLoop = params.loop && (breakpointParams.slidesPerView !== params.slidesPerView); | |
| 3332 | + | |
| 3333 | + Utils.extend(swiper.params, breakpointParams); | |
| 3334 | + | |
| 3335 | + Utils.extend(swiper, { | |
| 3336 | + allowTouchMove: swiper.params.allowTouchMove, | |
| 3337 | + allowSlideNext: swiper.params.allowSlideNext, | |
| 3338 | + allowSlidePrev: swiper.params.allowSlidePrev, | |
| 3339 | + }); | |
| 3340 | + | |
| 3341 | + swiper.currentBreakpoint = breakpoint; | |
| 3342 | + | |
| 3343 | + if (needsReLoop && initialized) { | |
| 3344 | + swiper.loopDestroy(); | |
| 3345 | + swiper.loopCreate(); | |
| 3346 | + swiper.updateSlides(); | |
| 3347 | + swiper.slideTo((activeIndex - loopedSlides) + swiper.loopedSlides, 0, false); | |
| 3348 | + } | |
| 3349 | + swiper.emit('breakpoint', breakpointParams); | |
| 3350 | + } | |
| 3351 | + } | |
| 3352 | + | |
| 3353 | + function getBreakpoint (breakpoints) { | |
| 3354 | + var swiper = this; | |
| 3355 | + // Get breakpoint for window width | |
| 3356 | + if (!breakpoints) { return undefined; } | |
| 3357 | + var breakpoint = false; | |
| 3358 | + var points = []; | |
| 3359 | + Object.keys(breakpoints).forEach(function (point) { | |
| 3360 | + points.push(point); | |
| 3361 | + }); | |
| 3362 | + points.sort(function (a, b) { return parseInt(a, 10) - parseInt(b, 10); }); | |
| 3363 | + for (var i = 0; i < points.length; i += 1) { | |
| 3364 | + var point = points[i]; | |
| 3365 | + if (swiper.params.breakpointsInverse) { | |
| 3366 | + if (point <= win.innerWidth) { | |
| 3367 | + breakpoint = point; | |
| 3368 | + } | |
| 3369 | + } else if (point >= win.innerWidth && !breakpoint) { | |
| 3370 | + breakpoint = point; | |
| 3371 | + } | |
| 3372 | + } | |
| 3373 | + return breakpoint || 'max'; | |
| 3374 | + } | |
| 3375 | + | |
| 3376 | + var breakpoints = { setBreakpoint: setBreakpoint, getBreakpoint: getBreakpoint }; | |
| 3377 | + | |
| 3378 | + var Browser = (function Browser() { | |
| 3379 | + function isSafari() { | |
| 3380 | + var ua = win.navigator.userAgent.toLowerCase(); | |
| 3381 | + return (ua.indexOf('safari') >= 0 && ua.indexOf('chrome') < 0 && ua.indexOf('android') < 0); | |
| 3382 | + } | |
| 3383 | + return { | |
| 3384 | + isIE: !!win.navigator.userAgent.match(/Trident/g) || !!win.navigator.userAgent.match(/MSIE/g), | |
| 3385 | + isEdge: !!win.navigator.userAgent.match(/Edge/g), | |
| 3386 | + isSafari: isSafari(), | |
| 3387 | + isUiWebView: /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(win.navigator.userAgent), | |
| 3388 | + }; | |
| 3389 | + }()); | |
| 3390 | + | |
| 3391 | + function addClasses () { | |
| 3392 | + var swiper = this; | |
| 3393 | + var classNames = swiper.classNames; | |
| 3394 | + var params = swiper.params; | |
| 3395 | + var rtl = swiper.rtl; | |
| 3396 | + var $el = swiper.$el; | |
| 3397 | + var suffixes = []; | |
| 3398 | + | |
| 3399 | + suffixes.push(params.direction); | |
| 3400 | + | |
| 3401 | + if (params.freeMode) { | |
| 3402 | + suffixes.push('free-mode'); | |
| 3403 | + } | |
| 3404 | + if (!Support.flexbox) { | |
| 3405 | + suffixes.push('no-flexbox'); | |
| 3406 | + } | |
| 3407 | + if (params.autoHeight) { | |
| 3408 | + suffixes.push('autoheight'); | |
| 3409 | + } | |
| 3410 | + if (rtl) { | |
| 3411 | + suffixes.push('rtl'); | |
| 3412 | + } | |
| 3413 | + if (params.slidesPerColumn > 1) { | |
| 3414 | + suffixes.push('multirow'); | |
| 3415 | + } | |
| 3416 | + if (Device.android) { | |
| 3417 | + suffixes.push('android'); | |
| 3418 | + } | |
| 3419 | + if (Device.ios) { | |
| 3420 | + suffixes.push('ios'); | |
| 3421 | + } | |
| 3422 | + // WP8 Touch Events Fix | |
| 3423 | + if ((Browser.isIE || Browser.isEdge) && (Support.pointerEvents || Support.prefixedPointerEvents)) { | |
| 3424 | + suffixes.push(("wp8-" + (params.direction))); | |
| 3425 | + } | |
| 3426 | + | |
| 3427 | + suffixes.forEach(function (suffix) { | |
| 3428 | + classNames.push(params.containerModifierClass + suffix); | |
| 3429 | + }); | |
| 3430 | + | |
| 3431 | + $el.addClass(classNames.join(' ')); | |
| 3432 | + } | |
| 3433 | + | |
| 3434 | + function removeClasses () { | |
| 3435 | + var swiper = this; | |
| 3436 | + var $el = swiper.$el; | |
| 3437 | + var classNames = swiper.classNames; | |
| 3438 | + | |
| 3439 | + $el.removeClass(classNames.join(' ')); | |
| 3440 | + } | |
| 3441 | + | |
| 3442 | + var classes = { addClasses: addClasses, removeClasses: removeClasses }; | |
| 3443 | + | |
| 3444 | + function loadImage (imageEl, src, srcset, sizes, checkForComplete, callback) { | |
| 3445 | + var image; | |
| 3446 | + function onReady() { | |
| 3447 | + if (callback) { callback(); } | |
| 3448 | + } | |
| 3449 | + if (!imageEl.complete || !checkForComplete) { | |
| 3450 | + if (src) { | |
| 3451 | + image = new win.Image(); | |
| 3452 | + image.onload = onReady; | |
| 3453 | + image.onerror = onReady; | |
| 3454 | + if (sizes) { | |
| 3455 | + image.sizes = sizes; | |
| 3456 | + } | |
| 3457 | + if (srcset) { | |
| 3458 | + image.srcset = srcset; | |
| 3459 | + } | |
| 3460 | + if (src) { | |
| 3461 | + image.src = src; | |
| 3462 | + } | |
| 3463 | + } else { | |
| 3464 | + onReady(); | |
| 3465 | + } | |
| 3466 | + } else { | |
| 3467 | + // image already loaded... | |
| 3468 | + onReady(); | |
| 3469 | + } | |
| 3470 | + } | |
| 3471 | + | |
| 3472 | + function preloadImages () { | |
| 3473 | + var swiper = this; | |
| 3474 | + swiper.imagesToLoad = swiper.$el.find('img'); | |
| 3475 | + function onReady() { | |
| 3476 | + if (typeof swiper === 'undefined' || swiper === null || !swiper || swiper.destroyed) { return; } | |
| 3477 | + if (swiper.imagesLoaded !== undefined) { swiper.imagesLoaded += 1; } | |
| 3478 | + if (swiper.imagesLoaded === swiper.imagesToLoad.length) { | |
| 3479 | + if (swiper.params.updateOnImagesReady) { swiper.update(); } | |
| 3480 | + swiper.emit('imagesReady'); | |
| 3481 | + } | |
| 3482 | + } | |
| 3483 | + for (var i = 0; i < swiper.imagesToLoad.length; i += 1) { | |
| 3484 | + var imageEl = swiper.imagesToLoad[i]; | |
| 3485 | + swiper.loadImage( | |
| 3486 | + imageEl, | |
| 3487 | + imageEl.currentSrc || imageEl.getAttribute('src'), | |
| 3488 | + imageEl.srcset || imageEl.getAttribute('srcset'), | |
| 3489 | + imageEl.sizes || imageEl.getAttribute('sizes'), | |
| 3490 | + true, | |
| 3491 | + onReady | |
| 3492 | + ); | |
| 3493 | + } | |
| 3494 | + } | |
| 3495 | + | |
| 3496 | + var images = { | |
| 3497 | + loadImage: loadImage, | |
| 3498 | + preloadImages: preloadImages, | |
| 3499 | + }; | |
| 3500 | + | |
| 3501 | + function checkOverflow() { | |
| 3502 | + var swiper = this; | |
| 3503 | + var wasLocked = swiper.isLocked; | |
| 3504 | + | |
| 3505 | + swiper.isLocked = swiper.snapGrid.length === 1; | |
| 3506 | + swiper.allowSlideNext = !swiper.isLocked; | |
| 3507 | + swiper.allowSlidePrev = !swiper.isLocked; | |
| 3508 | + | |
| 3509 | + // events | |
| 3510 | + if (wasLocked !== swiper.isLocked) { swiper.emit(swiper.isLocked ? 'lock' : 'unlock'); } | |
| 3511 | + | |
| 3512 | + if (wasLocked && wasLocked !== swiper.isLocked) { | |
| 3513 | + swiper.isEnd = false; | |
| 3514 | + swiper.navigation.update(); | |
| 3515 | + } | |
| 3516 | + } | |
| 3517 | + | |
| 3518 | + var checkOverflow$1 = { checkOverflow: checkOverflow }; | |
| 3519 | + | |
| 3520 | + var defaults = { | |
| 3521 | + init: true, | |
| 3522 | + direction: 'horizontal', | |
| 3523 | + touchEventsTarget: 'container', | |
| 3524 | + initialSlide: 0, | |
| 3525 | + speed: 300, | |
| 3526 | + // | |
| 3527 | + preventInteractionOnTransition: false, | |
| 3528 | + | |
| 3529 | + // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView). | |
| 3530 | + edgeSwipeDetection: false, | |
| 3531 | + edgeSwipeThreshold: 20, | |
| 3532 | + | |
| 3533 | + // Free mode | |
| 3534 | + freeMode: false, | |
| 3535 | + freeModeMomentum: true, | |
| 3536 | + freeModeMomentumRatio: 1, | |
| 3537 | + freeModeMomentumBounce: true, | |
| 3538 | + freeModeMomentumBounceRatio: 1, | |
| 3539 | + freeModeMomentumVelocityRatio: 1, | |
| 3540 | + freeModeSticky: false, | |
| 3541 | + freeModeMinimumVelocity: 0.02, | |
| 3542 | + | |
| 3543 | + // Autoheight | |
| 3544 | + autoHeight: false, | |
| 3545 | + | |
| 3546 | + // Set wrapper width | |
| 3547 | + setWrapperSize: false, | |
| 3548 | + | |
| 3549 | + // Virtual Translate | |
| 3550 | + virtualTranslate: false, | |
| 3551 | + | |
| 3552 | + // Effects | |
| 3553 | + effect: 'slide', // 'slide' or 'fade' or 'cube' or 'coverflow' or 'flip' | |
| 3554 | + | |
| 3555 | + // Breakpoints | |
| 3556 | + breakpoints: undefined, | |
| 3557 | + breakpointsInverse: false, | |
| 3558 | + | |
| 3559 | + // Slides grid | |
| 3560 | + spaceBetween: 0, | |
| 3561 | + slidesPerView: 1, | |
| 3562 | + slidesPerColumn: 1, | |
| 3563 | + slidesPerColumnFill: 'column', | |
| 3564 | + slidesPerGroup: 1, | |
| 3565 | + centeredSlides: false, | |
| 3566 | + slidesOffsetBefore: 0, // in px | |
| 3567 | + slidesOffsetAfter: 0, // in px | |
| 3568 | + normalizeSlideIndex: true, | |
| 3569 | + centerInsufficientSlides: false, | |
| 3570 | + | |
| 3571 | + // Disable swiper and hide navigation when container not overflow | |
| 3572 | + watchOverflow: false, | |
| 3573 | + | |
| 3574 | + // Round length | |
| 3575 | + roundLengths: false, | |
| 3576 | + | |
| 3577 | + // Touches | |
| 3578 | + touchRatio: 1, | |
| 3579 | + touchAngle: 45, | |
| 3580 | + simulateTouch: true, | |
| 3581 | + shortSwipes: true, | |
| 3582 | + longSwipes: true, | |
| 3583 | + longSwipesRatio: 0.5, | |
| 3584 | + longSwipesMs: 300, | |
| 3585 | + followFinger: true, | |
| 3586 | + allowTouchMove: true, | |
| 3587 | + threshold: 0, | |
| 3588 | + touchMoveStopPropagation: true, | |
| 3589 | + touchStartPreventDefault: true, | |
| 3590 | + touchStartForcePreventDefault: false, | |
| 3591 | + touchReleaseOnEdges: false, | |
| 3592 | + | |
| 3593 | + // Unique Navigation Elements | |
| 3594 | + uniqueNavElements: true, | |
| 3595 | + | |
| 3596 | + // Resistance | |
| 3597 | + resistance: true, | |
| 3598 | + resistanceRatio: 0.85, | |
| 3599 | + | |
| 3600 | + // Progress | |
| 3601 | + watchSlidesProgress: false, | |
| 3602 | + watchSlidesVisibility: false, | |
| 3603 | + | |
| 3604 | + // Cursor | |
| 3605 | + grabCursor: false, | |
| 3606 | + | |
| 3607 | + // Clicks | |
| 3608 | + preventClicks: true, | |
| 3609 | + preventClicksPropagation: true, | |
| 3610 | + slideToClickedSlide: false, | |
| 3611 | + | |
| 3612 | + // Images | |
| 3613 | + preloadImages: true, | |
| 3614 | + updateOnImagesReady: true, | |
| 3615 | + | |
| 3616 | + // loop | |
| 3617 | + loop: false, | |
| 3618 | + loopAdditionalSlides: 0, | |
| 3619 | + loopedSlides: null, | |
| 3620 | + loopFillGroupWithBlank: false, | |
| 3621 | + | |
| 3622 | + // Swiping/no swiping | |
| 3623 | + allowSlidePrev: true, | |
| 3624 | + allowSlideNext: true, | |
| 3625 | + swipeHandler: null, // '.swipe-handler', | |
| 3626 | + noSwiping: true, | |
| 3627 | + noSwipingClass: 'swiper-no-swiping', | |
| 3628 | + noSwipingSelector: null, | |
| 3629 | + | |
| 3630 | + // Passive Listeners | |
| 3631 | + passiveListeners: true, | |
| 3632 | + | |
| 3633 | + // NS | |
| 3634 | + containerModifierClass: 'swiper-container-', // NEW | |
| 3635 | + slideClass: 'swiper-slide', | |
| 3636 | + slideBlankClass: 'swiper-slide-invisible-blank', | |
| 3637 | + slideActiveClass: 'swiper-slide-active', | |
| 3638 | + slideDuplicateActiveClass: 'swiper-slide-duplicate-active', | |
| 3639 | + slideVisibleClass: 'swiper-slide-visible', | |
| 3640 | + slideDuplicateClass: 'swiper-slide-duplicate', | |
| 3641 | + slideNextClass: 'swiper-slide-next', | |
| 3642 | + slideDuplicateNextClass: 'swiper-slide-duplicate-next', | |
| 3643 | + slidePrevClass: 'swiper-slide-prev', | |
| 3644 | + slideDuplicatePrevClass: 'swiper-slide-duplicate-prev', | |
| 3645 | + wrapperClass: 'swiper-wrapper', | |
| 3646 | + | |
| 3647 | + // Callbacks | |
| 3648 | + runCallbacksOnInit: true, | |
| 3649 | + }; | |
| 3650 | + | |
| 3651 | + var prototypes = { | |
| 3652 | + update: update, | |
| 3653 | + translate: translate, | |
| 3654 | + transition: transition$1, | |
| 3655 | + slide: slide, | |
| 3656 | + loop: loop, | |
| 3657 | + grabCursor: grabCursor, | |
| 3658 | + manipulation: manipulation, | |
| 3659 | + events: events, | |
| 3660 | + breakpoints: breakpoints, | |
| 3661 | + checkOverflow: checkOverflow$1, | |
| 3662 | + classes: classes, | |
| 3663 | + images: images, | |
| 3664 | + }; | |
| 3665 | + | |
| 3666 | + var extendedDefaults = {}; | |
| 3667 | + | |
| 3668 | + var Swiper = /*@__PURE__*/(function (SwiperClass$$1) { | |
| 3669 | + function Swiper() { | |
| 3670 | + var assign; | |
| 3671 | + | |
| 3672 | + var args = [], len = arguments.length; | |
| 3673 | + while ( len-- ) args[ len ] = arguments[ len ]; | |
| 3674 | + var el; | |
| 3675 | + var params; | |
| 3676 | + if (args.length === 1 && args[0].constructor && args[0].constructor === Object) { | |
| 3677 | + params = args[0]; | |
| 3678 | + } else { | |
| 3679 | + (assign = args, el = assign[0], params = assign[1]); | |
| 3680 | + } | |
| 3681 | + if (!params) { params = {}; } | |
| 3682 | + | |
| 3683 | + params = Utils.extend({}, params); | |
| 3684 | + if (el && !params.el) { params.el = el; } | |
| 3685 | + | |
| 3686 | + SwiperClass$$1.call(this, params); | |
| 3687 | + | |
| 3688 | + Object.keys(prototypes).forEach(function (prototypeGroup) { | |
| 3689 | + Object.keys(prototypes[prototypeGroup]).forEach(function (protoMethod) { | |
| 3690 | + if (!Swiper.prototype[protoMethod]) { | |
| 3691 | + Swiper.prototype[protoMethod] = prototypes[prototypeGroup][protoMethod]; | |
| 3692 | + } | |
| 3693 | + }); | |
| 3694 | + }); | |
| 3695 | + | |
| 3696 | + // Swiper Instance | |
| 3697 | + var swiper = this; | |
| 3698 | + if (typeof swiper.modules === 'undefined') { | |
| 3699 | + swiper.modules = {}; | |
| 3700 | + } | |
| 3701 | + Object.keys(swiper.modules).forEach(function (moduleName) { | |
| 3702 | + var module = swiper.modules[moduleName]; | |
| 3703 | + if (module.params) { | |
| 3704 | + var moduleParamName = Object.keys(module.params)[0]; | |
| 3705 | + var moduleParams = module.params[moduleParamName]; | |
| 3706 | + if (typeof moduleParams !== 'object' || moduleParams === null) { return; } | |
| 3707 | + if (!(moduleParamName in params && 'enabled' in moduleParams)) { return; } | |
| 3708 | + if (params[moduleParamName] === true) { | |
| 3709 | + params[moduleParamName] = { enabled: true }; | |
| 3710 | + } | |
| 3711 | + if ( | |
| 3712 | + typeof params[moduleParamName] === 'object' | |
| 3713 | + && !('enabled' in params[moduleParamName]) | |
| 3714 | + ) { | |
| 3715 | + params[moduleParamName].enabled = true; | |
| 3716 | + } | |
| 3717 | + if (!params[moduleParamName]) { params[moduleParamName] = { enabled: false }; } | |
| 3718 | + } | |
| 3719 | + }); | |
| 3720 | + | |
| 3721 | + // Extend defaults with modules params | |
| 3722 | + var swiperParams = Utils.extend({}, defaults); | |
| 3723 | + swiper.useModulesParams(swiperParams); | |
| 3724 | + | |
| 3725 | + // Extend defaults with passed params | |
| 3726 | + swiper.params = Utils.extend({}, swiperParams, extendedDefaults, params); | |
| 3727 | + swiper.originalParams = Utils.extend({}, swiper.params); | |
| 3728 | + swiper.passedParams = Utils.extend({}, params); | |
| 3729 | + | |
| 3730 | + // Save Dom lib | |
| 3731 | + swiper.$ = $; | |
| 3732 | + | |
| 3733 | + // Find el | |
| 3734 | + var $el = $(swiper.params.el); | |
| 3735 | + el = $el[0]; | |
| 3736 | + | |
| 3737 | + if (!el) { | |
| 3738 | + return undefined; | |
| 3739 | + } | |
| 3740 | + | |
| 3741 | + if ($el.length > 1) { | |
| 3742 | + var swipers = []; | |
| 3743 | + $el.each(function (index, containerEl) { | |
| 3744 | + var newParams = Utils.extend({}, params, { el: containerEl }); | |
| 3745 | + swipers.push(new Swiper(newParams)); | |
| 3746 | + }); | |
| 3747 | + return swipers; | |
| 3748 | + } | |
| 3749 | + | |
| 3750 | + el.swiper = swiper; | |
| 3751 | + $el.data('swiper', swiper); | |
| 3752 | + | |
| 3753 | + // Find Wrapper | |
| 3754 | + var $wrapperEl = $el.children(("." + (swiper.params.wrapperClass))); | |
| 3755 | + | |
| 3756 | + // Extend Swiper | |
| 3757 | + Utils.extend(swiper, { | |
| 3758 | + $el: $el, | |
| 3759 | + el: el, | |
| 3760 | + $wrapperEl: $wrapperEl, | |
| 3761 | + wrapperEl: $wrapperEl[0], | |
| 3762 | + | |
| 3763 | + // Classes | |
| 3764 | + classNames: [], | |
| 3765 | + | |
| 3766 | + // Slides | |
| 3767 | + slides: $(), | |
| 3768 | + slidesGrid: [], | |
| 3769 | + snapGrid: [], | |
| 3770 | + slidesSizesGrid: [], | |
| 3771 | + | |
| 3772 | + // isDirection | |
| 3773 | + isHorizontal: function isHorizontal() { | |
| 3774 | + return swiper.params.direction === 'horizontal'; | |
| 3775 | + }, | |
| 3776 | + isVertical: function isVertical() { | |
| 3777 | + return swiper.params.direction === 'vertical'; | |
| 3778 | + }, | |
| 3779 | + // RTL | |
| 3780 | + rtl: (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), | |
| 3781 | + rtlTranslate: swiper.params.direction === 'horizontal' && (el.dir.toLowerCase() === 'rtl' || $el.css('direction') === 'rtl'), | |
| 3782 | + wrongRTL: $wrapperEl.css('display') === '-webkit-box', | |
| 3783 | + | |
| 3784 | + // Indexes | |
| 3785 | + activeIndex: 0, | |
| 3786 | + realIndex: 0, | |
| 3787 | + | |
| 3788 | + // | |
| 3789 | + isBeginning: true, | |
| 3790 | + isEnd: false, | |
| 3791 | + | |
| 3792 | + // Props | |
| 3793 | + translate: 0, | |
| 3794 | + previousTranslate: 0, | |
| 3795 | + progress: 0, | |
| 3796 | + velocity: 0, | |
| 3797 | + animating: false, | |
| 3798 | + | |
| 3799 | + // Locks | |
| 3800 | + allowSlideNext: swiper.params.allowSlideNext, | |
| 3801 | + allowSlidePrev: swiper.params.allowSlidePrev, | |
| 3802 | + | |
| 3803 | + // Touch Events | |
| 3804 | + touchEvents: (function touchEvents() { | |
| 3805 | + var touch = ['touchstart', 'touchmove', 'touchend']; | |
| 3806 | + var desktop = ['mousedown', 'mousemove', 'mouseup']; | |
| 3807 | + if (Support.pointerEvents) { | |
| 3808 | + desktop = ['pointerdown', 'pointermove', 'pointerup']; | |
| 3809 | + } else if (Support.prefixedPointerEvents) { | |
| 3810 | + desktop = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp']; | |
| 3811 | + } | |
| 3812 | + swiper.touchEventsTouch = { | |
| 3813 | + start: touch[0], | |
| 3814 | + move: touch[1], | |
| 3815 | + end: touch[2], | |
| 3816 | + }; | |
| 3817 | + swiper.touchEventsDesktop = { | |
| 3818 | + start: desktop[0], | |
| 3819 | + move: desktop[1], | |
| 3820 | + end: desktop[2], | |
| 3821 | + }; | |
| 3822 | + return Support.touch || !swiper.params.simulateTouch ? swiper.touchEventsTouch : swiper.touchEventsDesktop; | |
| 3823 | + }()), | |
| 3824 | + touchEventsData: { | |
| 3825 | + isTouched: undefined, | |
| 3826 | + isMoved: undefined, | |
| 3827 | + allowTouchCallbacks: undefined, | |
| 3828 | + touchStartTime: undefined, | |
| 3829 | + isScrolling: undefined, | |
| 3830 | + currentTranslate: undefined, | |
| 3831 | + startTranslate: undefined, | |
| 3832 | + allowThresholdMove: undefined, | |
| 3833 | + // Form elements to match | |
| 3834 | + formElements: 'input, select, option, textarea, button, video', | |
| 3835 | + // Last click time | |
| 3836 | + lastClickTime: Utils.now(), | |
| 3837 | + clickTimeout: undefined, | |
| 3838 | + // Velocities | |
| 3839 | + velocities: [], | |
| 3840 | + allowMomentumBounce: undefined, | |
| 3841 | + isTouchEvent: undefined, | |
| 3842 | + startMoving: undefined, | |
| 3843 | + }, | |
| 3844 | + | |
| 3845 | + // Clicks | |
| 3846 | + allowClick: true, | |
| 3847 | + | |
| 3848 | + // Touches | |
| 3849 | + allowTouchMove: swiper.params.allowTouchMove, | |
| 3850 | + | |
| 3851 | + touches: { | |
| 3852 | + startX: 0, | |
| 3853 | + startY: 0, | |
| 3854 | + currentX: 0, | |
| 3855 | + currentY: 0, | |
| 3856 | + diff: 0, | |
| 3857 | + }, | |
| 3858 | + | |
| 3859 | + // Images | |
| 3860 | + imagesToLoad: [], | |
| 3861 | + imagesLoaded: 0, | |
| 3862 | + | |
| 3863 | + }); | |
| 3864 | + | |
| 3865 | + // Install Modules | |
| 3866 | + swiper.useModules(); | |
| 3867 | + | |
| 3868 | + // Init | |
| 3869 | + if (swiper.params.init) { | |
| 3870 | + swiper.init(); | |
| 3871 | + } | |
| 3872 | + | |
| 3873 | + // Return app instance | |
| 3874 | + return swiper; | |
| 3875 | + } | |
| 3876 | + | |
| 3877 | + if ( SwiperClass$$1 ) Swiper.__proto__ = SwiperClass$$1; | |
| 3878 | + Swiper.prototype = Object.create( SwiperClass$$1 && SwiperClass$$1.prototype ); | |
| 3879 | + Swiper.prototype.constructor = Swiper; | |
| 3880 | + | |
| 3881 | + var staticAccessors = { extendedDefaults: { configurable: true },defaults: { configurable: true },Class: { configurable: true },$: { configurable: true } }; | |
| 3882 | + | |
| 3883 | + Swiper.prototype.slidesPerViewDynamic = function slidesPerViewDynamic () { | |
| 3884 | + var swiper = this; | |
| 3885 | + var params = swiper.params; | |
| 3886 | + var slides = swiper.slides; | |
| 3887 | + var slidesGrid = swiper.slidesGrid; | |
| 3888 | + var swiperSize = swiper.size; | |
| 3889 | + var activeIndex = swiper.activeIndex; | |
| 3890 | + var spv = 1; | |
| 3891 | + if (params.centeredSlides) { | |
| 3892 | + var slideSize = slides[activeIndex].swiperSlideSize; | |
| 3893 | + var breakLoop; | |
| 3894 | + for (var i = activeIndex + 1; i < slides.length; i += 1) { | |
| 3895 | + if (slides[i] && !breakLoop) { | |
| 3896 | + slideSize += slides[i].swiperSlideSize; | |
| 3897 | + spv += 1; | |
| 3898 | + if (slideSize > swiperSize) { breakLoop = true; } | |
| 3899 | + } | |
| 3900 | + } | |
| 3901 | + for (var i$1 = activeIndex - 1; i$1 >= 0; i$1 -= 1) { | |
| 3902 | + if (slides[i$1] && !breakLoop) { | |
| 3903 | + slideSize += slides[i$1].swiperSlideSize; | |
| 3904 | + spv += 1; | |
| 3905 | + if (slideSize > swiperSize) { breakLoop = true; } | |
| 3906 | + } | |
| 3907 | + } | |
| 3908 | + } else { | |
| 3909 | + for (var i$2 = activeIndex + 1; i$2 < slides.length; i$2 += 1) { | |
| 3910 | + if (slidesGrid[i$2] - slidesGrid[activeIndex] < swiperSize) { | |
| 3911 | + spv += 1; | |
| 3912 | + } | |
| 3913 | + } | |
| 3914 | + } | |
| 3915 | + return spv; | |
| 3916 | + }; | |
| 3917 | + | |
| 3918 | + Swiper.prototype.update = function update$$1 () { | |
| 3919 | + var swiper = this; | |
| 3920 | + if (!swiper || swiper.destroyed) { return; } | |
| 3921 | + var snapGrid = swiper.snapGrid; | |
| 3922 | + var params = swiper.params; | |
| 3923 | + // Breakpoints | |
| 3924 | + if (params.breakpoints) { | |
| 3925 | + swiper.setBreakpoint(); | |
| 3926 | + } | |
| 3927 | + swiper.updateSize(); | |
| 3928 | + swiper.updateSlides(); | |
| 3929 | + swiper.updateProgress(); | |
| 3930 | + swiper.updateSlidesClasses(); | |
| 3931 | + | |
| 3932 | + function setTranslate() { | |
| 3933 | + var translateValue = swiper.rtlTranslate ? swiper.translate * -1 : swiper.translate; | |
| 3934 | + var newTranslate = Math.min(Math.max(translateValue, swiper.maxTranslate()), swiper.minTranslate()); | |
| 3935 | + swiper.setTranslate(newTranslate); | |
| 3936 | + swiper.updateActiveIndex(); | |
| 3937 | + swiper.updateSlidesClasses(); | |
| 3938 | + } | |
| 3939 | + var translated; | |
| 3940 | + if (swiper.params.freeMode) { | |
| 3941 | + setTranslate(); | |
| 3942 | + if (swiper.params.autoHeight) { | |
| 3943 | + swiper.updateAutoHeight(); | |
| 3944 | + } | |
| 3945 | + } else { | |
| 3946 | + if ((swiper.params.slidesPerView === 'auto' || swiper.params.slidesPerView > 1) && swiper.isEnd && !swiper.params.centeredSlides) { | |
| 3947 | + translated = swiper.slideTo(swiper.slides.length - 1, 0, false, true); | |
| 3948 | + } else { | |
| 3949 | + translated = swiper.slideTo(swiper.activeIndex, 0, false, true); | |
| 3950 | + } | |
| 3951 | + if (!translated) { | |
| 3952 | + setTranslate(); | |
| 3953 | + } | |
| 3954 | + } | |
| 3955 | + if (params.watchOverflow && snapGrid !== swiper.snapGrid) { | |
| 3956 | + swiper.checkOverflow(); | |
| 3957 | + } | |
| 3958 | + swiper.emit('update'); | |
| 3959 | + }; | |
| 3960 | + | |
| 3961 | + Swiper.prototype.init = function init () { | |
| 3962 | + var swiper = this; | |
| 3963 | + if (swiper.initialized) { return; } | |
| 3964 | + | |
| 3965 | + swiper.emit('beforeInit'); | |
| 3966 | + | |
| 3967 | + // Set breakpoint | |
| 3968 | + if (swiper.params.breakpoints) { | |
| 3969 | + swiper.setBreakpoint(); | |
| 3970 | + } | |
| 3971 | + | |
| 3972 | + // Add Classes | |
| 3973 | + swiper.addClasses(); | |
| 3974 | + | |
| 3975 | + // Create loop | |
| 3976 | + if (swiper.params.loop) { | |
| 3977 | + swiper.loopCreate(); | |
| 3978 | + } | |
| 3979 | + | |
| 3980 | + // Update size | |
| 3981 | + swiper.updateSize(); | |
| 3982 | + | |
| 3983 | + // Update slides | |
| 3984 | + swiper.updateSlides(); | |
| 3985 | + | |
| 3986 | + if (swiper.params.watchOverflow) { | |
| 3987 | + swiper.checkOverflow(); | |
| 3988 | + } | |
| 3989 | + | |
| 3990 | + // Set Grab Cursor | |
| 3991 | + if (swiper.params.grabCursor) { | |
| 3992 | + swiper.setGrabCursor(); | |
| 3993 | + } | |
| 3994 | + | |
| 3995 | + if (swiper.params.preloadImages) { | |
| 3996 | + swiper.preloadImages(); | |
| 3997 | + } | |
| 3998 | + | |
| 3999 | + // Slide To Initial Slide | |
| 4000 | + if (swiper.params.loop) { | |
| 4001 | + swiper.slideTo(swiper.params.initialSlide + swiper.loopedSlides, 0, swiper.params.runCallbacksOnInit); | |
| 4002 | + } else { | |
| 4003 | + swiper.slideTo(swiper.params.initialSlide, 0, swiper.params.runCallbacksOnInit); | |
| 4004 | + } | |
| 4005 | + | |
| 4006 | + // Attach events | |
| 4007 | + swiper.attachEvents(); | |
| 4008 | + | |
| 4009 | + // Init Flag | |
| 4010 | + swiper.initialized = true; | |
| 4011 | + | |
| 4012 | + // Emit | |
| 4013 | + swiper.emit('init'); | |
| 4014 | + }; | |
| 4015 | + | |
| 4016 | + Swiper.prototype.destroy = function destroy (deleteInstance, cleanStyles) { | |
| 4017 | + if ( deleteInstance === void 0 ) deleteInstance = true; | |
| 4018 | + if ( cleanStyles === void 0 ) cleanStyles = true; | |
| 4019 | + | |
| 4020 | + var swiper = this; | |
| 4021 | + var params = swiper.params; | |
| 4022 | + var $el = swiper.$el; | |
| 4023 | + var $wrapperEl = swiper.$wrapperEl; | |
| 4024 | + var slides = swiper.slides; | |
| 4025 | + | |
| 4026 | + if (typeof swiper.params === 'undefined' || swiper.destroyed) { | |
| 4027 | + return null; | |
| 4028 | + } | |
| 4029 | + | |
| 4030 | + swiper.emit('beforeDestroy'); | |
| 4031 | + | |
| 4032 | + // Init Flag | |
| 4033 | + swiper.initialized = false; | |
| 4034 | + | |
| 4035 | + // Detach events | |
| 4036 | + swiper.detachEvents(); | |
| 4037 | + | |
| 4038 | + // Destroy loop | |
| 4039 | + if (params.loop) { | |
| 4040 | + swiper.loopDestroy(); | |
| 4041 | + } | |
| 4042 | + | |
| 4043 | + // Cleanup styles | |
| 4044 | + if (cleanStyles) { | |
| 4045 | + swiper.removeClasses(); | |
| 4046 | + $el.removeAttr('style'); | |
| 4047 | + $wrapperEl.removeAttr('style'); | |
| 4048 | + if (slides && slides.length) { | |
| 4049 | + slides | |
| 4050 | + .removeClass([ | |
| 4051 | + params.slideVisibleClass, | |
| 4052 | + params.slideActiveClass, | |
| 4053 | + params.slideNextClass, | |
| 4054 | + params.slidePrevClass ].join(' ')) | |
| 4055 | + .removeAttr('style') | |
| 4056 | + .removeAttr('data-swiper-slide-index') | |
| 4057 | + .removeAttr('data-swiper-column') | |
| 4058 | + .removeAttr('data-swiper-row'); | |
| 4059 | + } | |
| 4060 | + } | |
| 4061 | + | |
| 4062 | + swiper.emit('destroy'); | |
| 4063 | + | |
| 4064 | + // Detach emitter events | |
| 4065 | + Object.keys(swiper.eventsListeners).forEach(function (eventName) { | |
| 4066 | + swiper.off(eventName); | |
| 4067 | + }); | |
| 4068 | + | |
| 4069 | + if (deleteInstance !== false) { | |
| 4070 | + swiper.$el[0].swiper = null; | |
| 4071 | + swiper.$el.data('swiper', null); | |
| 4072 | + Utils.deleteProps(swiper); | |
| 4073 | + } | |
| 4074 | + swiper.destroyed = true; | |
| 4075 | + | |
| 4076 | + return null; | |
| 4077 | + }; | |
| 4078 | + | |
| 4079 | + Swiper.extendDefaults = function extendDefaults (newDefaults) { | |
| 4080 | + Utils.extend(extendedDefaults, newDefaults); | |
| 4081 | + }; | |
| 4082 | + | |
| 4083 | + staticAccessors.extendedDefaults.get = function () { | |
| 4084 | + return extendedDefaults; | |
| 4085 | + }; | |
| 4086 | + | |
| 4087 | + staticAccessors.defaults.get = function () { | |
| 4088 | + return defaults; | |
| 4089 | + }; | |
| 4090 | + | |
| 4091 | + staticAccessors.Class.get = function () { | |
| 4092 | + return SwiperClass$$1; | |
| 4093 | + }; | |
| 4094 | + | |
| 4095 | + staticAccessors.$.get = function () { | |
| 4096 | + return $; | |
| 4097 | + }; | |
| 4098 | + | |
| 4099 | + Object.defineProperties( Swiper, staticAccessors ); | |
| 4100 | + | |
| 4101 | + return Swiper; | |
| 4102 | + }(SwiperClass)); | |
| 4103 | + | |
| 4104 | + var Device$1 = { | |
| 4105 | + name: 'device', | |
| 4106 | + proto: { | |
| 4107 | + device: Device, | |
| 4108 | + }, | |
| 4109 | + static: { | |
| 4110 | + device: Device, | |
| 4111 | + }, | |
| 4112 | + }; | |
| 4113 | + | |
| 4114 | + var Support$1 = { | |
| 4115 | + name: 'support', | |
| 4116 | + proto: { | |
| 4117 | + support: Support, | |
| 4118 | + }, | |
| 4119 | + static: { | |
| 4120 | + support: Support, | |
| 4121 | + }, | |
| 4122 | + }; | |
| 4123 | + | |
| 4124 | + var Browser$1 = { | |
| 4125 | + name: 'browser', | |
| 4126 | + proto: { | |
| 4127 | + browser: Browser, | |
| 4128 | + }, | |
| 4129 | + static: { | |
| 4130 | + browser: Browser, | |
| 4131 | + }, | |
| 4132 | + }; | |
| 4133 | + | |
| 4134 | + var Resize = { | |
| 4135 | + name: 'resize', | |
| 4136 | + create: function create() { | |
| 4137 | + var swiper = this; | |
| 4138 | + Utils.extend(swiper, { | |
| 4139 | + resize: { | |
| 4140 | + resizeHandler: function resizeHandler() { | |
| 4141 | + if (!swiper || swiper.destroyed || !swiper.initialized) { return; } | |
| 4142 | + swiper.emit('beforeResize'); | |
| 4143 | + swiper.emit('resize'); | |
| 4144 | + }, | |
| 4145 | + orientationChangeHandler: function orientationChangeHandler() { | |
| 4146 | + if (!swiper || swiper.destroyed || !swiper.initialized) { return; } | |
| 4147 | + swiper.emit('orientationchange'); | |
| 4148 | + }, | |
| 4149 | + }, | |
| 4150 | + }); | |
| 4151 | + }, | |
| 4152 | + on: { | |
| 4153 | + init: function init() { | |
| 4154 | + var swiper = this; | |
| 4155 | + // Emit resize | |
| 4156 | + win.addEventListener('resize', swiper.resize.resizeHandler); | |
| 4157 | + | |
| 4158 | + // Emit orientationchange | |
| 4159 | + win.addEventListener('orientationchange', swiper.resize.orientationChangeHandler); | |
| 4160 | + }, | |
| 4161 | + destroy: function destroy() { | |
| 4162 | + var swiper = this; | |
| 4163 | + win.removeEventListener('resize', swiper.resize.resizeHandler); | |
| 4164 | + win.removeEventListener('orientationchange', swiper.resize.orientationChangeHandler); | |
| 4165 | + }, | |
| 4166 | + }, | |
| 4167 | + }; | |
| 4168 | + | |
| 4169 | + var Observer = { | |
| 4170 | + func: win.MutationObserver || win.WebkitMutationObserver, | |
| 4171 | + attach: function attach(target, options) { | |
| 4172 | + if ( options === void 0 ) options = {}; | |
| 4173 | + | |
| 4174 | + var swiper = this; | |
| 4175 | + | |
| 4176 | + var ObserverFunc = Observer.func; | |
| 4177 | + var observer = new ObserverFunc(function (mutations) { | |
| 4178 | + // The observerUpdate event should only be triggered | |
| 4179 | + // once despite the number of mutations. Additional | |
| 4180 | + // triggers are redundant and are very costly | |
| 4181 | + if (mutations.length === 1) { | |
| 4182 | + swiper.emit('observerUpdate', mutations[0]); | |
| 4183 | + return; | |
| 4184 | + } | |
| 4185 | + var observerUpdate = function observerUpdate() { | |
| 4186 | + swiper.emit('observerUpdate', mutations[0]); | |
| 4187 | + }; | |
| 4188 | + | |
| 4189 | + if (win.requestAnimationFrame) { | |
| 4190 | + win.requestAnimationFrame(observerUpdate); | |
| 4191 | + } else { | |
| 4192 | + win.setTimeout(observerUpdate, 0); | |
| 4193 | + } | |
| 4194 | + }); | |
| 4195 | + | |
| 4196 | + observer.observe(target, { | |
| 4197 | + attributes: typeof options.attributes === 'undefined' ? true : options.attributes, | |
| 4198 | + childList: typeof options.childList === 'undefined' ? true : options.childList, | |
| 4199 | + characterData: typeof options.characterData === 'undefined' ? true : options.characterData, | |
| 4200 | + }); | |
| 4201 | + | |
| 4202 | + swiper.observer.observers.push(observer); | |
| 4203 | + }, | |
| 4204 | + init: function init() { | |
| 4205 | + var swiper = this; | |
| 4206 | + if (!Support.observer || !swiper.params.observer) { return; } | |
| 4207 | + if (swiper.params.observeParents) { | |
| 4208 | + var containerParents = swiper.$el.parents(); | |
| 4209 | + for (var i = 0; i < containerParents.length; i += 1) { | |
| 4210 | + swiper.observer.attach(containerParents[i]); | |
| 4211 | + } | |
| 4212 | + } | |
| 4213 | + // Observe container | |
| 4214 | + swiper.observer.attach(swiper.$el[0], { childList: swiper.params.observeSlideChildren }); | |
| 4215 | + | |
| 4216 | + // Observe wrapper | |
| 4217 | + swiper.observer.attach(swiper.$wrapperEl[0], { attributes: false }); | |
| 4218 | + }, | |
| 4219 | + destroy: function destroy() { | |
| 4220 | + var swiper = this; | |
| 4221 | + swiper.observer.observers.forEach(function (observer) { | |
| 4222 | + observer.disconnect(); | |
| 4223 | + }); | |
| 4224 | + swiper.observer.observers = []; | |
| 4225 | + }, | |
| 4226 | + }; | |
| 4227 | + | |
| 4228 | + var Observer$1 = { | |
| 4229 | + name: 'observer', | |
| 4230 | + params: { | |
| 4231 | + observer: false, | |
| 4232 | + observeParents: false, | |
| 4233 | + observeSlideChildren: false, | |
| 4234 | + }, | |
| 4235 | + create: function create() { | |
| 4236 | + var swiper = this; | |
| 4237 | + Utils.extend(swiper, { | |
| 4238 | + observer: { | |
| 4239 | + init: Observer.init.bind(swiper), | |
| 4240 | + attach: Observer.attach.bind(swiper), | |
| 4241 | + destroy: Observer.destroy.bind(swiper), | |
| 4242 | + observers: [], | |
| 4243 | + }, | |
| 4244 | + }); | |
| 4245 | + }, | |
| 4246 | + on: { | |
| 4247 | + init: function init() { | |
| 4248 | + var swiper = this; | |
| 4249 | + swiper.observer.init(); | |
| 4250 | + }, | |
| 4251 | + destroy: function destroy() { | |
| 4252 | + var swiper = this; | |
| 4253 | + swiper.observer.destroy(); | |
| 4254 | + }, | |
| 4255 | + }, | |
| 4256 | + }; | |
| 4257 | + | |
| 4258 | + var Virtual = { | |
| 4259 | + update: function update(force) { | |
| 4260 | + var swiper = this; | |
| 4261 | + var ref = swiper.params; | |
| 4262 | + var slidesPerView = ref.slidesPerView; | |
| 4263 | + var slidesPerGroup = ref.slidesPerGroup; | |
| 4264 | + var centeredSlides = ref.centeredSlides; | |
| 4265 | + var ref$1 = swiper.params.virtual; | |
| 4266 | + var addSlidesBefore = ref$1.addSlidesBefore; | |
| 4267 | + var addSlidesAfter = ref$1.addSlidesAfter; | |
| 4268 | + var ref$2 = swiper.virtual; | |
| 4269 | + var previousFrom = ref$2.from; | |
| 4270 | + var previousTo = ref$2.to; | |
| 4271 | + var slides = ref$2.slides; | |
| 4272 | + var previousSlidesGrid = ref$2.slidesGrid; | |
| 4273 | + var renderSlide = ref$2.renderSlide; | |
| 4274 | + var previousOffset = ref$2.offset; | |
| 4275 | + swiper.updateActiveIndex(); | |
| 4276 | + var activeIndex = swiper.activeIndex || 0; | |
| 4277 | + | |
| 4278 | + var offsetProp; | |
| 4279 | + if (swiper.rtlTranslate) { offsetProp = 'right'; } | |
| 4280 | + else { offsetProp = swiper.isHorizontal() ? 'left' : 'top'; } | |
| 4281 | + | |
| 4282 | + var slidesAfter; | |
| 4283 | + var slidesBefore; | |
| 4284 | + if (centeredSlides) { | |
| 4285 | + slidesAfter = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesBefore; | |
| 4286 | + slidesBefore = Math.floor(slidesPerView / 2) + slidesPerGroup + addSlidesAfter; | |
| 4287 | + } else { | |
| 4288 | + slidesAfter = slidesPerView + (slidesPerGroup - 1) + addSlidesBefore; | |
| 4289 | + slidesBefore = slidesPerGroup + addSlidesAfter; | |
| 4290 | + } | |
| 4291 | + var from = Math.max((activeIndex || 0) - slidesBefore, 0); | |
| 4292 | + var to = Math.min((activeIndex || 0) + slidesAfter, slides.length - 1); | |
| 4293 | + var offset = (swiper.slidesGrid[from] || 0) - (swiper.slidesGrid[0] || 0); | |
| 4294 | + | |
| 4295 | + Utils.extend(swiper.virtual, { | |
| 4296 | + from: from, | |
| 4297 | + to: to, | |
| 4298 | + offset: offset, | |
| 4299 | + slidesGrid: swiper.slidesGrid, | |
| 4300 | + }); | |
| 4301 | + | |
| 4302 | + function onRendered() { | |
| 4303 | + swiper.updateSlides(); | |
| 4304 | + swiper.updateProgress(); | |
| 4305 | + swiper.updateSlidesClasses(); | |
| 4306 | + if (swiper.lazy && swiper.params.lazy.enabled) { | |
| 4307 | + swiper.lazy.load(); | |
| 4308 | + } | |
| 4309 | + } | |
| 4310 | + | |
| 4311 | + if (previousFrom === from && previousTo === to && !force) { | |
| 4312 | + if (swiper.slidesGrid !== previousSlidesGrid && offset !== previousOffset) { | |
| 4313 | + swiper.slides.css(offsetProp, (offset + "px")); | |
| 4314 | + } | |
| 4315 | + swiper.updateProgress(); | |
| 4316 | + return; | |
| 4317 | + } | |
| 4318 | + if (swiper.params.virtual.renderExternal) { | |
| 4319 | + swiper.params.virtual.renderExternal.call(swiper, { | |
| 4320 | + offset: offset, | |
| 4321 | + from: from, | |
| 4322 | + to: to, | |
| 4323 | + slides: (function getSlides() { | |
| 4324 | + var slidesToRender = []; | |
| 4325 | + for (var i = from; i <= to; i += 1) { | |
| 4326 | + slidesToRender.push(slides[i]); | |
| 4327 | + } | |
| 4328 | + return slidesToRender; | |
| 4329 | + }()), | |
| 4330 | + }); | |
| 4331 | + onRendered(); | |
| 4332 | + return; | |
| 4333 | + } | |
| 4334 | + var prependIndexes = []; | |
| 4335 | + var appendIndexes = []; | |
| 4336 | + if (force) { | |
| 4337 | + swiper.$wrapperEl.find(("." + (swiper.params.slideClass))).remove(); | |
| 4338 | + } else { | |
| 4339 | + for (var i = previousFrom; i <= previousTo; i += 1) { | |
| 4340 | + if (i < from || i > to) { | |
| 4341 | + swiper.$wrapperEl.find(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + i + "\"]")).remove(); | |
| 4342 | + } | |
| 4343 | + } | |
| 4344 | + } | |
| 4345 | + for (var i$1 = 0; i$1 < slides.length; i$1 += 1) { | |
| 4346 | + if (i$1 >= from && i$1 <= to) { | |
| 4347 | + if (typeof previousTo === 'undefined' || force) { | |
| 4348 | + appendIndexes.push(i$1); | |
| 4349 | + } else { | |
| 4350 | + if (i$1 > previousTo) { appendIndexes.push(i$1); } | |
| 4351 | + if (i$1 < previousFrom) { prependIndexes.push(i$1); } | |
| 4352 | + } | |
| 4353 | + } | |
| 4354 | + } | |
| 4355 | + appendIndexes.forEach(function (index) { | |
| 4356 | + swiper.$wrapperEl.append(renderSlide(slides[index], index)); | |
| 4357 | + }); | |
| 4358 | + prependIndexes.sort(function (a, b) { return b - a; }).forEach(function (index) { | |
| 4359 | + swiper.$wrapperEl.prepend(renderSlide(slides[index], index)); | |
| 4360 | + }); | |
| 4361 | + swiper.$wrapperEl.children('.swiper-slide').css(offsetProp, (offset + "px")); | |
| 4362 | + onRendered(); | |
| 4363 | + }, | |
| 4364 | + renderSlide: function renderSlide(slide, index) { | |
| 4365 | + var swiper = this; | |
| 4366 | + var params = swiper.params.virtual; | |
| 4367 | + if (params.cache && swiper.virtual.cache[index]) { | |
| 4368 | + return swiper.virtual.cache[index]; | |
| 4369 | + } | |
| 4370 | + var $slideEl = params.renderSlide | |
| 4371 | + ? $(params.renderSlide.call(swiper, slide, index)) | |
| 4372 | + : $(("<div class=\"" + (swiper.params.slideClass) + "\" data-swiper-slide-index=\"" + index + "\">" + slide + "</div>")); | |
| 4373 | + if (!$slideEl.attr('data-swiper-slide-index')) { $slideEl.attr('data-swiper-slide-index', index); } | |
| 4374 | + if (params.cache) { swiper.virtual.cache[index] = $slideEl; } | |
| 4375 | + return $slideEl; | |
| 4376 | + }, | |
| 4377 | + appendSlide: function appendSlide(slide) { | |
| 4378 | + var swiper = this; | |
| 4379 | + swiper.virtual.slides.push(slide); | |
| 4380 | + swiper.virtual.update(true); | |
| 4381 | + }, | |
| 4382 | + prependSlide: function prependSlide(slide) { | |
| 4383 | + var swiper = this; | |
| 4384 | + swiper.virtual.slides.unshift(slide); | |
| 4385 | + if (swiper.params.virtual.cache) { | |
| 4386 | + var cache = swiper.virtual.cache; | |
| 4387 | + var newCache = {}; | |
| 4388 | + Object.keys(cache).forEach(function (cachedIndex) { | |
| 4389 | + newCache[cachedIndex + 1] = cache[cachedIndex]; | |
| 4390 | + }); | |
| 4391 | + swiper.virtual.cache = newCache; | |
| 4392 | + } | |
| 4393 | + swiper.virtual.update(true); | |
| 4394 | + swiper.slideNext(0); | |
| 4395 | + }, | |
| 4396 | + }; | |
| 4397 | + | |
| 4398 | + var Virtual$1 = { | |
| 4399 | + name: 'virtual', | |
| 4400 | + params: { | |
| 4401 | + virtual: { | |
| 4402 | + enabled: false, | |
| 4403 | + slides: [], | |
| 4404 | + cache: true, | |
| 4405 | + renderSlide: null, | |
| 4406 | + renderExternal: null, | |
| 4407 | + addSlidesBefore: 0, | |
| 4408 | + addSlidesAfter: 0, | |
| 4409 | + }, | |
| 4410 | + }, | |
| 4411 | + create: function create() { | |
| 4412 | + var swiper = this; | |
| 4413 | + Utils.extend(swiper, { | |
| 4414 | + virtual: { | |
| 4415 | + update: Virtual.update.bind(swiper), | |
| 4416 | + appendSlide: Virtual.appendSlide.bind(swiper), | |
| 4417 | + prependSlide: Virtual.prependSlide.bind(swiper), | |
| 4418 | + renderSlide: Virtual.renderSlide.bind(swiper), | |
| 4419 | + slides: swiper.params.virtual.slides, | |
| 4420 | + cache: {}, | |
| 4421 | + }, | |
| 4422 | + }); | |
| 4423 | + }, | |
| 4424 | + on: { | |
| 4425 | + beforeInit: function beforeInit() { | |
| 4426 | + var swiper = this; | |
| 4427 | + if (!swiper.params.virtual.enabled) { return; } | |
| 4428 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "virtual")); | |
| 4429 | + var overwriteParams = { | |
| 4430 | + watchSlidesProgress: true, | |
| 4431 | + }; | |
| 4432 | + Utils.extend(swiper.params, overwriteParams); | |
| 4433 | + Utils.extend(swiper.originalParams, overwriteParams); | |
| 4434 | + | |
| 4435 | + if (!swiper.params.initialSlide) { | |
| 4436 | + swiper.virtual.update(); | |
| 4437 | + } | |
| 4438 | + }, | |
| 4439 | + setTranslate: function setTranslate() { | |
| 4440 | + var swiper = this; | |
| 4441 | + if (!swiper.params.virtual.enabled) { return; } | |
| 4442 | + swiper.virtual.update(); | |
| 4443 | + }, | |
| 4444 | + }, | |
| 4445 | + }; | |
| 4446 | + | |
| 4447 | + var Keyboard = { | |
| 4448 | + handle: function handle(event) { | |
| 4449 | + var swiper = this; | |
| 4450 | + var rtl = swiper.rtlTranslate; | |
| 4451 | + var e = event; | |
| 4452 | + if (e.originalEvent) { e = e.originalEvent; } // jquery fix | |
| 4453 | + var kc = e.keyCode || e.charCode; | |
| 4454 | + // Directions locks | |
| 4455 | + if (!swiper.allowSlideNext && ((swiper.isHorizontal() && kc === 39) || (swiper.isVertical() && kc === 40))) { | |
| 4456 | + return false; | |
| 4457 | + } | |
| 4458 | + if (!swiper.allowSlidePrev && ((swiper.isHorizontal() && kc === 37) || (swiper.isVertical() && kc === 38))) { | |
| 4459 | + return false; | |
| 4460 | + } | |
| 4461 | + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { | |
| 4462 | + return undefined; | |
| 4463 | + } | |
| 4464 | + if (doc.activeElement && doc.activeElement.nodeName && (doc.activeElement.nodeName.toLowerCase() === 'input' || doc.activeElement.nodeName.toLowerCase() === 'textarea')) { | |
| 4465 | + return undefined; | |
| 4466 | + } | |
| 4467 | + if (swiper.params.keyboard.onlyInViewport && (kc === 37 || kc === 39 || kc === 38 || kc === 40)) { | |
| 4468 | + var inView = false; | |
| 4469 | + // Check that swiper should be inside of visible area of window | |
| 4470 | + if (swiper.$el.parents(("." + (swiper.params.slideClass))).length > 0 && swiper.$el.parents(("." + (swiper.params.slideActiveClass))).length === 0) { | |
| 4471 | + return undefined; | |
| 4472 | + } | |
| 4473 | + var windowWidth = win.innerWidth; | |
| 4474 | + var windowHeight = win.innerHeight; | |
| 4475 | + var swiperOffset = swiper.$el.offset(); | |
| 4476 | + if (rtl) { swiperOffset.left -= swiper.$el[0].scrollLeft; } | |
| 4477 | + var swiperCoord = [ | |
| 4478 | + [swiperOffset.left, swiperOffset.top], | |
| 4479 | + [swiperOffset.left + swiper.width, swiperOffset.top], | |
| 4480 | + [swiperOffset.left, swiperOffset.top + swiper.height], | |
| 4481 | + [swiperOffset.left + swiper.width, swiperOffset.top + swiper.height] ]; | |
| 4482 | + for (var i = 0; i < swiperCoord.length; i += 1) { | |
| 4483 | + var point = swiperCoord[i]; | |
| 4484 | + if ( | |
| 4485 | + point[0] >= 0 && point[0] <= windowWidth | |
| 4486 | + && point[1] >= 0 && point[1] <= windowHeight | |
| 4487 | + ) { | |
| 4488 | + inView = true; | |
| 4489 | + } | |
| 4490 | + } | |
| 4491 | + if (!inView) { return undefined; } | |
| 4492 | + } | |
| 4493 | + if (swiper.isHorizontal()) { | |
| 4494 | + if (kc === 37 || kc === 39) { | |
| 4495 | + if (e.preventDefault) { e.preventDefault(); } | |
| 4496 | + else { e.returnValue = false; } | |
| 4497 | + } | |
| 4498 | + if ((kc === 39 && !rtl) || (kc === 37 && rtl)) { swiper.slideNext(); } | |
| 4499 | + if ((kc === 37 && !rtl) || (kc === 39 && rtl)) { swiper.slidePrev(); } | |
| 4500 | + } else { | |
| 4501 | + if (kc === 38 || kc === 40) { | |
| 4502 | + if (e.preventDefault) { e.preventDefault(); } | |
| 4503 | + else { e.returnValue = false; } | |
| 4504 | + } | |
| 4505 | + if (kc === 40) { swiper.slideNext(); } | |
| 4506 | + if (kc === 38) { swiper.slidePrev(); } | |
| 4507 | + } | |
| 4508 | + swiper.emit('keyPress', kc); | |
| 4509 | + return undefined; | |
| 4510 | + }, | |
| 4511 | + enable: function enable() { | |
| 4512 | + var swiper = this; | |
| 4513 | + if (swiper.keyboard.enabled) { return; } | |
| 4514 | + $(doc).on('keydown', swiper.keyboard.handle); | |
| 4515 | + swiper.keyboard.enabled = true; | |
| 4516 | + }, | |
| 4517 | + disable: function disable() { | |
| 4518 | + var swiper = this; | |
| 4519 | + if (!swiper.keyboard.enabled) { return; } | |
| 4520 | + $(doc).off('keydown', swiper.keyboard.handle); | |
| 4521 | + swiper.keyboard.enabled = false; | |
| 4522 | + }, | |
| 4523 | + }; | |
| 4524 | + | |
| 4525 | + var Keyboard$1 = { | |
| 4526 | + name: 'keyboard', | |
| 4527 | + params: { | |
| 4528 | + keyboard: { | |
| 4529 | + enabled: false, | |
| 4530 | + onlyInViewport: true, | |
| 4531 | + }, | |
| 4532 | + }, | |
| 4533 | + create: function create() { | |
| 4534 | + var swiper = this; | |
| 4535 | + Utils.extend(swiper, { | |
| 4536 | + keyboard: { | |
| 4537 | + enabled: false, | |
| 4538 | + enable: Keyboard.enable.bind(swiper), | |
| 4539 | + disable: Keyboard.disable.bind(swiper), | |
| 4540 | + handle: Keyboard.handle.bind(swiper), | |
| 4541 | + }, | |
| 4542 | + }); | |
| 4543 | + }, | |
| 4544 | + on: { | |
| 4545 | + init: function init() { | |
| 4546 | + var swiper = this; | |
| 4547 | + if (swiper.params.keyboard.enabled) { | |
| 4548 | + swiper.keyboard.enable(); | |
| 4549 | + } | |
| 4550 | + }, | |
| 4551 | + destroy: function destroy() { | |
| 4552 | + var swiper = this; | |
| 4553 | + if (swiper.keyboard.enabled) { | |
| 4554 | + swiper.keyboard.disable(); | |
| 4555 | + } | |
| 4556 | + }, | |
| 4557 | + }, | |
| 4558 | + }; | |
| 4559 | + | |
| 4560 | + function isEventSupported() { | |
| 4561 | + var eventName = 'onwheel'; | |
| 4562 | + var isSupported = eventName in doc; | |
| 4563 | + | |
| 4564 | + if (!isSupported) { | |
| 4565 | + var element = doc.createElement('div'); | |
| 4566 | + element.setAttribute(eventName, 'return;'); | |
| 4567 | + isSupported = typeof element[eventName] === 'function'; | |
| 4568 | + } | |
| 4569 | + | |
| 4570 | + if (!isSupported | |
| 4571 | + && doc.implementation | |
| 4572 | + && doc.implementation.hasFeature | |
| 4573 | + // always returns true in newer browsers as per the standard. | |
| 4574 | + // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature | |
| 4575 | + && doc.implementation.hasFeature('', '') !== true | |
| 4576 | + ) { | |
| 4577 | + // This is the only way to test support for the `wheel` event in IE9+. | |
| 4578 | + isSupported = doc.implementation.hasFeature('Events.wheel', '3.0'); | |
| 4579 | + } | |
| 4580 | + | |
| 4581 | + return isSupported; | |
| 4582 | + } | |
| 4583 | + var Mousewheel = { | |
| 4584 | + lastScrollTime: Utils.now(), | |
| 4585 | + event: (function getEvent() { | |
| 4586 | + if (win.navigator.userAgent.indexOf('firefox') > -1) { return 'DOMMouseScroll'; } | |
| 4587 | + return isEventSupported() ? 'wheel' : 'mousewheel'; | |
| 4588 | + }()), | |
| 4589 | + normalize: function normalize(e) { | |
| 4590 | + // Reasonable defaults | |
| 4591 | + var PIXEL_STEP = 10; | |
| 4592 | + var LINE_HEIGHT = 40; | |
| 4593 | + var PAGE_HEIGHT = 800; | |
| 4594 | + | |
| 4595 | + var sX = 0; | |
| 4596 | + var sY = 0; // spinX, spinY | |
| 4597 | + var pX = 0; | |
| 4598 | + var pY = 0; // pixelX, pixelY | |
| 4599 | + | |
| 4600 | + // Legacy | |
| 4601 | + if ('detail' in e) { | |
| 4602 | + sY = e.detail; | |
| 4603 | + } | |
| 4604 | + if ('wheelDelta' in e) { | |
| 4605 | + sY = -e.wheelDelta / 120; | |
| 4606 | + } | |
| 4607 | + if ('wheelDeltaY' in e) { | |
| 4608 | + sY = -e.wheelDeltaY / 120; | |
| 4609 | + } | |
| 4610 | + if ('wheelDeltaX' in e) { | |
| 4611 | + sX = -e.wheelDeltaX / 120; | |
| 4612 | + } | |
| 4613 | + | |
| 4614 | + // side scrolling on FF with DOMMouseScroll | |
| 4615 | + if ('axis' in e && e.axis === e.HORIZONTAL_AXIS) { | |
| 4616 | + sX = sY; | |
| 4617 | + sY = 0; | |
| 4618 | + } | |
| 4619 | + | |
| 4620 | + pX = sX * PIXEL_STEP; | |
| 4621 | + pY = sY * PIXEL_STEP; | |
| 4622 | + | |
| 4623 | + if ('deltaY' in e) { | |
| 4624 | + pY = e.deltaY; | |
| 4625 | + } | |
| 4626 | + if ('deltaX' in e) { | |
| 4627 | + pX = e.deltaX; | |
| 4628 | + } | |
| 4629 | + | |
| 4630 | + if ((pX || pY) && e.deltaMode) { | |
| 4631 | + if (e.deltaMode === 1) { // delta in LINE units | |
| 4632 | + pX *= LINE_HEIGHT; | |
| 4633 | + pY *= LINE_HEIGHT; | |
| 4634 | + } else { // delta in PAGE units | |
| 4635 | + pX *= PAGE_HEIGHT; | |
| 4636 | + pY *= PAGE_HEIGHT; | |
| 4637 | + } | |
| 4638 | + } | |
| 4639 | + | |
| 4640 | + // Fall-back if spin cannot be determined | |
| 4641 | + if (pX && !sX) { | |
| 4642 | + sX = (pX < 1) ? -1 : 1; | |
| 4643 | + } | |
| 4644 | + if (pY && !sY) { | |
| 4645 | + sY = (pY < 1) ? -1 : 1; | |
| 4646 | + } | |
| 4647 | + | |
| 4648 | + return { | |
| 4649 | + spinX: sX, | |
| 4650 | + spinY: sY, | |
| 4651 | + pixelX: pX, | |
| 4652 | + pixelY: pY, | |
| 4653 | + }; | |
| 4654 | + }, | |
| 4655 | + handleMouseEnter: function handleMouseEnter() { | |
| 4656 | + var swiper = this; | |
| 4657 | + swiper.mouseEntered = true; | |
| 4658 | + }, | |
| 4659 | + handleMouseLeave: function handleMouseLeave() { | |
| 4660 | + var swiper = this; | |
| 4661 | + swiper.mouseEntered = false; | |
| 4662 | + }, | |
| 4663 | + handle: function handle(event) { | |
| 4664 | + var e = event; | |
| 4665 | + var swiper = this; | |
| 4666 | + var params = swiper.params.mousewheel; | |
| 4667 | + | |
| 4668 | + if (!swiper.mouseEntered && !params.releaseOnEdges) { return true; } | |
| 4669 | + | |
| 4670 | + if (e.originalEvent) { e = e.originalEvent; } // jquery fix | |
| 4671 | + var delta = 0; | |
| 4672 | + var rtlFactor = swiper.rtlTranslate ? -1 : 1; | |
| 4673 | + | |
| 4674 | + var data = Mousewheel.normalize(e); | |
| 4675 | + | |
| 4676 | + if (params.forceToAxis) { | |
| 4677 | + if (swiper.isHorizontal()) { | |
| 4678 | + if (Math.abs(data.pixelX) > Math.abs(data.pixelY)) { delta = data.pixelX * rtlFactor; } | |
| 4679 | + else { return true; } | |
| 4680 | + } else if (Math.abs(data.pixelY) > Math.abs(data.pixelX)) { delta = data.pixelY; } | |
| 4681 | + else { return true; } | |
| 4682 | + } else { | |
| 4683 | + delta = Math.abs(data.pixelX) > Math.abs(data.pixelY) ? -data.pixelX * rtlFactor : -data.pixelY; | |
| 4684 | + } | |
| 4685 | + | |
| 4686 | + if (delta === 0) { return true; } | |
| 4687 | + | |
| 4688 | + if (params.invert) { delta = -delta; } | |
| 4689 | + | |
| 4690 | + if (!swiper.params.freeMode) { | |
| 4691 | + if (Utils.now() - swiper.mousewheel.lastScrollTime > 60) { | |
| 4692 | + if (delta < 0) { | |
| 4693 | + if ((!swiper.isEnd || swiper.params.loop) && !swiper.animating) { | |
| 4694 | + swiper.slideNext(); | |
| 4695 | + swiper.emit('scroll', e); | |
| 4696 | + } else if (params.releaseOnEdges) { return true; } | |
| 4697 | + } else if ((!swiper.isBeginning || swiper.params.loop) && !swiper.animating) { | |
| 4698 | + swiper.slidePrev(); | |
| 4699 | + swiper.emit('scroll', e); | |
| 4700 | + } else if (params.releaseOnEdges) { return true; } | |
| 4701 | + } | |
| 4702 | + swiper.mousewheel.lastScrollTime = (new win.Date()).getTime(); | |
| 4703 | + } else { | |
| 4704 | + // Freemode or scrollContainer: | |
| 4705 | + if (swiper.params.loop) { | |
| 4706 | + swiper.loopFix(); | |
| 4707 | + } | |
| 4708 | + var position = swiper.getTranslate() + (delta * params.sensitivity); | |
| 4709 | + var wasBeginning = swiper.isBeginning; | |
| 4710 | + var wasEnd = swiper.isEnd; | |
| 4711 | + | |
| 4712 | + if (position >= swiper.minTranslate()) { position = swiper.minTranslate(); } | |
| 4713 | + if (position <= swiper.maxTranslate()) { position = swiper.maxTranslate(); } | |
| 4714 | + | |
| 4715 | + swiper.setTransition(0); | |
| 4716 | + swiper.setTranslate(position); | |
| 4717 | + swiper.updateProgress(); | |
| 4718 | + swiper.updateActiveIndex(); | |
| 4719 | + swiper.updateSlidesClasses(); | |
| 4720 | + | |
| 4721 | + if ((!wasBeginning && swiper.isBeginning) || (!wasEnd && swiper.isEnd)) { | |
| 4722 | + swiper.updateSlidesClasses(); | |
| 4723 | + } | |
| 4724 | + | |
| 4725 | + if (swiper.params.freeModeSticky) { | |
| 4726 | + clearTimeout(swiper.mousewheel.timeout); | |
| 4727 | + swiper.mousewheel.timeout = Utils.nextTick(function () { | |
| 4728 | + swiper.slideToClosest(); | |
| 4729 | + }, 300); | |
| 4730 | + } | |
| 4731 | + // Emit event | |
| 4732 | + swiper.emit('scroll', e); | |
| 4733 | + | |
| 4734 | + // Stop autoplay | |
| 4735 | + if (swiper.params.autoplay && swiper.params.autoplayDisableOnInteraction) { swiper.autoplay.stop(); } | |
| 4736 | + // Return page scroll on edge positions | |
| 4737 | + if (position === swiper.minTranslate() || position === swiper.maxTranslate()) { return true; } | |
| 4738 | + } | |
| 4739 | + | |
| 4740 | + if (e.preventDefault) { e.preventDefault(); } | |
| 4741 | + else { e.returnValue = false; } | |
| 4742 | + return false; | |
| 4743 | + }, | |
| 4744 | + enable: function enable() { | |
| 4745 | + var swiper = this; | |
| 4746 | + if (!Mousewheel.event) { return false; } | |
| 4747 | + if (swiper.mousewheel.enabled) { return false; } | |
| 4748 | + var target = swiper.$el; | |
| 4749 | + if (swiper.params.mousewheel.eventsTarged !== 'container') { | |
| 4750 | + target = $(swiper.params.mousewheel.eventsTarged); | |
| 4751 | + } | |
| 4752 | + target.on('mouseenter', swiper.mousewheel.handleMouseEnter); | |
| 4753 | + target.on('mouseleave', swiper.mousewheel.handleMouseLeave); | |
| 4754 | + target.on(Mousewheel.event, swiper.mousewheel.handle); | |
| 4755 | + swiper.mousewheel.enabled = true; | |
| 4756 | + return true; | |
| 4757 | + }, | |
| 4758 | + disable: function disable() { | |
| 4759 | + var swiper = this; | |
| 4760 | + if (!Mousewheel.event) { return false; } | |
| 4761 | + if (!swiper.mousewheel.enabled) { return false; } | |
| 4762 | + var target = swiper.$el; | |
| 4763 | + if (swiper.params.mousewheel.eventsTarged !== 'container') { | |
| 4764 | + target = $(swiper.params.mousewheel.eventsTarged); | |
| 4765 | + } | |
| 4766 | + target.off(Mousewheel.event, swiper.mousewheel.handle); | |
| 4767 | + swiper.mousewheel.enabled = false; | |
| 4768 | + return true; | |
| 4769 | + }, | |
| 4770 | + }; | |
| 4771 | + | |
| 4772 | + var Mousewheel$1 = { | |
| 4773 | + name: 'mousewheel', | |
| 4774 | + params: { | |
| 4775 | + mousewheel: { | |
| 4776 | + enabled: false, | |
| 4777 | + releaseOnEdges: false, | |
| 4778 | + invert: false, | |
| 4779 | + forceToAxis: false, | |
| 4780 | + sensitivity: 1, | |
| 4781 | + eventsTarged: 'container', | |
| 4782 | + }, | |
| 4783 | + }, | |
| 4784 | + create: function create() { | |
| 4785 | + var swiper = this; | |
| 4786 | + Utils.extend(swiper, { | |
| 4787 | + mousewheel: { | |
| 4788 | + enabled: false, | |
| 4789 | + enable: Mousewheel.enable.bind(swiper), | |
| 4790 | + disable: Mousewheel.disable.bind(swiper), | |
| 4791 | + handle: Mousewheel.handle.bind(swiper), | |
| 4792 | + handleMouseEnter: Mousewheel.handleMouseEnter.bind(swiper), | |
| 4793 | + handleMouseLeave: Mousewheel.handleMouseLeave.bind(swiper), | |
| 4794 | + lastScrollTime: Utils.now(), | |
| 4795 | + }, | |
| 4796 | + }); | |
| 4797 | + }, | |
| 4798 | + on: { | |
| 4799 | + init: function init() { | |
| 4800 | + var swiper = this; | |
| 4801 | + if (swiper.params.mousewheel.enabled) { swiper.mousewheel.enable(); } | |
| 4802 | + }, | |
| 4803 | + destroy: function destroy() { | |
| 4804 | + var swiper = this; | |
| 4805 | + if (swiper.mousewheel.enabled) { swiper.mousewheel.disable(); } | |
| 4806 | + }, | |
| 4807 | + }, | |
| 4808 | + }; | |
| 4809 | + | |
| 4810 | + var Navigation = { | |
| 4811 | + update: function update() { | |
| 4812 | + // Update Navigation Buttons | |
| 4813 | + var swiper = this; | |
| 4814 | + var params = swiper.params.navigation; | |
| 4815 | + | |
| 4816 | + if (swiper.params.loop) { return; } | |
| 4817 | + var ref = swiper.navigation; | |
| 4818 | + var $nextEl = ref.$nextEl; | |
| 4819 | + var $prevEl = ref.$prevEl; | |
| 4820 | + | |
| 4821 | + if ($prevEl && $prevEl.length > 0) { | |
| 4822 | + if (swiper.isBeginning) { | |
| 4823 | + $prevEl.addClass(params.disabledClass); | |
| 4824 | + } else { | |
| 4825 | + $prevEl.removeClass(params.disabledClass); | |
| 4826 | + } | |
| 4827 | + $prevEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); | |
| 4828 | + } | |
| 4829 | + if ($nextEl && $nextEl.length > 0) { | |
| 4830 | + if (swiper.isEnd) { | |
| 4831 | + $nextEl.addClass(params.disabledClass); | |
| 4832 | + } else { | |
| 4833 | + $nextEl.removeClass(params.disabledClass); | |
| 4834 | + } | |
| 4835 | + $nextEl[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); | |
| 4836 | + } | |
| 4837 | + }, | |
| 4838 | + onPrevClick: function onPrevClick(e) { | |
| 4839 | + var swiper = this; | |
| 4840 | + e.preventDefault(); | |
| 4841 | + if (swiper.isBeginning && !swiper.params.loop) { return; } | |
| 4842 | + swiper.slidePrev(); | |
| 4843 | + }, | |
| 4844 | + onNextClick: function onNextClick(e) { | |
| 4845 | + var swiper = this; | |
| 4846 | + e.preventDefault(); | |
| 4847 | + if (swiper.isEnd && !swiper.params.loop) { return; } | |
| 4848 | + swiper.slideNext(); | |
| 4849 | + }, | |
| 4850 | + init: function init() { | |
| 4851 | + var swiper = this; | |
| 4852 | + var params = swiper.params.navigation; | |
| 4853 | + if (!(params.nextEl || params.prevEl)) { return; } | |
| 4854 | + | |
| 4855 | + var $nextEl; | |
| 4856 | + var $prevEl; | |
| 4857 | + if (params.nextEl) { | |
| 4858 | + $nextEl = $(params.nextEl); | |
| 4859 | + if ( | |
| 4860 | + swiper.params.uniqueNavElements | |
| 4861 | + && typeof params.nextEl === 'string' | |
| 4862 | + && $nextEl.length > 1 | |
| 4863 | + && swiper.$el.find(params.nextEl).length === 1 | |
| 4864 | + ) { | |
| 4865 | + $nextEl = swiper.$el.find(params.nextEl); | |
| 4866 | + } | |
| 4867 | + } | |
| 4868 | + if (params.prevEl) { | |
| 4869 | + $prevEl = $(params.prevEl); | |
| 4870 | + if ( | |
| 4871 | + swiper.params.uniqueNavElements | |
| 4872 | + && typeof params.prevEl === 'string' | |
| 4873 | + && $prevEl.length > 1 | |
| 4874 | + && swiper.$el.find(params.prevEl).length === 1 | |
| 4875 | + ) { | |
| 4876 | + $prevEl = swiper.$el.find(params.prevEl); | |
| 4877 | + } | |
| 4878 | + } | |
| 4879 | + | |
| 4880 | + if ($nextEl && $nextEl.length > 0) { | |
| 4881 | + $nextEl.on('click', swiper.navigation.onNextClick); | |
| 4882 | + } | |
| 4883 | + if ($prevEl && $prevEl.length > 0) { | |
| 4884 | + $prevEl.on('click', swiper.navigation.onPrevClick); | |
| 4885 | + } | |
| 4886 | + | |
| 4887 | + Utils.extend(swiper.navigation, { | |
| 4888 | + $nextEl: $nextEl, | |
| 4889 | + nextEl: $nextEl && $nextEl[0], | |
| 4890 | + $prevEl: $prevEl, | |
| 4891 | + prevEl: $prevEl && $prevEl[0], | |
| 4892 | + }); | |
| 4893 | + }, | |
| 4894 | + destroy: function destroy() { | |
| 4895 | + var swiper = this; | |
| 4896 | + var ref = swiper.navigation; | |
| 4897 | + var $nextEl = ref.$nextEl; | |
| 4898 | + var $prevEl = ref.$prevEl; | |
| 4899 | + if ($nextEl && $nextEl.length) { | |
| 4900 | + $nextEl.off('click', swiper.navigation.onNextClick); | |
| 4901 | + $nextEl.removeClass(swiper.params.navigation.disabledClass); | |
| 4902 | + } | |
| 4903 | + if ($prevEl && $prevEl.length) { | |
| 4904 | + $prevEl.off('click', swiper.navigation.onPrevClick); | |
| 4905 | + $prevEl.removeClass(swiper.params.navigation.disabledClass); | |
| 4906 | + } | |
| 4907 | + }, | |
| 4908 | + }; | |
| 4909 | + | |
| 4910 | + var Navigation$1 = { | |
| 4911 | + name: 'navigation', | |
| 4912 | + params: { | |
| 4913 | + navigation: { | |
| 4914 | + nextEl: null, | |
| 4915 | + prevEl: null, | |
| 4916 | + | |
| 4917 | + hideOnClick: false, | |
| 4918 | + disabledClass: 'swiper-button-disabled', | |
| 4919 | + hiddenClass: 'swiper-button-hidden', | |
| 4920 | + lockClass: 'swiper-button-lock', | |
| 4921 | + }, | |
| 4922 | + }, | |
| 4923 | + create: function create() { | |
| 4924 | + var swiper = this; | |
| 4925 | + Utils.extend(swiper, { | |
| 4926 | + navigation: { | |
| 4927 | + init: Navigation.init.bind(swiper), | |
| 4928 | + update: Navigation.update.bind(swiper), | |
| 4929 | + destroy: Navigation.destroy.bind(swiper), | |
| 4930 | + onNextClick: Navigation.onNextClick.bind(swiper), | |
| 4931 | + onPrevClick: Navigation.onPrevClick.bind(swiper), | |
| 4932 | + }, | |
| 4933 | + }); | |
| 4934 | + }, | |
| 4935 | + on: { | |
| 4936 | + init: function init() { | |
| 4937 | + var swiper = this; | |
| 4938 | + swiper.navigation.init(); | |
| 4939 | + swiper.navigation.update(); | |
| 4940 | + }, | |
| 4941 | + toEdge: function toEdge() { | |
| 4942 | + var swiper = this; | |
| 4943 | + swiper.navigation.update(); | |
| 4944 | + }, | |
| 4945 | + fromEdge: function fromEdge() { | |
| 4946 | + var swiper = this; | |
| 4947 | + swiper.navigation.update(); | |
| 4948 | + }, | |
| 4949 | + destroy: function destroy() { | |
| 4950 | + var swiper = this; | |
| 4951 | + swiper.navigation.destroy(); | |
| 4952 | + }, | |
| 4953 | + click: function click(e) { | |
| 4954 | + var swiper = this; | |
| 4955 | + var ref = swiper.navigation; | |
| 4956 | + var $nextEl = ref.$nextEl; | |
| 4957 | + var $prevEl = ref.$prevEl; | |
| 4958 | + if ( | |
| 4959 | + swiper.params.navigation.hideOnClick | |
| 4960 | + && !$(e.target).is($prevEl) | |
| 4961 | + && !$(e.target).is($nextEl) | |
| 4962 | + ) { | |
| 4963 | + if ($nextEl) { $nextEl.toggleClass(swiper.params.navigation.hiddenClass); } | |
| 4964 | + if ($prevEl) { $prevEl.toggleClass(swiper.params.navigation.hiddenClass); } | |
| 4965 | + } | |
| 4966 | + }, | |
| 4967 | + }, | |
| 4968 | + }; | |
| 4969 | + | |
| 4970 | + var Pagination = { | |
| 4971 | + update: function update() { | |
| 4972 | + // Render || Update Pagination bullets/items | |
| 4973 | + var swiper = this; | |
| 4974 | + var rtl = swiper.rtl; | |
| 4975 | + var params = swiper.params.pagination; | |
| 4976 | + if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } | |
| 4977 | + var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; | |
| 4978 | + var $el = swiper.pagination.$el; | |
| 4979 | + // Current/Total | |
| 4980 | + var current; | |
| 4981 | + var total = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; | |
| 4982 | + if (swiper.params.loop) { | |
| 4983 | + current = Math.ceil((swiper.activeIndex - swiper.loopedSlides) / swiper.params.slidesPerGroup); | |
| 4984 | + if (current > slidesLength - 1 - (swiper.loopedSlides * 2)) { | |
| 4985 | + current -= (slidesLength - (swiper.loopedSlides * 2)); | |
| 4986 | + } | |
| 4987 | + if (current > total - 1) { current -= total; } | |
| 4988 | + if (current < 0 && swiper.params.paginationType !== 'bullets') { current = total + current; } | |
| 4989 | + } else if (typeof swiper.snapIndex !== 'undefined') { | |
| 4990 | + current = swiper.snapIndex; | |
| 4991 | + } else { | |
| 4992 | + current = swiper.activeIndex || 0; | |
| 4993 | + } | |
| 4994 | + // Types | |
| 4995 | + if (params.type === 'bullets' && swiper.pagination.bullets && swiper.pagination.bullets.length > 0) { | |
| 4996 | + var bullets = swiper.pagination.bullets; | |
| 4997 | + var firstIndex; | |
| 4998 | + var lastIndex; | |
| 4999 | + var midIndex; | |
| 5000 | + if (params.dynamicBullets) { | |
| 5001 | + swiper.pagination.bulletSize = bullets.eq(0)[swiper.isHorizontal() ? 'outerWidth' : 'outerHeight'](true); | |
| 5002 | + $el.css(swiper.isHorizontal() ? 'width' : 'height', ((swiper.pagination.bulletSize * (params.dynamicMainBullets + 4)) + "px")); | |
| 5003 | + if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) { | |
| 5004 | + swiper.pagination.dynamicBulletIndex += (current - swiper.previousIndex); | |
| 5005 | + if (swiper.pagination.dynamicBulletIndex > (params.dynamicMainBullets - 1)) { | |
| 5006 | + swiper.pagination.dynamicBulletIndex = params.dynamicMainBullets - 1; | |
| 5007 | + } else if (swiper.pagination.dynamicBulletIndex < 0) { | |
| 5008 | + swiper.pagination.dynamicBulletIndex = 0; | |
| 5009 | + } | |
| 5010 | + } | |
| 5011 | + firstIndex = current - swiper.pagination.dynamicBulletIndex; | |
| 5012 | + lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1); | |
| 5013 | + midIndex = (lastIndex + firstIndex) / 2; | |
| 5014 | + } | |
| 5015 | + bullets.removeClass(((params.bulletActiveClass) + " " + (params.bulletActiveClass) + "-next " + (params.bulletActiveClass) + "-next-next " + (params.bulletActiveClass) + "-prev " + (params.bulletActiveClass) + "-prev-prev " + (params.bulletActiveClass) + "-main")); | |
| 5016 | + if ($el.length > 1) { | |
| 5017 | + bullets.each(function (index, bullet) { | |
| 5018 | + var $bullet = $(bullet); | |
| 5019 | + var bulletIndex = $bullet.index(); | |
| 5020 | + if (bulletIndex === current) { | |
| 5021 | + $bullet.addClass(params.bulletActiveClass); | |
| 5022 | + } | |
| 5023 | + if (params.dynamicBullets) { | |
| 5024 | + if (bulletIndex >= firstIndex && bulletIndex <= lastIndex) { | |
| 5025 | + $bullet.addClass(((params.bulletActiveClass) + "-main")); | |
| 5026 | + } | |
| 5027 | + if (bulletIndex === firstIndex) { | |
| 5028 | + $bullet | |
| 5029 | + .prev() | |
| 5030 | + .addClass(((params.bulletActiveClass) + "-prev")) | |
| 5031 | + .prev() | |
| 5032 | + .addClass(((params.bulletActiveClass) + "-prev-prev")); | |
| 5033 | + } | |
| 5034 | + if (bulletIndex === lastIndex) { | |
| 5035 | + $bullet | |
| 5036 | + .next() | |
| 5037 | + .addClass(((params.bulletActiveClass) + "-next")) | |
| 5038 | + .next() | |
| 5039 | + .addClass(((params.bulletActiveClass) + "-next-next")); | |
| 5040 | + } | |
| 5041 | + } | |
| 5042 | + }); | |
| 5043 | + } else { | |
| 5044 | + var $bullet = bullets.eq(current); | |
| 5045 | + $bullet.addClass(params.bulletActiveClass); | |
| 5046 | + if (params.dynamicBullets) { | |
| 5047 | + var $firstDisplayedBullet = bullets.eq(firstIndex); | |
| 5048 | + var $lastDisplayedBullet = bullets.eq(lastIndex); | |
| 5049 | + for (var i = firstIndex; i <= lastIndex; i += 1) { | |
| 5050 | + bullets.eq(i).addClass(((params.bulletActiveClass) + "-main")); | |
| 5051 | + } | |
| 5052 | + $firstDisplayedBullet | |
| 5053 | + .prev() | |
| 5054 | + .addClass(((params.bulletActiveClass) + "-prev")) | |
| 5055 | + .prev() | |
| 5056 | + .addClass(((params.bulletActiveClass) + "-prev-prev")); | |
| 5057 | + $lastDisplayedBullet | |
| 5058 | + .next() | |
| 5059 | + .addClass(((params.bulletActiveClass) + "-next")) | |
| 5060 | + .next() | |
| 5061 | + .addClass(((params.bulletActiveClass) + "-next-next")); | |
| 5062 | + } | |
| 5063 | + } | |
| 5064 | + if (params.dynamicBullets) { | |
| 5065 | + var dynamicBulletsLength = Math.min(bullets.length, params.dynamicMainBullets + 4); | |
| 5066 | + var bulletsOffset = (((swiper.pagination.bulletSize * dynamicBulletsLength) - (swiper.pagination.bulletSize)) / 2) - (midIndex * swiper.pagination.bulletSize); | |
| 5067 | + var offsetProp = rtl ? 'right' : 'left'; | |
| 5068 | + bullets.css(swiper.isHorizontal() ? offsetProp : 'top', (bulletsOffset + "px")); | |
| 5069 | + } | |
| 5070 | + } | |
| 5071 | + if (params.type === 'fraction') { | |
| 5072 | + $el.find(("." + (params.currentClass))).text(params.formatFractionCurrent(current + 1)); | |
| 5073 | + $el.find(("." + (params.totalClass))).text(params.formatFractionTotal(total)); | |
| 5074 | + } | |
| 5075 | + if (params.type === 'progressbar') { | |
| 5076 | + var progressbarDirection; | |
| 5077 | + if (params.progressbarOpposite) { | |
| 5078 | + progressbarDirection = swiper.isHorizontal() ? 'vertical' : 'horizontal'; | |
| 5079 | + } else { | |
| 5080 | + progressbarDirection = swiper.isHorizontal() ? 'horizontal' : 'vertical'; | |
| 5081 | + } | |
| 5082 | + var scale = (current + 1) / total; | |
| 5083 | + var scaleX = 1; | |
| 5084 | + var scaleY = 1; | |
| 5085 | + if (progressbarDirection === 'horizontal') { | |
| 5086 | + scaleX = scale; | |
| 5087 | + } else { | |
| 5088 | + scaleY = scale; | |
| 5089 | + } | |
| 5090 | + $el.find(("." + (params.progressbarFillClass))).transform(("translate3d(0,0,0) scaleX(" + scaleX + ") scaleY(" + scaleY + ")")).transition(swiper.params.speed); | |
| 5091 | + } | |
| 5092 | + if (params.type === 'custom' && params.renderCustom) { | |
| 5093 | + $el.html(params.renderCustom(swiper, current + 1, total)); | |
| 5094 | + swiper.emit('paginationRender', swiper, $el[0]); | |
| 5095 | + } else { | |
| 5096 | + swiper.emit('paginationUpdate', swiper, $el[0]); | |
| 5097 | + } | |
| 5098 | + $el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](params.lockClass); | |
| 5099 | + }, | |
| 5100 | + render: function render() { | |
| 5101 | + // Render Container | |
| 5102 | + var swiper = this; | |
| 5103 | + var params = swiper.params.pagination; | |
| 5104 | + if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } | |
| 5105 | + var slidesLength = swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.slides.length : swiper.slides.length; | |
| 5106 | + | |
| 5107 | + var $el = swiper.pagination.$el; | |
| 5108 | + var paginationHTML = ''; | |
| 5109 | + if (params.type === 'bullets') { | |
| 5110 | + var numberOfBullets = swiper.params.loop ? Math.ceil((slidesLength - (swiper.loopedSlides * 2)) / swiper.params.slidesPerGroup) : swiper.snapGrid.length; | |
| 5111 | + for (var i = 0; i < numberOfBullets; i += 1) { | |
| 5112 | + if (params.renderBullet) { | |
| 5113 | + paginationHTML += params.renderBullet.call(swiper, i, params.bulletClass); | |
| 5114 | + } else { | |
| 5115 | + paginationHTML += "<" + (params.bulletElement) + " class=\"" + (params.bulletClass) + "\"></" + (params.bulletElement) + ">"; | |
| 5116 | + } | |
| 5117 | + } | |
| 5118 | + $el.html(paginationHTML); | |
| 5119 | + swiper.pagination.bullets = $el.find(("." + (params.bulletClass))); | |
| 5120 | + } | |
| 5121 | + if (params.type === 'fraction') { | |
| 5122 | + if (params.renderFraction) { | |
| 5123 | + paginationHTML = params.renderFraction.call(swiper, params.currentClass, params.totalClass); | |
| 5124 | + } else { | |
| 5125 | + paginationHTML = "<span class=\"" + (params.currentClass) + "\"></span>" | |
| 5126 | + + ' / ' | |
| 5127 | + + "<span class=\"" + (params.totalClass) + "\"></span>"; | |
| 5128 | + } | |
| 5129 | + $el.html(paginationHTML); | |
| 5130 | + } | |
| 5131 | + if (params.type === 'progressbar') { | |
| 5132 | + if (params.renderProgressbar) { | |
| 5133 | + paginationHTML = params.renderProgressbar.call(swiper, params.progressbarFillClass); | |
| 5134 | + } else { | |
| 5135 | + paginationHTML = "<span class=\"" + (params.progressbarFillClass) + "\"></span>"; | |
| 5136 | + } | |
| 5137 | + $el.html(paginationHTML); | |
| 5138 | + } | |
| 5139 | + if (params.type !== 'custom') { | |
| 5140 | + swiper.emit('paginationRender', swiper.pagination.$el[0]); | |
| 5141 | + } | |
| 5142 | + }, | |
| 5143 | + init: function init() { | |
| 5144 | + var swiper = this; | |
| 5145 | + var params = swiper.params.pagination; | |
| 5146 | + if (!params.el) { return; } | |
| 5147 | + | |
| 5148 | + var $el = $(params.el); | |
| 5149 | + if ($el.length === 0) { return; } | |
| 5150 | + | |
| 5151 | + if ( | |
| 5152 | + swiper.params.uniqueNavElements | |
| 5153 | + && typeof params.el === 'string' | |
| 5154 | + && $el.length > 1 | |
| 5155 | + && swiper.$el.find(params.el).length === 1 | |
| 5156 | + ) { | |
| 5157 | + $el = swiper.$el.find(params.el); | |
| 5158 | + } | |
| 5159 | + | |
| 5160 | + if (params.type === 'bullets' && params.clickable) { | |
| 5161 | + $el.addClass(params.clickableClass); | |
| 5162 | + } | |
| 5163 | + | |
| 5164 | + $el.addClass(params.modifierClass + params.type); | |
| 5165 | + | |
| 5166 | + if (params.type === 'bullets' && params.dynamicBullets) { | |
| 5167 | + $el.addClass(("" + (params.modifierClass) + (params.type) + "-dynamic")); | |
| 5168 | + swiper.pagination.dynamicBulletIndex = 0; | |
| 5169 | + if (params.dynamicMainBullets < 1) { | |
| 5170 | + params.dynamicMainBullets = 1; | |
| 5171 | + } | |
| 5172 | + } | |
| 5173 | + if (params.type === 'progressbar' && params.progressbarOpposite) { | |
| 5174 | + $el.addClass(params.progressbarOppositeClass); | |
| 5175 | + } | |
| 5176 | + | |
| 5177 | + if (params.clickable) { | |
| 5178 | + $el.on('click', ("." + (params.bulletClass)), function onClick(e) { | |
| 5179 | + e.preventDefault(); | |
| 5180 | + var index = $(this).index() * swiper.params.slidesPerGroup; | |
| 5181 | + if (swiper.params.loop) { index += swiper.loopedSlides; } | |
| 5182 | + swiper.slideTo(index); | |
| 5183 | + }); | |
| 5184 | + } | |
| 5185 | + | |
| 5186 | + Utils.extend(swiper.pagination, { | |
| 5187 | + $el: $el, | |
| 5188 | + el: $el[0], | |
| 5189 | + }); | |
| 5190 | + }, | |
| 5191 | + destroy: function destroy() { | |
| 5192 | + var swiper = this; | |
| 5193 | + var params = swiper.params.pagination; | |
| 5194 | + if (!params.el || !swiper.pagination.el || !swiper.pagination.$el || swiper.pagination.$el.length === 0) { return; } | |
| 5195 | + var $el = swiper.pagination.$el; | |
| 5196 | + | |
| 5197 | + $el.removeClass(params.hiddenClass); | |
| 5198 | + $el.removeClass(params.modifierClass + params.type); | |
| 5199 | + if (swiper.pagination.bullets) { swiper.pagination.bullets.removeClass(params.bulletActiveClass); } | |
| 5200 | + if (params.clickable) { | |
| 5201 | + $el.off('click', ("." + (params.bulletClass))); | |
| 5202 | + } | |
| 5203 | + }, | |
| 5204 | + }; | |
| 5205 | + | |
| 5206 | + var Pagination$1 = { | |
| 5207 | + name: 'pagination', | |
| 5208 | + params: { | |
| 5209 | + pagination: { | |
| 5210 | + el: null, | |
| 5211 | + bulletElement: 'span', | |
| 5212 | + clickable: false, | |
| 5213 | + hideOnClick: false, | |
| 5214 | + renderBullet: null, | |
| 5215 | + renderProgressbar: null, | |
| 5216 | + renderFraction: null, | |
| 5217 | + renderCustom: null, | |
| 5218 | + progressbarOpposite: false, | |
| 5219 | + type: 'bullets', // 'bullets' or 'progressbar' or 'fraction' or 'custom' | |
| 5220 | + dynamicBullets: false, | |
| 5221 | + dynamicMainBullets: 1, | |
| 5222 | + formatFractionCurrent: function (number) { return number; }, | |
| 5223 | + formatFractionTotal: function (number) { return number; }, | |
| 5224 | + bulletClass: 'swiper-pagination-bullet', | |
| 5225 | + bulletActiveClass: 'swiper-pagination-bullet-active', | |
| 5226 | + modifierClass: 'swiper-pagination-', // NEW | |
| 5227 | + currentClass: 'swiper-pagination-current', | |
| 5228 | + totalClass: 'swiper-pagination-total', | |
| 5229 | + hiddenClass: 'swiper-pagination-hidden', | |
| 5230 | + progressbarFillClass: 'swiper-pagination-progressbar-fill', | |
| 5231 | + progressbarOppositeClass: 'swiper-pagination-progressbar-opposite', | |
| 5232 | + clickableClass: 'swiper-pagination-clickable', // NEW | |
| 5233 | + lockClass: 'swiper-pagination-lock', | |
| 5234 | + }, | |
| 5235 | + }, | |
| 5236 | + create: function create() { | |
| 5237 | + var swiper = this; | |
| 5238 | + Utils.extend(swiper, { | |
| 5239 | + pagination: { | |
| 5240 | + init: Pagination.init.bind(swiper), | |
| 5241 | + render: Pagination.render.bind(swiper), | |
| 5242 | + update: Pagination.update.bind(swiper), | |
| 5243 | + destroy: Pagination.destroy.bind(swiper), | |
| 5244 | + dynamicBulletIndex: 0, | |
| 5245 | + }, | |
| 5246 | + }); | |
| 5247 | + }, | |
| 5248 | + on: { | |
| 5249 | + init: function init() { | |
| 5250 | + var swiper = this; | |
| 5251 | + swiper.pagination.init(); | |
| 5252 | + swiper.pagination.render(); | |
| 5253 | + swiper.pagination.update(); | |
| 5254 | + }, | |
| 5255 | + activeIndexChange: function activeIndexChange() { | |
| 5256 | + var swiper = this; | |
| 5257 | + if (swiper.params.loop) { | |
| 5258 | + swiper.pagination.update(); | |
| 5259 | + } else if (typeof swiper.snapIndex === 'undefined') { | |
| 5260 | + swiper.pagination.update(); | |
| 5261 | + } | |
| 5262 | + }, | |
| 5263 | + snapIndexChange: function snapIndexChange() { | |
| 5264 | + var swiper = this; | |
| 5265 | + if (!swiper.params.loop) { | |
| 5266 | + swiper.pagination.update(); | |
| 5267 | + } | |
| 5268 | + }, | |
| 5269 | + slidesLengthChange: function slidesLengthChange() { | |
| 5270 | + var swiper = this; | |
| 5271 | + if (swiper.params.loop) { | |
| 5272 | + swiper.pagination.render(); | |
| 5273 | + swiper.pagination.update(); | |
| 5274 | + } | |
| 5275 | + }, | |
| 5276 | + snapGridLengthChange: function snapGridLengthChange() { | |
| 5277 | + var swiper = this; | |
| 5278 | + if (!swiper.params.loop) { | |
| 5279 | + swiper.pagination.render(); | |
| 5280 | + swiper.pagination.update(); | |
| 5281 | + } | |
| 5282 | + }, | |
| 5283 | + destroy: function destroy() { | |
| 5284 | + var swiper = this; | |
| 5285 | + swiper.pagination.destroy(); | |
| 5286 | + }, | |
| 5287 | + click: function click(e) { | |
| 5288 | + var swiper = this; | |
| 5289 | + if ( | |
| 5290 | + swiper.params.pagination.el | |
| 5291 | + && swiper.params.pagination.hideOnClick | |
| 5292 | + && swiper.pagination.$el.length > 0 | |
| 5293 | + && !$(e.target).hasClass(swiper.params.pagination.bulletClass) | |
| 5294 | + ) { | |
| 5295 | + swiper.pagination.$el.toggleClass(swiper.params.pagination.hiddenClass); | |
| 5296 | + } | |
| 5297 | + }, | |
| 5298 | + }, | |
| 5299 | + }; | |
| 5300 | + | |
| 5301 | + var Scrollbar = { | |
| 5302 | + setTranslate: function setTranslate() { | |
| 5303 | + var swiper = this; | |
| 5304 | + if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } | |
| 5305 | + var scrollbar = swiper.scrollbar; | |
| 5306 | + var rtl = swiper.rtlTranslate; | |
| 5307 | + var progress = swiper.progress; | |
| 5308 | + var dragSize = scrollbar.dragSize; | |
| 5309 | + var trackSize = scrollbar.trackSize; | |
| 5310 | + var $dragEl = scrollbar.$dragEl; | |
| 5311 | + var $el = scrollbar.$el; | |
| 5312 | + var params = swiper.params.scrollbar; | |
| 5313 | + | |
| 5314 | + var newSize = dragSize; | |
| 5315 | + var newPos = (trackSize - dragSize) * progress; | |
| 5316 | + if (rtl) { | |
| 5317 | + newPos = -newPos; | |
| 5318 | + if (newPos > 0) { | |
| 5319 | + newSize = dragSize - newPos; | |
| 5320 | + newPos = 0; | |
| 5321 | + } else if (-newPos + dragSize > trackSize) { | |
| 5322 | + newSize = trackSize + newPos; | |
| 5323 | + } | |
| 5324 | + } else if (newPos < 0) { | |
| 5325 | + newSize = dragSize + newPos; | |
| 5326 | + newPos = 0; | |
| 5327 | + } else if (newPos + dragSize > trackSize) { | |
| 5328 | + newSize = trackSize - newPos; | |
| 5329 | + } | |
| 5330 | + if (swiper.isHorizontal()) { | |
| 5331 | + if (Support.transforms3d) { | |
| 5332 | + $dragEl.transform(("translate3d(" + newPos + "px, 0, 0)")); | |
| 5333 | + } else { | |
| 5334 | + $dragEl.transform(("translateX(" + newPos + "px)")); | |
| 5335 | + } | |
| 5336 | + $dragEl[0].style.width = newSize + "px"; | |
| 5337 | + } else { | |
| 5338 | + if (Support.transforms3d) { | |
| 5339 | + $dragEl.transform(("translate3d(0px, " + newPos + "px, 0)")); | |
| 5340 | + } else { | |
| 5341 | + $dragEl.transform(("translateY(" + newPos + "px)")); | |
| 5342 | + } | |
| 5343 | + $dragEl[0].style.height = newSize + "px"; | |
| 5344 | + } | |
| 5345 | + if (params.hide) { | |
| 5346 | + clearTimeout(swiper.scrollbar.timeout); | |
| 5347 | + $el[0].style.opacity = 1; | |
| 5348 | + swiper.scrollbar.timeout = setTimeout(function () { | |
| 5349 | + $el[0].style.opacity = 0; | |
| 5350 | + $el.transition(400); | |
| 5351 | + }, 1000); | |
| 5352 | + } | |
| 5353 | + }, | |
| 5354 | + setTransition: function setTransition(duration) { | |
| 5355 | + var swiper = this; | |
| 5356 | + if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } | |
| 5357 | + swiper.scrollbar.$dragEl.transition(duration); | |
| 5358 | + }, | |
| 5359 | + updateSize: function updateSize() { | |
| 5360 | + var swiper = this; | |
| 5361 | + if (!swiper.params.scrollbar.el || !swiper.scrollbar.el) { return; } | |
| 5362 | + | |
| 5363 | + var scrollbar = swiper.scrollbar; | |
| 5364 | + var $dragEl = scrollbar.$dragEl; | |
| 5365 | + var $el = scrollbar.$el; | |
| 5366 | + | |
| 5367 | + $dragEl[0].style.width = ''; | |
| 5368 | + $dragEl[0].style.height = ''; | |
| 5369 | + var trackSize = swiper.isHorizontal() ? $el[0].offsetWidth : $el[0].offsetHeight; | |
| 5370 | + | |
| 5371 | + var divider = swiper.size / swiper.virtualSize; | |
| 5372 | + var moveDivider = divider * (trackSize / swiper.size); | |
| 5373 | + var dragSize; | |
| 5374 | + if (swiper.params.scrollbar.dragSize === 'auto') { | |
| 5375 | + dragSize = trackSize * divider; | |
| 5376 | + } else { | |
| 5377 | + dragSize = parseInt(swiper.params.scrollbar.dragSize, 10); | |
| 5378 | + } | |
| 5379 | + | |
| 5380 | + if (swiper.isHorizontal()) { | |
| 5381 | + $dragEl[0].style.width = dragSize + "px"; | |
| 5382 | + } else { | |
| 5383 | + $dragEl[0].style.height = dragSize + "px"; | |
| 5384 | + } | |
| 5385 | + | |
| 5386 | + if (divider >= 1) { | |
| 5387 | + $el[0].style.display = 'none'; | |
| 5388 | + } else { | |
| 5389 | + $el[0].style.display = ''; | |
| 5390 | + } | |
| 5391 | + if (swiper.params.scrollbarHide) { | |
| 5392 | + $el[0].style.opacity = 0; | |
| 5393 | + } | |
| 5394 | + Utils.extend(scrollbar, { | |
| 5395 | + trackSize: trackSize, | |
| 5396 | + divider: divider, | |
| 5397 | + moveDivider: moveDivider, | |
| 5398 | + dragSize: dragSize, | |
| 5399 | + }); | |
| 5400 | + scrollbar.$el[swiper.params.watchOverflow && swiper.isLocked ? 'addClass' : 'removeClass'](swiper.params.scrollbar.lockClass); | |
| 5401 | + }, | |
| 5402 | + setDragPosition: function setDragPosition(e) { | |
| 5403 | + var swiper = this; | |
| 5404 | + var scrollbar = swiper.scrollbar; | |
| 5405 | + var rtl = swiper.rtlTranslate; | |
| 5406 | + var $el = scrollbar.$el; | |
| 5407 | + var dragSize = scrollbar.dragSize; | |
| 5408 | + var trackSize = scrollbar.trackSize; | |
| 5409 | + | |
| 5410 | + var pointerPosition; | |
| 5411 | + if (swiper.isHorizontal()) { | |
| 5412 | + pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageX : e.pageX || e.clientX); | |
| 5413 | + } else { | |
| 5414 | + pointerPosition = ((e.type === 'touchstart' || e.type === 'touchmove') ? e.targetTouches[0].pageY : e.pageY || e.clientY); | |
| 5415 | + } | |
| 5416 | + var positionRatio; | |
| 5417 | + positionRatio = ((pointerPosition) - $el.offset()[swiper.isHorizontal() ? 'left' : 'top'] - (dragSize / 2)) / (trackSize - dragSize); | |
| 5418 | + positionRatio = Math.max(Math.min(positionRatio, 1), 0); | |
| 5419 | + if (rtl) { | |
| 5420 | + positionRatio = 1 - positionRatio; | |
| 5421 | + } | |
| 5422 | + | |
| 5423 | + var position = swiper.minTranslate() + ((swiper.maxTranslate() - swiper.minTranslate()) * positionRatio); | |
| 5424 | + | |
| 5425 | + swiper.updateProgress(position); | |
| 5426 | + swiper.setTranslate(position); | |
| 5427 | + swiper.updateActiveIndex(); | |
| 5428 | + swiper.updateSlidesClasses(); | |
| 5429 | + }, | |
| 5430 | + onDragStart: function onDragStart(e) { | |
| 5431 | + var swiper = this; | |
| 5432 | + var params = swiper.params.scrollbar; | |
| 5433 | + var scrollbar = swiper.scrollbar; | |
| 5434 | + var $wrapperEl = swiper.$wrapperEl; | |
| 5435 | + var $el = scrollbar.$el; | |
| 5436 | + var $dragEl = scrollbar.$dragEl; | |
| 5437 | + swiper.scrollbar.isTouched = true; | |
| 5438 | + e.preventDefault(); | |
| 5439 | + e.stopPropagation(); | |
| 5440 | + | |
| 5441 | + $wrapperEl.transition(100); | |
| 5442 | + $dragEl.transition(100); | |
| 5443 | + scrollbar.setDragPosition(e); | |
| 5444 | + | |
| 5445 | + clearTimeout(swiper.scrollbar.dragTimeout); | |
| 5446 | + | |
| 5447 | + $el.transition(0); | |
| 5448 | + if (params.hide) { | |
| 5449 | + $el.css('opacity', 1); | |
| 5450 | + } | |
| 5451 | + swiper.emit('scrollbarDragStart', e); | |
| 5452 | + }, | |
| 5453 | + onDragMove: function onDragMove(e) { | |
| 5454 | + var swiper = this; | |
| 5455 | + var scrollbar = swiper.scrollbar; | |
| 5456 | + var $wrapperEl = swiper.$wrapperEl; | |
| 5457 | + var $el = scrollbar.$el; | |
| 5458 | + var $dragEl = scrollbar.$dragEl; | |
| 5459 | + | |
| 5460 | + if (!swiper.scrollbar.isTouched) { return; } | |
| 5461 | + if (e.preventDefault) { e.preventDefault(); } | |
| 5462 | + else { e.returnValue = false; } | |
| 5463 | + scrollbar.setDragPosition(e); | |
| 5464 | + $wrapperEl.transition(0); | |
| 5465 | + $el.transition(0); | |
| 5466 | + $dragEl.transition(0); | |
| 5467 | + swiper.emit('scrollbarDragMove', e); | |
| 5468 | + }, | |
| 5469 | + onDragEnd: function onDragEnd(e) { | |
| 5470 | + var swiper = this; | |
| 5471 | + | |
| 5472 | + var params = swiper.params.scrollbar; | |
| 5473 | + var scrollbar = swiper.scrollbar; | |
| 5474 | + var $el = scrollbar.$el; | |
| 5475 | + | |
| 5476 | + if (!swiper.scrollbar.isTouched) { return; } | |
| 5477 | + swiper.scrollbar.isTouched = false; | |
| 5478 | + if (params.hide) { | |
| 5479 | + clearTimeout(swiper.scrollbar.dragTimeout); | |
| 5480 | + swiper.scrollbar.dragTimeout = Utils.nextTick(function () { | |
| 5481 | + $el.css('opacity', 0); | |
| 5482 | + $el.transition(400); | |
| 5483 | + }, 1000); | |
| 5484 | + } | |
| 5485 | + swiper.emit('scrollbarDragEnd', e); | |
| 5486 | + if (params.snapOnRelease) { | |
| 5487 | + swiper.slideToClosest(); | |
| 5488 | + } | |
| 5489 | + }, | |
| 5490 | + enableDraggable: function enableDraggable() { | |
| 5491 | + var swiper = this; | |
| 5492 | + if (!swiper.params.scrollbar.el) { return; } | |
| 5493 | + var scrollbar = swiper.scrollbar; | |
| 5494 | + var touchEventsTouch = swiper.touchEventsTouch; | |
| 5495 | + var touchEventsDesktop = swiper.touchEventsDesktop; | |
| 5496 | + var params = swiper.params; | |
| 5497 | + var $el = scrollbar.$el; | |
| 5498 | + var target = $el[0]; | |
| 5499 | + var activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false; | |
| 5500 | + var passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; | |
| 5501 | + if (!Support.touch) { | |
| 5502 | + target.addEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); | |
| 5503 | + doc.addEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); | |
| 5504 | + doc.addEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); | |
| 5505 | + } else { | |
| 5506 | + target.addEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); | |
| 5507 | + target.addEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); | |
| 5508 | + target.addEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); | |
| 5509 | + } | |
| 5510 | + }, | |
| 5511 | + disableDraggable: function disableDraggable() { | |
| 5512 | + var swiper = this; | |
| 5513 | + if (!swiper.params.scrollbar.el) { return; } | |
| 5514 | + var scrollbar = swiper.scrollbar; | |
| 5515 | + var touchEventsTouch = swiper.touchEventsTouch; | |
| 5516 | + var touchEventsDesktop = swiper.touchEventsDesktop; | |
| 5517 | + var params = swiper.params; | |
| 5518 | + var $el = scrollbar.$el; | |
| 5519 | + var target = $el[0]; | |
| 5520 | + var activeListener = Support.passiveListener && params.passiveListeners ? { passive: false, capture: false } : false; | |
| 5521 | + var passiveListener = Support.passiveListener && params.passiveListeners ? { passive: true, capture: false } : false; | |
| 5522 | + if (!Support.touch) { | |
| 5523 | + target.removeEventListener(touchEventsDesktop.start, swiper.scrollbar.onDragStart, activeListener); | |
| 5524 | + doc.removeEventListener(touchEventsDesktop.move, swiper.scrollbar.onDragMove, activeListener); | |
| 5525 | + doc.removeEventListener(touchEventsDesktop.end, swiper.scrollbar.onDragEnd, passiveListener); | |
| 5526 | + } else { | |
| 5527 | + target.removeEventListener(touchEventsTouch.start, swiper.scrollbar.onDragStart, activeListener); | |
| 5528 | + target.removeEventListener(touchEventsTouch.move, swiper.scrollbar.onDragMove, activeListener); | |
| 5529 | + target.removeEventListener(touchEventsTouch.end, swiper.scrollbar.onDragEnd, passiveListener); | |
| 5530 | + } | |
| 5531 | + }, | |
| 5532 | + init: function init() { | |
| 5533 | + var swiper = this; | |
| 5534 | + if (!swiper.params.scrollbar.el) { return; } | |
| 5535 | + var scrollbar = swiper.scrollbar; | |
| 5536 | + var $swiperEl = swiper.$el; | |
| 5537 | + var params = swiper.params.scrollbar; | |
| 5538 | + | |
| 5539 | + var $el = $(params.el); | |
| 5540 | + if (swiper.params.uniqueNavElements && typeof params.el === 'string' && $el.length > 1 && $swiperEl.find(params.el).length === 1) { | |
| 5541 | + $el = $swiperEl.find(params.el); | |
| 5542 | + } | |
| 5543 | + | |
| 5544 | + var $dragEl = $el.find(("." + (swiper.params.scrollbar.dragClass))); | |
| 5545 | + if ($dragEl.length === 0) { | |
| 5546 | + $dragEl = $(("<div class=\"" + (swiper.params.scrollbar.dragClass) + "\"></div>")); | |
| 5547 | + $el.append($dragEl); | |
| 5548 | + } | |
| 5549 | + | |
| 5550 | + Utils.extend(scrollbar, { | |
| 5551 | + $el: $el, | |
| 5552 | + el: $el[0], | |
| 5553 | + $dragEl: $dragEl, | |
| 5554 | + dragEl: $dragEl[0], | |
| 5555 | + }); | |
| 5556 | + | |
| 5557 | + if (params.draggable) { | |
| 5558 | + scrollbar.enableDraggable(); | |
| 5559 | + } | |
| 5560 | + }, | |
| 5561 | + destroy: function destroy() { | |
| 5562 | + var swiper = this; | |
| 5563 | + swiper.scrollbar.disableDraggable(); | |
| 5564 | + }, | |
| 5565 | + }; | |
| 5566 | + | |
| 5567 | + var Scrollbar$1 = { | |
| 5568 | + name: 'scrollbar', | |
| 5569 | + params: { | |
| 5570 | + scrollbar: { | |
| 5571 | + el: null, | |
| 5572 | + dragSize: 'auto', | |
| 5573 | + hide: false, | |
| 5574 | + draggable: false, | |
| 5575 | + snapOnRelease: true, | |
| 5576 | + lockClass: 'swiper-scrollbar-lock', | |
| 5577 | + dragClass: 'swiper-scrollbar-drag', | |
| 5578 | + }, | |
| 5579 | + }, | |
| 5580 | + create: function create() { | |
| 5581 | + var swiper = this; | |
| 5582 | + Utils.extend(swiper, { | |
| 5583 | + scrollbar: { | |
| 5584 | + init: Scrollbar.init.bind(swiper), | |
| 5585 | + destroy: Scrollbar.destroy.bind(swiper), | |
| 5586 | + updateSize: Scrollbar.updateSize.bind(swiper), | |
| 5587 | + setTranslate: Scrollbar.setTranslate.bind(swiper), | |
| 5588 | + setTransition: Scrollbar.setTransition.bind(swiper), | |
| 5589 | + enableDraggable: Scrollbar.enableDraggable.bind(swiper), | |
| 5590 | + disableDraggable: Scrollbar.disableDraggable.bind(swiper), | |
| 5591 | + setDragPosition: Scrollbar.setDragPosition.bind(swiper), | |
| 5592 | + onDragStart: Scrollbar.onDragStart.bind(swiper), | |
| 5593 | + onDragMove: Scrollbar.onDragMove.bind(swiper), | |
| 5594 | + onDragEnd: Scrollbar.onDragEnd.bind(swiper), | |
| 5595 | + isTouched: false, | |
| 5596 | + timeout: null, | |
| 5597 | + dragTimeout: null, | |
| 5598 | + }, | |
| 5599 | + }); | |
| 5600 | + }, | |
| 5601 | + on: { | |
| 5602 | + init: function init() { | |
| 5603 | + var swiper = this; | |
| 5604 | + swiper.scrollbar.init(); | |
| 5605 | + swiper.scrollbar.updateSize(); | |
| 5606 | + swiper.scrollbar.setTranslate(); | |
| 5607 | + }, | |
| 5608 | + update: function update() { | |
| 5609 | + var swiper = this; | |
| 5610 | + swiper.scrollbar.updateSize(); | |
| 5611 | + }, | |
| 5612 | + resize: function resize() { | |
| 5613 | + var swiper = this; | |
| 5614 | + swiper.scrollbar.updateSize(); | |
| 5615 | + }, | |
| 5616 | + observerUpdate: function observerUpdate() { | |
| 5617 | + var swiper = this; | |
| 5618 | + swiper.scrollbar.updateSize(); | |
| 5619 | + }, | |
| 5620 | + setTranslate: function setTranslate() { | |
| 5621 | + var swiper = this; | |
| 5622 | + swiper.scrollbar.setTranslate(); | |
| 5623 | + }, | |
| 5624 | + setTransition: function setTransition(duration) { | |
| 5625 | + var swiper = this; | |
| 5626 | + swiper.scrollbar.setTransition(duration); | |
| 5627 | + }, | |
| 5628 | + destroy: function destroy() { | |
| 5629 | + var swiper = this; | |
| 5630 | + swiper.scrollbar.destroy(); | |
| 5631 | + }, | |
| 5632 | + }, | |
| 5633 | + }; | |
| 5634 | + | |
| 5635 | + var Parallax = { | |
| 5636 | + setTransform: function setTransform(el, progress) { | |
| 5637 | + var swiper = this; | |
| 5638 | + var rtl = swiper.rtl; | |
| 5639 | + | |
| 5640 | + var $el = $(el); | |
| 5641 | + var rtlFactor = rtl ? -1 : 1; | |
| 5642 | + | |
| 5643 | + var p = $el.attr('data-swiper-parallax') || '0'; | |
| 5644 | + var x = $el.attr('data-swiper-parallax-x'); | |
| 5645 | + var y = $el.attr('data-swiper-parallax-y'); | |
| 5646 | + var scale = $el.attr('data-swiper-parallax-scale'); | |
| 5647 | + var opacity = $el.attr('data-swiper-parallax-opacity'); | |
| 5648 | + | |
| 5649 | + if (x || y) { | |
| 5650 | + x = x || '0'; | |
| 5651 | + y = y || '0'; | |
| 5652 | + } else if (swiper.isHorizontal()) { | |
| 5653 | + x = p; | |
| 5654 | + y = '0'; | |
| 5655 | + } else { | |
| 5656 | + y = p; | |
| 5657 | + x = '0'; | |
| 5658 | + } | |
| 5659 | + | |
| 5660 | + if ((x).indexOf('%') >= 0) { | |
| 5661 | + x = (parseInt(x, 10) * progress * rtlFactor) + "%"; | |
| 5662 | + } else { | |
| 5663 | + x = (x * progress * rtlFactor) + "px"; | |
| 5664 | + } | |
| 5665 | + if ((y).indexOf('%') >= 0) { | |
| 5666 | + y = (parseInt(y, 10) * progress) + "%"; | |
| 5667 | + } else { | |
| 5668 | + y = (y * progress) + "px"; | |
| 5669 | + } | |
| 5670 | + | |
| 5671 | + if (typeof opacity !== 'undefined' && opacity !== null) { | |
| 5672 | + var currentOpacity = opacity - ((opacity - 1) * (1 - Math.abs(progress))); | |
| 5673 | + $el[0].style.opacity = currentOpacity; | |
| 5674 | + } | |
| 5675 | + if (typeof scale === 'undefined' || scale === null) { | |
| 5676 | + $el.transform(("translate3d(" + x + ", " + y + ", 0px)")); | |
| 5677 | + } else { | |
| 5678 | + var currentScale = scale - ((scale - 1) * (1 - Math.abs(progress))); | |
| 5679 | + $el.transform(("translate3d(" + x + ", " + y + ", 0px) scale(" + currentScale + ")")); | |
| 5680 | + } | |
| 5681 | + }, | |
| 5682 | + setTranslate: function setTranslate() { | |
| 5683 | + var swiper = this; | |
| 5684 | + var $el = swiper.$el; | |
| 5685 | + var slides = swiper.slides; | |
| 5686 | + var progress = swiper.progress; | |
| 5687 | + var snapGrid = swiper.snapGrid; | |
| 5688 | + $el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') | |
| 5689 | + .each(function (index, el) { | |
| 5690 | + swiper.parallax.setTransform(el, progress); | |
| 5691 | + }); | |
| 5692 | + slides.each(function (slideIndex, slideEl) { | |
| 5693 | + var slideProgress = slideEl.progress; | |
| 5694 | + if (swiper.params.slidesPerGroup > 1 && swiper.params.slidesPerView !== 'auto') { | |
| 5695 | + slideProgress += Math.ceil(slideIndex / 2) - (progress * (snapGrid.length - 1)); | |
| 5696 | + } | |
| 5697 | + slideProgress = Math.min(Math.max(slideProgress, -1), 1); | |
| 5698 | + $(slideEl).find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') | |
| 5699 | + .each(function (index, el) { | |
| 5700 | + swiper.parallax.setTransform(el, slideProgress); | |
| 5701 | + }); | |
| 5702 | + }); | |
| 5703 | + }, | |
| 5704 | + setTransition: function setTransition(duration) { | |
| 5705 | + if ( duration === void 0 ) duration = this.params.speed; | |
| 5706 | + | |
| 5707 | + var swiper = this; | |
| 5708 | + var $el = swiper.$el; | |
| 5709 | + $el.find('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]') | |
| 5710 | + .each(function (index, parallaxEl) { | |
| 5711 | + var $parallaxEl = $(parallaxEl); | |
| 5712 | + var parallaxDuration = parseInt($parallaxEl.attr('data-swiper-parallax-duration'), 10) || duration; | |
| 5713 | + if (duration === 0) { parallaxDuration = 0; } | |
| 5714 | + $parallaxEl.transition(parallaxDuration); | |
| 5715 | + }); | |
| 5716 | + }, | |
| 5717 | + }; | |
| 5718 | + | |
| 5719 | + var Parallax$1 = { | |
| 5720 | + name: 'parallax', | |
| 5721 | + params: { | |
| 5722 | + parallax: { | |
| 5723 | + enabled: false, | |
| 5724 | + }, | |
| 5725 | + }, | |
| 5726 | + create: function create() { | |
| 5727 | + var swiper = this; | |
| 5728 | + Utils.extend(swiper, { | |
| 5729 | + parallax: { | |
| 5730 | + setTransform: Parallax.setTransform.bind(swiper), | |
| 5731 | + setTranslate: Parallax.setTranslate.bind(swiper), | |
| 5732 | + setTransition: Parallax.setTransition.bind(swiper), | |
| 5733 | + }, | |
| 5734 | + }); | |
| 5735 | + }, | |
| 5736 | + on: { | |
| 5737 | + beforeInit: function beforeInit() { | |
| 5738 | + var swiper = this; | |
| 5739 | + if (!swiper.params.parallax.enabled) { return; } | |
| 5740 | + swiper.params.watchSlidesProgress = true; | |
| 5741 | + swiper.originalParams.watchSlidesProgress = true; | |
| 5742 | + }, | |
| 5743 | + init: function init() { | |
| 5744 | + var swiper = this; | |
| 5745 | + if (!swiper.params.parallax) { return; } | |
| 5746 | + swiper.parallax.setTranslate(); | |
| 5747 | + }, | |
| 5748 | + setTranslate: function setTranslate() { | |
| 5749 | + var swiper = this; | |
| 5750 | + if (!swiper.params.parallax) { return; } | |
| 5751 | + swiper.parallax.setTranslate(); | |
| 5752 | + }, | |
| 5753 | + setTransition: function setTransition(duration) { | |
| 5754 | + var swiper = this; | |
| 5755 | + if (!swiper.params.parallax) { return; } | |
| 5756 | + swiper.parallax.setTransition(duration); | |
| 5757 | + }, | |
| 5758 | + }, | |
| 5759 | + }; | |
| 5760 | + | |
| 5761 | + var Zoom = { | |
| 5762 | + // Calc Scale From Multi-touches | |
| 5763 | + getDistanceBetweenTouches: function getDistanceBetweenTouches(e) { | |
| 5764 | + if (e.targetTouches.length < 2) { return 1; } | |
| 5765 | + var x1 = e.targetTouches[0].pageX; | |
| 5766 | + var y1 = e.targetTouches[0].pageY; | |
| 5767 | + var x2 = e.targetTouches[1].pageX; | |
| 5768 | + var y2 = e.targetTouches[1].pageY; | |
| 5769 | + var distance = Math.sqrt((Math.pow( (x2 - x1), 2 )) + (Math.pow( (y2 - y1), 2 ))); | |
| 5770 | + return distance; | |
| 5771 | + }, | |
| 5772 | + // Events | |
| 5773 | + onGestureStart: function onGestureStart(e) { | |
| 5774 | + var swiper = this; | |
| 5775 | + var params = swiper.params.zoom; | |
| 5776 | + var zoom = swiper.zoom; | |
| 5777 | + var gesture = zoom.gesture; | |
| 5778 | + zoom.fakeGestureTouched = false; | |
| 5779 | + zoom.fakeGestureMoved = false; | |
| 5780 | + if (!Support.gestures) { | |
| 5781 | + if (e.type !== 'touchstart' || (e.type === 'touchstart' && e.targetTouches.length < 2)) { | |
| 5782 | + return; | |
| 5783 | + } | |
| 5784 | + zoom.fakeGestureTouched = true; | |
| 5785 | + gesture.scaleStart = Zoom.getDistanceBetweenTouches(e); | |
| 5786 | + } | |
| 5787 | + if (!gesture.$slideEl || !gesture.$slideEl.length) { | |
| 5788 | + gesture.$slideEl = $(e.target).closest('.swiper-slide'); | |
| 5789 | + if (gesture.$slideEl.length === 0) { gesture.$slideEl = swiper.slides.eq(swiper.activeIndex); } | |
| 5790 | + gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); | |
| 5791 | + gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); | |
| 5792 | + gesture.maxRatio = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; | |
| 5793 | + if (gesture.$imageWrapEl.length === 0) { | |
| 5794 | + gesture.$imageEl = undefined; | |
| 5795 | + return; | |
| 5796 | + } | |
| 5797 | + } | |
| 5798 | + gesture.$imageEl.transition(0); | |
| 5799 | + swiper.zoom.isScaling = true; | |
| 5800 | + }, | |
| 5801 | + onGestureChange: function onGestureChange(e) { | |
| 5802 | + var swiper = this; | |
| 5803 | + var params = swiper.params.zoom; | |
| 5804 | + var zoom = swiper.zoom; | |
| 5805 | + var gesture = zoom.gesture; | |
| 5806 | + if (!Support.gestures) { | |
| 5807 | + if (e.type !== 'touchmove' || (e.type === 'touchmove' && e.targetTouches.length < 2)) { | |
| 5808 | + return; | |
| 5809 | + } | |
| 5810 | + zoom.fakeGestureMoved = true; | |
| 5811 | + gesture.scaleMove = Zoom.getDistanceBetweenTouches(e); | |
| 5812 | + } | |
| 5813 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 5814 | + if (Support.gestures) { | |
| 5815 | + zoom.scale = e.scale * zoom.currentScale; | |
| 5816 | + } else { | |
| 5817 | + zoom.scale = (gesture.scaleMove / gesture.scaleStart) * zoom.currentScale; | |
| 5818 | + } | |
| 5819 | + if (zoom.scale > gesture.maxRatio) { | |
| 5820 | + zoom.scale = (gesture.maxRatio - 1) + (Math.pow( ((zoom.scale - gesture.maxRatio) + 1), 0.5 )); | |
| 5821 | + } | |
| 5822 | + if (zoom.scale < params.minRatio) { | |
| 5823 | + zoom.scale = (params.minRatio + 1) - (Math.pow( ((params.minRatio - zoom.scale) + 1), 0.5 )); | |
| 5824 | + } | |
| 5825 | + gesture.$imageEl.transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); | |
| 5826 | + }, | |
| 5827 | + onGestureEnd: function onGestureEnd(e) { | |
| 5828 | + var swiper = this; | |
| 5829 | + var params = swiper.params.zoom; | |
| 5830 | + var zoom = swiper.zoom; | |
| 5831 | + var gesture = zoom.gesture; | |
| 5832 | + if (!Support.gestures) { | |
| 5833 | + if (!zoom.fakeGestureTouched || !zoom.fakeGestureMoved) { | |
| 5834 | + return; | |
| 5835 | + } | |
| 5836 | + if (e.type !== 'touchend' || (e.type === 'touchend' && e.changedTouches.length < 2 && !Device.android)) { | |
| 5837 | + return; | |
| 5838 | + } | |
| 5839 | + zoom.fakeGestureTouched = false; | |
| 5840 | + zoom.fakeGestureMoved = false; | |
| 5841 | + } | |
| 5842 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 5843 | + zoom.scale = Math.max(Math.min(zoom.scale, gesture.maxRatio), params.minRatio); | |
| 5844 | + gesture.$imageEl.transition(swiper.params.speed).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); | |
| 5845 | + zoom.currentScale = zoom.scale; | |
| 5846 | + zoom.isScaling = false; | |
| 5847 | + if (zoom.scale === 1) { gesture.$slideEl = undefined; } | |
| 5848 | + }, | |
| 5849 | + onTouchStart: function onTouchStart(e) { | |
| 5850 | + var swiper = this; | |
| 5851 | + var zoom = swiper.zoom; | |
| 5852 | + var gesture = zoom.gesture; | |
| 5853 | + var image = zoom.image; | |
| 5854 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 5855 | + if (image.isTouched) { return; } | |
| 5856 | + if (Device.android) { e.preventDefault(); } | |
| 5857 | + image.isTouched = true; | |
| 5858 | + image.touchesStart.x = e.type === 'touchstart' ? e.targetTouches[0].pageX : e.pageX; | |
| 5859 | + image.touchesStart.y = e.type === 'touchstart' ? e.targetTouches[0].pageY : e.pageY; | |
| 5860 | + }, | |
| 5861 | + onTouchMove: function onTouchMove(e) { | |
| 5862 | + var swiper = this; | |
| 5863 | + var zoom = swiper.zoom; | |
| 5864 | + var gesture = zoom.gesture; | |
| 5865 | + var image = zoom.image; | |
| 5866 | + var velocity = zoom.velocity; | |
| 5867 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 5868 | + swiper.allowClick = false; | |
| 5869 | + if (!image.isTouched || !gesture.$slideEl) { return; } | |
| 5870 | + | |
| 5871 | + if (!image.isMoved) { | |
| 5872 | + image.width = gesture.$imageEl[0].offsetWidth; | |
| 5873 | + image.height = gesture.$imageEl[0].offsetHeight; | |
| 5874 | + image.startX = Utils.getTranslate(gesture.$imageWrapEl[0], 'x') || 0; | |
| 5875 | + image.startY = Utils.getTranslate(gesture.$imageWrapEl[0], 'y') || 0; | |
| 5876 | + gesture.slideWidth = gesture.$slideEl[0].offsetWidth; | |
| 5877 | + gesture.slideHeight = gesture.$slideEl[0].offsetHeight; | |
| 5878 | + gesture.$imageWrapEl.transition(0); | |
| 5879 | + if (swiper.rtl) { | |
| 5880 | + image.startX = -image.startX; | |
| 5881 | + image.startY = -image.startY; | |
| 5882 | + } | |
| 5883 | + } | |
| 5884 | + // Define if we need image drag | |
| 5885 | + var scaledWidth = image.width * zoom.scale; | |
| 5886 | + var scaledHeight = image.height * zoom.scale; | |
| 5887 | + | |
| 5888 | + if (scaledWidth < gesture.slideWidth && scaledHeight < gesture.slideHeight) { return; } | |
| 5889 | + | |
| 5890 | + image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0); | |
| 5891 | + image.maxX = -image.minX; | |
| 5892 | + image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0); | |
| 5893 | + image.maxY = -image.minY; | |
| 5894 | + | |
| 5895 | + image.touchesCurrent.x = e.type === 'touchmove' ? e.targetTouches[0].pageX : e.pageX; | |
| 5896 | + image.touchesCurrent.y = e.type === 'touchmove' ? e.targetTouches[0].pageY : e.pageY; | |
| 5897 | + | |
| 5898 | + if (!image.isMoved && !zoom.isScaling) { | |
| 5899 | + if ( | |
| 5900 | + swiper.isHorizontal() | |
| 5901 | + && ( | |
| 5902 | + (Math.floor(image.minX) === Math.floor(image.startX) && image.touchesCurrent.x < image.touchesStart.x) | |
| 5903 | + || (Math.floor(image.maxX) === Math.floor(image.startX) && image.touchesCurrent.x > image.touchesStart.x) | |
| 5904 | + ) | |
| 5905 | + ) { | |
| 5906 | + image.isTouched = false; | |
| 5907 | + return; | |
| 5908 | + } if ( | |
| 5909 | + !swiper.isHorizontal() | |
| 5910 | + && ( | |
| 5911 | + (Math.floor(image.minY) === Math.floor(image.startY) && image.touchesCurrent.y < image.touchesStart.y) | |
| 5912 | + || (Math.floor(image.maxY) === Math.floor(image.startY) && image.touchesCurrent.y > image.touchesStart.y) | |
| 5913 | + ) | |
| 5914 | + ) { | |
| 5915 | + image.isTouched = false; | |
| 5916 | + return; | |
| 5917 | + } | |
| 5918 | + } | |
| 5919 | + e.preventDefault(); | |
| 5920 | + e.stopPropagation(); | |
| 5921 | + | |
| 5922 | + image.isMoved = true; | |
| 5923 | + image.currentX = (image.touchesCurrent.x - image.touchesStart.x) + image.startX; | |
| 5924 | + image.currentY = (image.touchesCurrent.y - image.touchesStart.y) + image.startY; | |
| 5925 | + | |
| 5926 | + if (image.currentX < image.minX) { | |
| 5927 | + image.currentX = (image.minX + 1) - (Math.pow( ((image.minX - image.currentX) + 1), 0.8 )); | |
| 5928 | + } | |
| 5929 | + if (image.currentX > image.maxX) { | |
| 5930 | + image.currentX = (image.maxX - 1) + (Math.pow( ((image.currentX - image.maxX) + 1), 0.8 )); | |
| 5931 | + } | |
| 5932 | + | |
| 5933 | + if (image.currentY < image.minY) { | |
| 5934 | + image.currentY = (image.minY + 1) - (Math.pow( ((image.minY - image.currentY) + 1), 0.8 )); | |
| 5935 | + } | |
| 5936 | + if (image.currentY > image.maxY) { | |
| 5937 | + image.currentY = (image.maxY - 1) + (Math.pow( ((image.currentY - image.maxY) + 1), 0.8 )); | |
| 5938 | + } | |
| 5939 | + | |
| 5940 | + // Velocity | |
| 5941 | + if (!velocity.prevPositionX) { velocity.prevPositionX = image.touchesCurrent.x; } | |
| 5942 | + if (!velocity.prevPositionY) { velocity.prevPositionY = image.touchesCurrent.y; } | |
| 5943 | + if (!velocity.prevTime) { velocity.prevTime = Date.now(); } | |
| 5944 | + velocity.x = (image.touchesCurrent.x - velocity.prevPositionX) / (Date.now() - velocity.prevTime) / 2; | |
| 5945 | + velocity.y = (image.touchesCurrent.y - velocity.prevPositionY) / (Date.now() - velocity.prevTime) / 2; | |
| 5946 | + if (Math.abs(image.touchesCurrent.x - velocity.prevPositionX) < 2) { velocity.x = 0; } | |
| 5947 | + if (Math.abs(image.touchesCurrent.y - velocity.prevPositionY) < 2) { velocity.y = 0; } | |
| 5948 | + velocity.prevPositionX = image.touchesCurrent.x; | |
| 5949 | + velocity.prevPositionY = image.touchesCurrent.y; | |
| 5950 | + velocity.prevTime = Date.now(); | |
| 5951 | + | |
| 5952 | + gesture.$imageWrapEl.transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)")); | |
| 5953 | + }, | |
| 5954 | + onTouchEnd: function onTouchEnd() { | |
| 5955 | + var swiper = this; | |
| 5956 | + var zoom = swiper.zoom; | |
| 5957 | + var gesture = zoom.gesture; | |
| 5958 | + var image = zoom.image; | |
| 5959 | + var velocity = zoom.velocity; | |
| 5960 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 5961 | + if (!image.isTouched || !image.isMoved) { | |
| 5962 | + image.isTouched = false; | |
| 5963 | + image.isMoved = false; | |
| 5964 | + return; | |
| 5965 | + } | |
| 5966 | + image.isTouched = false; | |
| 5967 | + image.isMoved = false; | |
| 5968 | + var momentumDurationX = 300; | |
| 5969 | + var momentumDurationY = 300; | |
| 5970 | + var momentumDistanceX = velocity.x * momentumDurationX; | |
| 5971 | + var newPositionX = image.currentX + momentumDistanceX; | |
| 5972 | + var momentumDistanceY = velocity.y * momentumDurationY; | |
| 5973 | + var newPositionY = image.currentY + momentumDistanceY; | |
| 5974 | + | |
| 5975 | + // Fix duration | |
| 5976 | + if (velocity.x !== 0) { momentumDurationX = Math.abs((newPositionX - image.currentX) / velocity.x); } | |
| 5977 | + if (velocity.y !== 0) { momentumDurationY = Math.abs((newPositionY - image.currentY) / velocity.y); } | |
| 5978 | + var momentumDuration = Math.max(momentumDurationX, momentumDurationY); | |
| 5979 | + | |
| 5980 | + image.currentX = newPositionX; | |
| 5981 | + image.currentY = newPositionY; | |
| 5982 | + | |
| 5983 | + // Define if we need image drag | |
| 5984 | + var scaledWidth = image.width * zoom.scale; | |
| 5985 | + var scaledHeight = image.height * zoom.scale; | |
| 5986 | + image.minX = Math.min(((gesture.slideWidth / 2) - (scaledWidth / 2)), 0); | |
| 5987 | + image.maxX = -image.minX; | |
| 5988 | + image.minY = Math.min(((gesture.slideHeight / 2) - (scaledHeight / 2)), 0); | |
| 5989 | + image.maxY = -image.minY; | |
| 5990 | + image.currentX = Math.max(Math.min(image.currentX, image.maxX), image.minX); | |
| 5991 | + image.currentY = Math.max(Math.min(image.currentY, image.maxY), image.minY); | |
| 5992 | + | |
| 5993 | + gesture.$imageWrapEl.transition(momentumDuration).transform(("translate3d(" + (image.currentX) + "px, " + (image.currentY) + "px,0)")); | |
| 5994 | + }, | |
| 5995 | + onTransitionEnd: function onTransitionEnd() { | |
| 5996 | + var swiper = this; | |
| 5997 | + var zoom = swiper.zoom; | |
| 5998 | + var gesture = zoom.gesture; | |
| 5999 | + if (gesture.$slideEl && swiper.previousIndex !== swiper.activeIndex) { | |
| 6000 | + gesture.$imageEl.transform('translate3d(0,0,0) scale(1)'); | |
| 6001 | + gesture.$imageWrapEl.transform('translate3d(0,0,0)'); | |
| 6002 | + | |
| 6003 | + zoom.scale = 1; | |
| 6004 | + zoom.currentScale = 1; | |
| 6005 | + | |
| 6006 | + gesture.$slideEl = undefined; | |
| 6007 | + gesture.$imageEl = undefined; | |
| 6008 | + gesture.$imageWrapEl = undefined; | |
| 6009 | + } | |
| 6010 | + }, | |
| 6011 | + // Toggle Zoom | |
| 6012 | + toggle: function toggle(e) { | |
| 6013 | + var swiper = this; | |
| 6014 | + var zoom = swiper.zoom; | |
| 6015 | + | |
| 6016 | + if (zoom.scale && zoom.scale !== 1) { | |
| 6017 | + // Zoom Out | |
| 6018 | + zoom.out(); | |
| 6019 | + } else { | |
| 6020 | + // Zoom In | |
| 6021 | + zoom.in(e); | |
| 6022 | + } | |
| 6023 | + }, | |
| 6024 | + in: function in$1(e) { | |
| 6025 | + var swiper = this; | |
| 6026 | + | |
| 6027 | + var zoom = swiper.zoom; | |
| 6028 | + var params = swiper.params.zoom; | |
| 6029 | + var gesture = zoom.gesture; | |
| 6030 | + var image = zoom.image; | |
| 6031 | + | |
| 6032 | + if (!gesture.$slideEl) { | |
| 6033 | + gesture.$slideEl = swiper.clickedSlide ? $(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex); | |
| 6034 | + gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); | |
| 6035 | + gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); | |
| 6036 | + } | |
| 6037 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 6038 | + | |
| 6039 | + gesture.$slideEl.addClass(("" + (params.zoomedSlideClass))); | |
| 6040 | + | |
| 6041 | + var touchX; | |
| 6042 | + var touchY; | |
| 6043 | + var offsetX; | |
| 6044 | + var offsetY; | |
| 6045 | + var diffX; | |
| 6046 | + var diffY; | |
| 6047 | + var translateX; | |
| 6048 | + var translateY; | |
| 6049 | + var imageWidth; | |
| 6050 | + var imageHeight; | |
| 6051 | + var scaledWidth; | |
| 6052 | + var scaledHeight; | |
| 6053 | + var translateMinX; | |
| 6054 | + var translateMinY; | |
| 6055 | + var translateMaxX; | |
| 6056 | + var translateMaxY; | |
| 6057 | + var slideWidth; | |
| 6058 | + var slideHeight; | |
| 6059 | + | |
| 6060 | + if (typeof image.touchesStart.x === 'undefined' && e) { | |
| 6061 | + touchX = e.type === 'touchend' ? e.changedTouches[0].pageX : e.pageX; | |
| 6062 | + touchY = e.type === 'touchend' ? e.changedTouches[0].pageY : e.pageY; | |
| 6063 | + } else { | |
| 6064 | + touchX = image.touchesStart.x; | |
| 6065 | + touchY = image.touchesStart.y; | |
| 6066 | + } | |
| 6067 | + | |
| 6068 | + zoom.scale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; | |
| 6069 | + zoom.currentScale = gesture.$imageWrapEl.attr('data-swiper-zoom') || params.maxRatio; | |
| 6070 | + if (e) { | |
| 6071 | + slideWidth = gesture.$slideEl[0].offsetWidth; | |
| 6072 | + slideHeight = gesture.$slideEl[0].offsetHeight; | |
| 6073 | + offsetX = gesture.$slideEl.offset().left; | |
| 6074 | + offsetY = gesture.$slideEl.offset().top; | |
| 6075 | + diffX = (offsetX + (slideWidth / 2)) - touchX; | |
| 6076 | + diffY = (offsetY + (slideHeight / 2)) - touchY; | |
| 6077 | + | |
| 6078 | + imageWidth = gesture.$imageEl[0].offsetWidth; | |
| 6079 | + imageHeight = gesture.$imageEl[0].offsetHeight; | |
| 6080 | + scaledWidth = imageWidth * zoom.scale; | |
| 6081 | + scaledHeight = imageHeight * zoom.scale; | |
| 6082 | + | |
| 6083 | + translateMinX = Math.min(((slideWidth / 2) - (scaledWidth / 2)), 0); | |
| 6084 | + translateMinY = Math.min(((slideHeight / 2) - (scaledHeight / 2)), 0); | |
| 6085 | + translateMaxX = -translateMinX; | |
| 6086 | + translateMaxY = -translateMinY; | |
| 6087 | + | |
| 6088 | + translateX = diffX * zoom.scale; | |
| 6089 | + translateY = diffY * zoom.scale; | |
| 6090 | + | |
| 6091 | + if (translateX < translateMinX) { | |
| 6092 | + translateX = translateMinX; | |
| 6093 | + } | |
| 6094 | + if (translateX > translateMaxX) { | |
| 6095 | + translateX = translateMaxX; | |
| 6096 | + } | |
| 6097 | + | |
| 6098 | + if (translateY < translateMinY) { | |
| 6099 | + translateY = translateMinY; | |
| 6100 | + } | |
| 6101 | + if (translateY > translateMaxY) { | |
| 6102 | + translateY = translateMaxY; | |
| 6103 | + } | |
| 6104 | + } else { | |
| 6105 | + translateX = 0; | |
| 6106 | + translateY = 0; | |
| 6107 | + } | |
| 6108 | + gesture.$imageWrapEl.transition(300).transform(("translate3d(" + translateX + "px, " + translateY + "px,0)")); | |
| 6109 | + gesture.$imageEl.transition(300).transform(("translate3d(0,0,0) scale(" + (zoom.scale) + ")")); | |
| 6110 | + }, | |
| 6111 | + out: function out() { | |
| 6112 | + var swiper = this; | |
| 6113 | + | |
| 6114 | + var zoom = swiper.zoom; | |
| 6115 | + var params = swiper.params.zoom; | |
| 6116 | + var gesture = zoom.gesture; | |
| 6117 | + | |
| 6118 | + if (!gesture.$slideEl) { | |
| 6119 | + gesture.$slideEl = swiper.clickedSlide ? $(swiper.clickedSlide) : swiper.slides.eq(swiper.activeIndex); | |
| 6120 | + gesture.$imageEl = gesture.$slideEl.find('img, svg, canvas'); | |
| 6121 | + gesture.$imageWrapEl = gesture.$imageEl.parent(("." + (params.containerClass))); | |
| 6122 | + } | |
| 6123 | + if (!gesture.$imageEl || gesture.$imageEl.length === 0) { return; } | |
| 6124 | + | |
| 6125 | + zoom.scale = 1; | |
| 6126 | + zoom.currentScale = 1; | |
| 6127 | + gesture.$imageWrapEl.transition(300).transform('translate3d(0,0,0)'); | |
| 6128 | + gesture.$imageEl.transition(300).transform('translate3d(0,0,0) scale(1)'); | |
| 6129 | + gesture.$slideEl.removeClass(("" + (params.zoomedSlideClass))); | |
| 6130 | + gesture.$slideEl = undefined; | |
| 6131 | + }, | |
| 6132 | + // Attach/Detach Events | |
| 6133 | + enable: function enable() { | |
| 6134 | + var swiper = this; | |
| 6135 | + var zoom = swiper.zoom; | |
| 6136 | + if (zoom.enabled) { return; } | |
| 6137 | + zoom.enabled = true; | |
| 6138 | + | |
| 6139 | + var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false; | |
| 6140 | + | |
| 6141 | + // Scale image | |
| 6142 | + if (Support.gestures) { | |
| 6143 | + swiper.$wrapperEl.on('gesturestart', '.swiper-slide', zoom.onGestureStart, passiveListener); | |
| 6144 | + swiper.$wrapperEl.on('gesturechange', '.swiper-slide', zoom.onGestureChange, passiveListener); | |
| 6145 | + swiper.$wrapperEl.on('gestureend', '.swiper-slide', zoom.onGestureEnd, passiveListener); | |
| 6146 | + } else if (swiper.touchEvents.start === 'touchstart') { | |
| 6147 | + swiper.$wrapperEl.on(swiper.touchEvents.start, '.swiper-slide', zoom.onGestureStart, passiveListener); | |
| 6148 | + swiper.$wrapperEl.on(swiper.touchEvents.move, '.swiper-slide', zoom.onGestureChange, passiveListener); | |
| 6149 | + swiper.$wrapperEl.on(swiper.touchEvents.end, '.swiper-slide', zoom.onGestureEnd, passiveListener); | |
| 6150 | + } | |
| 6151 | + | |
| 6152 | + // Move image | |
| 6153 | + swiper.$wrapperEl.on(swiper.touchEvents.move, ("." + (swiper.params.zoom.containerClass)), zoom.onTouchMove); | |
| 6154 | + }, | |
| 6155 | + disable: function disable() { | |
| 6156 | + var swiper = this; | |
| 6157 | + var zoom = swiper.zoom; | |
| 6158 | + if (!zoom.enabled) { return; } | |
| 6159 | + | |
| 6160 | + swiper.zoom.enabled = false; | |
| 6161 | + | |
| 6162 | + var passiveListener = swiper.touchEvents.start === 'touchstart' && Support.passiveListener && swiper.params.passiveListeners ? { passive: true, capture: false } : false; | |
| 6163 | + | |
| 6164 | + // Scale image | |
| 6165 | + if (Support.gestures) { | |
| 6166 | + swiper.$wrapperEl.off('gesturestart', '.swiper-slide', zoom.onGestureStart, passiveListener); | |
| 6167 | + swiper.$wrapperEl.off('gesturechange', '.swiper-slide', zoom.onGestureChange, passiveListener); | |
| 6168 | + swiper.$wrapperEl.off('gestureend', '.swiper-slide', zoom.onGestureEnd, passiveListener); | |
| 6169 | + } else if (swiper.touchEvents.start === 'touchstart') { | |
| 6170 | + swiper.$wrapperEl.off(swiper.touchEvents.start, '.swiper-slide', zoom.onGestureStart, passiveListener); | |
| 6171 | + swiper.$wrapperEl.off(swiper.touchEvents.move, '.swiper-slide', zoom.onGestureChange, passiveListener); | |
| 6172 | + swiper.$wrapperEl.off(swiper.touchEvents.end, '.swiper-slide', zoom.onGestureEnd, passiveListener); | |
| 6173 | + } | |
| 6174 | + | |
| 6175 | + // Move image | |
| 6176 | + swiper.$wrapperEl.off(swiper.touchEvents.move, ("." + (swiper.params.zoom.containerClass)), zoom.onTouchMove); | |
| 6177 | + }, | |
| 6178 | + }; | |
| 6179 | + | |
| 6180 | + var Zoom$1 = { | |
| 6181 | + name: 'zoom', | |
| 6182 | + params: { | |
| 6183 | + zoom: { | |
| 6184 | + enabled: false, | |
| 6185 | + maxRatio: 3, | |
| 6186 | + minRatio: 1, | |
| 6187 | + toggle: true, | |
| 6188 | + containerClass: 'swiper-zoom-container', | |
| 6189 | + zoomedSlideClass: 'swiper-slide-zoomed', | |
| 6190 | + }, | |
| 6191 | + }, | |
| 6192 | + create: function create() { | |
| 6193 | + var swiper = this; | |
| 6194 | + var zoom = { | |
| 6195 | + enabled: false, | |
| 6196 | + scale: 1, | |
| 6197 | + currentScale: 1, | |
| 6198 | + isScaling: false, | |
| 6199 | + gesture: { | |
| 6200 | + $slideEl: undefined, | |
| 6201 | + slideWidth: undefined, | |
| 6202 | + slideHeight: undefined, | |
| 6203 | + $imageEl: undefined, | |
| 6204 | + $imageWrapEl: undefined, | |
| 6205 | + maxRatio: 3, | |
| 6206 | + }, | |
| 6207 | + image: { | |
| 6208 | + isTouched: undefined, | |
| 6209 | + isMoved: undefined, | |
| 6210 | + currentX: undefined, | |
| 6211 | + currentY: undefined, | |
| 6212 | + minX: undefined, | |
| 6213 | + minY: undefined, | |
| 6214 | + maxX: undefined, | |
| 6215 | + maxY: undefined, | |
| 6216 | + width: undefined, | |
| 6217 | + height: undefined, | |
| 6218 | + startX: undefined, | |
| 6219 | + startY: undefined, | |
| 6220 | + touchesStart: {}, | |
| 6221 | + touchesCurrent: {}, | |
| 6222 | + }, | |
| 6223 | + velocity: { | |
| 6224 | + x: undefined, | |
| 6225 | + y: undefined, | |
| 6226 | + prevPositionX: undefined, | |
| 6227 | + prevPositionY: undefined, | |
| 6228 | + prevTime: undefined, | |
| 6229 | + }, | |
| 6230 | + }; | |
| 6231 | + | |
| 6232 | + ('onGestureStart onGestureChange onGestureEnd onTouchStart onTouchMove onTouchEnd onTransitionEnd toggle enable disable in out').split(' ').forEach(function (methodName) { | |
| 6233 | + zoom[methodName] = Zoom[methodName].bind(swiper); | |
| 6234 | + }); | |
| 6235 | + Utils.extend(swiper, { | |
| 6236 | + zoom: zoom, | |
| 6237 | + }); | |
| 6238 | + | |
| 6239 | + var scale = 1; | |
| 6240 | + Object.defineProperty(swiper.zoom, 'scale', { | |
| 6241 | + get: function get() { | |
| 6242 | + return scale; | |
| 6243 | + }, | |
| 6244 | + set: function set(value) { | |
| 6245 | + if (scale !== value) { | |
| 6246 | + var imageEl = swiper.zoom.gesture.$imageEl ? swiper.zoom.gesture.$imageEl[0] : undefined; | |
| 6247 | + var slideEl = swiper.zoom.gesture.$slideEl ? swiper.zoom.gesture.$slideEl[0] : undefined; | |
| 6248 | + swiper.emit('zoomChange', value, imageEl, slideEl); | |
| 6249 | + } | |
| 6250 | + scale = value; | |
| 6251 | + }, | |
| 6252 | + }); | |
| 6253 | + }, | |
| 6254 | + on: { | |
| 6255 | + init: function init() { | |
| 6256 | + var swiper = this; | |
| 6257 | + if (swiper.params.zoom.enabled) { | |
| 6258 | + swiper.zoom.enable(); | |
| 6259 | + } | |
| 6260 | + }, | |
| 6261 | + destroy: function destroy() { | |
| 6262 | + var swiper = this; | |
| 6263 | + swiper.zoom.disable(); | |
| 6264 | + }, | |
| 6265 | + touchStart: function touchStart(e) { | |
| 6266 | + var swiper = this; | |
| 6267 | + if (!swiper.zoom.enabled) { return; } | |
| 6268 | + swiper.zoom.onTouchStart(e); | |
| 6269 | + }, | |
| 6270 | + touchEnd: function touchEnd(e) { | |
| 6271 | + var swiper = this; | |
| 6272 | + if (!swiper.zoom.enabled) { return; } | |
| 6273 | + swiper.zoom.onTouchEnd(e); | |
| 6274 | + }, | |
| 6275 | + doubleTap: function doubleTap(e) { | |
| 6276 | + var swiper = this; | |
| 6277 | + if (swiper.params.zoom.enabled && swiper.zoom.enabled && swiper.params.zoom.toggle) { | |
| 6278 | + swiper.zoom.toggle(e); | |
| 6279 | + } | |
| 6280 | + }, | |
| 6281 | + transitionEnd: function transitionEnd() { | |
| 6282 | + var swiper = this; | |
| 6283 | + if (swiper.zoom.enabled && swiper.params.zoom.enabled) { | |
| 6284 | + swiper.zoom.onTransitionEnd(); | |
| 6285 | + } | |
| 6286 | + }, | |
| 6287 | + }, | |
| 6288 | + }; | |
| 6289 | + | |
| 6290 | + var Lazy = { | |
| 6291 | + loadInSlide: function loadInSlide(index, loadInDuplicate) { | |
| 6292 | + if ( loadInDuplicate === void 0 ) loadInDuplicate = true; | |
| 6293 | + | |
| 6294 | + var swiper = this; | |
| 6295 | + var params = swiper.params.lazy; | |
| 6296 | + if (typeof index === 'undefined') { return; } | |
| 6297 | + if (swiper.slides.length === 0) { return; } | |
| 6298 | + var isVirtual = swiper.virtual && swiper.params.virtual.enabled; | |
| 6299 | + | |
| 6300 | + var $slideEl = isVirtual | |
| 6301 | + ? swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")) | |
| 6302 | + : swiper.slides.eq(index); | |
| 6303 | + | |
| 6304 | + var $images = $slideEl.find(("." + (params.elementClass) + ":not(." + (params.loadedClass) + "):not(." + (params.loadingClass) + ")")); | |
| 6305 | + if ($slideEl.hasClass(params.elementClass) && !$slideEl.hasClass(params.loadedClass) && !$slideEl.hasClass(params.loadingClass)) { | |
| 6306 | + $images = $images.add($slideEl[0]); | |
| 6307 | + } | |
| 6308 | + if ($images.length === 0) { return; } | |
| 6309 | + | |
| 6310 | + $images.each(function (imageIndex, imageEl) { | |
| 6311 | + var $imageEl = $(imageEl); | |
| 6312 | + $imageEl.addClass(params.loadingClass); | |
| 6313 | + | |
| 6314 | + var background = $imageEl.attr('data-background'); | |
| 6315 | + var src = $imageEl.attr('data-src'); | |
| 6316 | + var srcset = $imageEl.attr('data-srcset'); | |
| 6317 | + var sizes = $imageEl.attr('data-sizes'); | |
| 6318 | + | |
| 6319 | + swiper.loadImage($imageEl[0], (src || background), srcset, sizes, false, function () { | |
| 6320 | + if (typeof swiper === 'undefined' || swiper === null || !swiper || (swiper && !swiper.params) || swiper.destroyed) { return; } | |
| 6321 | + if (background) { | |
| 6322 | + $imageEl.css('background-image', ("url(\"" + background + "\")")); | |
| 6323 | + $imageEl.removeAttr('data-background'); | |
| 6324 | + } else { | |
| 6325 | + if (srcset) { | |
| 6326 | + $imageEl.attr('srcset', srcset); | |
| 6327 | + $imageEl.removeAttr('data-srcset'); | |
| 6328 | + } | |
| 6329 | + if (sizes) { | |
| 6330 | + $imageEl.attr('sizes', sizes); | |
| 6331 | + $imageEl.removeAttr('data-sizes'); | |
| 6332 | + } | |
| 6333 | + if (src) { | |
| 6334 | + $imageEl.attr('src', src); | |
| 6335 | + $imageEl.removeAttr('data-src'); | |
| 6336 | + } | |
| 6337 | + } | |
| 6338 | + | |
| 6339 | + $imageEl.addClass(params.loadedClass).removeClass(params.loadingClass); | |
| 6340 | + $slideEl.find(("." + (params.preloaderClass))).remove(); | |
| 6341 | + if (swiper.params.loop && loadInDuplicate) { | |
| 6342 | + var slideOriginalIndex = $slideEl.attr('data-swiper-slide-index'); | |
| 6343 | + if ($slideEl.hasClass(swiper.params.slideDuplicateClass)) { | |
| 6344 | + var originalSlide = swiper.$wrapperEl.children(("[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]:not(." + (swiper.params.slideDuplicateClass) + ")")); | |
| 6345 | + swiper.lazy.loadInSlide(originalSlide.index(), false); | |
| 6346 | + } else { | |
| 6347 | + var duplicatedSlide = swiper.$wrapperEl.children(("." + (swiper.params.slideDuplicateClass) + "[data-swiper-slide-index=\"" + slideOriginalIndex + "\"]")); | |
| 6348 | + swiper.lazy.loadInSlide(duplicatedSlide.index(), false); | |
| 6349 | + } | |
| 6350 | + } | |
| 6351 | + swiper.emit('lazyImageReady', $slideEl[0], $imageEl[0]); | |
| 6352 | + }); | |
| 6353 | + | |
| 6354 | + swiper.emit('lazyImageLoad', $slideEl[0], $imageEl[0]); | |
| 6355 | + }); | |
| 6356 | + }, | |
| 6357 | + load: function load() { | |
| 6358 | + var swiper = this; | |
| 6359 | + var $wrapperEl = swiper.$wrapperEl; | |
| 6360 | + var swiperParams = swiper.params; | |
| 6361 | + var slides = swiper.slides; | |
| 6362 | + var activeIndex = swiper.activeIndex; | |
| 6363 | + var isVirtual = swiper.virtual && swiperParams.virtual.enabled; | |
| 6364 | + var params = swiperParams.lazy; | |
| 6365 | + | |
| 6366 | + var slidesPerView = swiperParams.slidesPerView; | |
| 6367 | + if (slidesPerView === 'auto') { | |
| 6368 | + slidesPerView = 0; | |
| 6369 | + } | |
| 6370 | + | |
| 6371 | + function slideExist(index) { | |
| 6372 | + if (isVirtual) { | |
| 6373 | + if ($wrapperEl.children(("." + (swiperParams.slideClass) + "[data-swiper-slide-index=\"" + index + "\"]")).length) { | |
| 6374 | + return true; | |
| 6375 | + } | |
| 6376 | + } else if (slides[index]) { return true; } | |
| 6377 | + return false; | |
| 6378 | + } | |
| 6379 | + function slideIndex(slideEl) { | |
| 6380 | + if (isVirtual) { | |
| 6381 | + return $(slideEl).attr('data-swiper-slide-index'); | |
| 6382 | + } | |
| 6383 | + return $(slideEl).index(); | |
| 6384 | + } | |
| 6385 | + | |
| 6386 | + if (!swiper.lazy.initialImageLoaded) { swiper.lazy.initialImageLoaded = true; } | |
| 6387 | + if (swiper.params.watchSlidesVisibility) { | |
| 6388 | + $wrapperEl.children(("." + (swiperParams.slideVisibleClass))).each(function (elIndex, slideEl) { | |
| 6389 | + var index = isVirtual ? $(slideEl).attr('data-swiper-slide-index') : $(slideEl).index(); | |
| 6390 | + swiper.lazy.loadInSlide(index); | |
| 6391 | + }); | |
| 6392 | + } else if (slidesPerView > 1) { | |
| 6393 | + for (var i = activeIndex; i < activeIndex + slidesPerView; i += 1) { | |
| 6394 | + if (slideExist(i)) { swiper.lazy.loadInSlide(i); } | |
| 6395 | + } | |
| 6396 | + } else { | |
| 6397 | + swiper.lazy.loadInSlide(activeIndex); | |
| 6398 | + } | |
| 6399 | + if (params.loadPrevNext) { | |
| 6400 | + if (slidesPerView > 1 || (params.loadPrevNextAmount && params.loadPrevNextAmount > 1)) { | |
| 6401 | + var amount = params.loadPrevNextAmount; | |
| 6402 | + var spv = slidesPerView; | |
| 6403 | + var maxIndex = Math.min(activeIndex + spv + Math.max(amount, spv), slides.length); | |
| 6404 | + var minIndex = Math.max(activeIndex - Math.max(spv, amount), 0); | |
| 6405 | + // Next Slides | |
| 6406 | + for (var i$1 = activeIndex + slidesPerView; i$1 < maxIndex; i$1 += 1) { | |
| 6407 | + if (slideExist(i$1)) { swiper.lazy.loadInSlide(i$1); } | |
| 6408 | + } | |
| 6409 | + // Prev Slides | |
| 6410 | + for (var i$2 = minIndex; i$2 < activeIndex; i$2 += 1) { | |
| 6411 | + if (slideExist(i$2)) { swiper.lazy.loadInSlide(i$2); } | |
| 6412 | + } | |
| 6413 | + } else { | |
| 6414 | + var nextSlide = $wrapperEl.children(("." + (swiperParams.slideNextClass))); | |
| 6415 | + if (nextSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(nextSlide)); } | |
| 6416 | + | |
| 6417 | + var prevSlide = $wrapperEl.children(("." + (swiperParams.slidePrevClass))); | |
| 6418 | + if (prevSlide.length > 0) { swiper.lazy.loadInSlide(slideIndex(prevSlide)); } | |
| 6419 | + } | |
| 6420 | + } | |
| 6421 | + }, | |
| 6422 | + }; | |
| 6423 | + | |
| 6424 | + var Lazy$1 = { | |
| 6425 | + name: 'lazy', | |
| 6426 | + params: { | |
| 6427 | + lazy: { | |
| 6428 | + enabled: false, | |
| 6429 | + loadPrevNext: false, | |
| 6430 | + loadPrevNextAmount: 1, | |
| 6431 | + loadOnTransitionStart: false, | |
| 6432 | + | |
| 6433 | + elementClass: 'swiper-lazy', | |
| 6434 | + loadingClass: 'swiper-lazy-loading', | |
| 6435 | + loadedClass: 'swiper-lazy-loaded', | |
| 6436 | + preloaderClass: 'swiper-lazy-preloader', | |
| 6437 | + }, | |
| 6438 | + }, | |
| 6439 | + create: function create() { | |
| 6440 | + var swiper = this; | |
| 6441 | + Utils.extend(swiper, { | |
| 6442 | + lazy: { | |
| 6443 | + initialImageLoaded: false, | |
| 6444 | + load: Lazy.load.bind(swiper), | |
| 6445 | + loadInSlide: Lazy.loadInSlide.bind(swiper), | |
| 6446 | + }, | |
| 6447 | + }); | |
| 6448 | + }, | |
| 6449 | + on: { | |
| 6450 | + beforeInit: function beforeInit() { | |
| 6451 | + var swiper = this; | |
| 6452 | + if (swiper.params.lazy.enabled && swiper.params.preloadImages) { | |
| 6453 | + swiper.params.preloadImages = false; | |
| 6454 | + } | |
| 6455 | + }, | |
| 6456 | + init: function init() { | |
| 6457 | + var swiper = this; | |
| 6458 | + if (swiper.params.lazy.enabled && !swiper.params.loop && swiper.params.initialSlide === 0) { | |
| 6459 | + swiper.lazy.load(); | |
| 6460 | + } | |
| 6461 | + }, | |
| 6462 | + scroll: function scroll() { | |
| 6463 | + var swiper = this; | |
| 6464 | + if (swiper.params.freeMode && !swiper.params.freeModeSticky) { | |
| 6465 | + swiper.lazy.load(); | |
| 6466 | + } | |
| 6467 | + }, | |
| 6468 | + resize: function resize() { | |
| 6469 | + var swiper = this; | |
| 6470 | + if (swiper.params.lazy.enabled) { | |
| 6471 | + swiper.lazy.load(); | |
| 6472 | + } | |
| 6473 | + }, | |
| 6474 | + scrollbarDragMove: function scrollbarDragMove() { | |
| 6475 | + var swiper = this; | |
| 6476 | + if (swiper.params.lazy.enabled) { | |
| 6477 | + swiper.lazy.load(); | |
| 6478 | + } | |
| 6479 | + }, | |
| 6480 | + transitionStart: function transitionStart() { | |
| 6481 | + var swiper = this; | |
| 6482 | + if (swiper.params.lazy.enabled) { | |
| 6483 | + if (swiper.params.lazy.loadOnTransitionStart || (!swiper.params.lazy.loadOnTransitionStart && !swiper.lazy.initialImageLoaded)) { | |
| 6484 | + swiper.lazy.load(); | |
| 6485 | + } | |
| 6486 | + } | |
| 6487 | + }, | |
| 6488 | + transitionEnd: function transitionEnd() { | |
| 6489 | + var swiper = this; | |
| 6490 | + if (swiper.params.lazy.enabled && !swiper.params.lazy.loadOnTransitionStart) { | |
| 6491 | + swiper.lazy.load(); | |
| 6492 | + } | |
| 6493 | + }, | |
| 6494 | + }, | |
| 6495 | + }; | |
| 6496 | + | |
| 6497 | + /* eslint no-bitwise: ["error", { "allow": [">>"] }] */ | |
| 6498 | + | |
| 6499 | + var Controller = { | |
| 6500 | + LinearSpline: function LinearSpline(x, y) { | |
| 6501 | + var binarySearch = (function search() { | |
| 6502 | + var maxIndex; | |
| 6503 | + var minIndex; | |
| 6504 | + var guess; | |
| 6505 | + return function (array, val) { | |
| 6506 | + minIndex = -1; | |
| 6507 | + maxIndex = array.length; | |
| 6508 | + while (maxIndex - minIndex > 1) { | |
| 6509 | + guess = maxIndex + minIndex >> 1; | |
| 6510 | + if (array[guess] <= val) { | |
| 6511 | + minIndex = guess; | |
| 6512 | + } else { | |
| 6513 | + maxIndex = guess; | |
| 6514 | + } | |
| 6515 | + } | |
| 6516 | + return maxIndex; | |
| 6517 | + }; | |
| 6518 | + }()); | |
| 6519 | + this.x = x; | |
| 6520 | + this.y = y; | |
| 6521 | + this.lastIndex = x.length - 1; | |
| 6522 | + // Given an x value (x2), return the expected y2 value: | |
| 6523 | + // (x1,y1) is the known point before given value, | |
| 6524 | + // (x3,y3) is the known point after given value. | |
| 6525 | + var i1; | |
| 6526 | + var i3; | |
| 6527 | + | |
| 6528 | + this.interpolate = function interpolate(x2) { | |
| 6529 | + if (!x2) { return 0; } | |
| 6530 | + | |
| 6531 | + // Get the indexes of x1 and x3 (the array indexes before and after given x2): | |
| 6532 | + i3 = binarySearch(this.x, x2); | |
| 6533 | + i1 = i3 - 1; | |
| 6534 | + | |
| 6535 | + // We have our indexes i1 & i3, so we can calculate already: | |
| 6536 | + // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1 | |
| 6537 | + return (((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1])) + this.y[i1]; | |
| 6538 | + }; | |
| 6539 | + return this; | |
| 6540 | + }, | |
| 6541 | + // xxx: for now i will just save one spline function to to | |
| 6542 | + getInterpolateFunction: function getInterpolateFunction(c) { | |
| 6543 | + var swiper = this; | |
| 6544 | + if (!swiper.controller.spline) { | |
| 6545 | + swiper.controller.spline = swiper.params.loop | |
| 6546 | + ? new Controller.LinearSpline(swiper.slidesGrid, c.slidesGrid) | |
| 6547 | + : new Controller.LinearSpline(swiper.snapGrid, c.snapGrid); | |
| 6548 | + } | |
| 6549 | + }, | |
| 6550 | + setTranslate: function setTranslate(setTranslate$1, byController) { | |
| 6551 | + var swiper = this; | |
| 6552 | + var controlled = swiper.controller.control; | |
| 6553 | + var multiplier; | |
| 6554 | + var controlledTranslate; | |
| 6555 | + function setControlledTranslate(c) { | |
| 6556 | + // this will create an Interpolate function based on the snapGrids | |
| 6557 | + // x is the Grid of the scrolled scroller and y will be the controlled scroller | |
| 6558 | + // it makes sense to create this only once and recall it for the interpolation | |
| 6559 | + // the function does a lot of value caching for performance | |
| 6560 | + var translate = swiper.rtlTranslate ? -swiper.translate : swiper.translate; | |
| 6561 | + if (swiper.params.controller.by === 'slide') { | |
| 6562 | + swiper.controller.getInterpolateFunction(c); | |
| 6563 | + // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid | |
| 6564 | + // but it did not work out | |
| 6565 | + controlledTranslate = -swiper.controller.spline.interpolate(-translate); | |
| 6566 | + } | |
| 6567 | + | |
| 6568 | + if (!controlledTranslate || swiper.params.controller.by === 'container') { | |
| 6569 | + multiplier = (c.maxTranslate() - c.minTranslate()) / (swiper.maxTranslate() - swiper.minTranslate()); | |
| 6570 | + controlledTranslate = ((translate - swiper.minTranslate()) * multiplier) + c.minTranslate(); | |
| 6571 | + } | |
| 6572 | + | |
| 6573 | + if (swiper.params.controller.inverse) { | |
| 6574 | + controlledTranslate = c.maxTranslate() - controlledTranslate; | |
| 6575 | + } | |
| 6576 | + c.updateProgress(controlledTranslate); | |
| 6577 | + c.setTranslate(controlledTranslate, swiper); | |
| 6578 | + c.updateActiveIndex(); | |
| 6579 | + c.updateSlidesClasses(); | |
| 6580 | + } | |
| 6581 | + if (Array.isArray(controlled)) { | |
| 6582 | + for (var i = 0; i < controlled.length; i += 1) { | |
| 6583 | + if (controlled[i] !== byController && controlled[i] instanceof Swiper) { | |
| 6584 | + setControlledTranslate(controlled[i]); | |
| 6585 | + } | |
| 6586 | + } | |
| 6587 | + } else if (controlled instanceof Swiper && byController !== controlled) { | |
| 6588 | + setControlledTranslate(controlled); | |
| 6589 | + } | |
| 6590 | + }, | |
| 6591 | + setTransition: function setTransition(duration, byController) { | |
| 6592 | + var swiper = this; | |
| 6593 | + var controlled = swiper.controller.control; | |
| 6594 | + var i; | |
| 6595 | + function setControlledTransition(c) { | |
| 6596 | + c.setTransition(duration, swiper); | |
| 6597 | + if (duration !== 0) { | |
| 6598 | + c.transitionStart(); | |
| 6599 | + if (c.params.autoHeight) { | |
| 6600 | + Utils.nextTick(function () { | |
| 6601 | + c.updateAutoHeight(); | |
| 6602 | + }); | |
| 6603 | + } | |
| 6604 | + c.$wrapperEl.transitionEnd(function () { | |
| 6605 | + if (!controlled) { return; } | |
| 6606 | + if (c.params.loop && swiper.params.controller.by === 'slide') { | |
| 6607 | + c.loopFix(); | |
| 6608 | + } | |
| 6609 | + c.transitionEnd(); | |
| 6610 | + }); | |
| 6611 | + } | |
| 6612 | + } | |
| 6613 | + if (Array.isArray(controlled)) { | |
| 6614 | + for (i = 0; i < controlled.length; i += 1) { | |
| 6615 | + if (controlled[i] !== byController && controlled[i] instanceof Swiper) { | |
| 6616 | + setControlledTransition(controlled[i]); | |
| 6617 | + } | |
| 6618 | + } | |
| 6619 | + } else if (controlled instanceof Swiper && byController !== controlled) { | |
| 6620 | + setControlledTransition(controlled); | |
| 6621 | + } | |
| 6622 | + }, | |
| 6623 | + }; | |
| 6624 | + var Controller$1 = { | |
| 6625 | + name: 'controller', | |
| 6626 | + params: { | |
| 6627 | + controller: { | |
| 6628 | + control: undefined, | |
| 6629 | + inverse: false, | |
| 6630 | + by: 'slide', // or 'container' | |
| 6631 | + }, | |
| 6632 | + }, | |
| 6633 | + create: function create() { | |
| 6634 | + var swiper = this; | |
| 6635 | + Utils.extend(swiper, { | |
| 6636 | + controller: { | |
| 6637 | + control: swiper.params.controller.control, | |
| 6638 | + getInterpolateFunction: Controller.getInterpolateFunction.bind(swiper), | |
| 6639 | + setTranslate: Controller.setTranslate.bind(swiper), | |
| 6640 | + setTransition: Controller.setTransition.bind(swiper), | |
| 6641 | + }, | |
| 6642 | + }); | |
| 6643 | + }, | |
| 6644 | + on: { | |
| 6645 | + update: function update() { | |
| 6646 | + var swiper = this; | |
| 6647 | + if (!swiper.controller.control) { return; } | |
| 6648 | + if (swiper.controller.spline) { | |
| 6649 | + swiper.controller.spline = undefined; | |
| 6650 | + delete swiper.controller.spline; | |
| 6651 | + } | |
| 6652 | + }, | |
| 6653 | + resize: function resize() { | |
| 6654 | + var swiper = this; | |
| 6655 | + if (!swiper.controller.control) { return; } | |
| 6656 | + if (swiper.controller.spline) { | |
| 6657 | + swiper.controller.spline = undefined; | |
| 6658 | + delete swiper.controller.spline; | |
| 6659 | + } | |
| 6660 | + }, | |
| 6661 | + observerUpdate: function observerUpdate() { | |
| 6662 | + var swiper = this; | |
| 6663 | + if (!swiper.controller.control) { return; } | |
| 6664 | + if (swiper.controller.spline) { | |
| 6665 | + swiper.controller.spline = undefined; | |
| 6666 | + delete swiper.controller.spline; | |
| 6667 | + } | |
| 6668 | + }, | |
| 6669 | + setTranslate: function setTranslate(translate, byController) { | |
| 6670 | + var swiper = this; | |
| 6671 | + if (!swiper.controller.control) { return; } | |
| 6672 | + swiper.controller.setTranslate(translate, byController); | |
| 6673 | + }, | |
| 6674 | + setTransition: function setTransition(duration, byController) { | |
| 6675 | + var swiper = this; | |
| 6676 | + if (!swiper.controller.control) { return; } | |
| 6677 | + swiper.controller.setTransition(duration, byController); | |
| 6678 | + }, | |
| 6679 | + }, | |
| 6680 | + }; | |
| 6681 | + | |
| 6682 | + var a11y = { | |
| 6683 | + makeElFocusable: function makeElFocusable($el) { | |
| 6684 | + $el.attr('tabIndex', '0'); | |
| 6685 | + return $el; | |
| 6686 | + }, | |
| 6687 | + addElRole: function addElRole($el, role) { | |
| 6688 | + $el.attr('role', role); | |
| 6689 | + return $el; | |
| 6690 | + }, | |
| 6691 | + addElLabel: function addElLabel($el, label) { | |
| 6692 | + $el.attr('aria-label', label); | |
| 6693 | + return $el; | |
| 6694 | + }, | |
| 6695 | + disableEl: function disableEl($el) { | |
| 6696 | + $el.attr('aria-disabled', true); | |
| 6697 | + return $el; | |
| 6698 | + }, | |
| 6699 | + enableEl: function enableEl($el) { | |
| 6700 | + $el.attr('aria-disabled', false); | |
| 6701 | + return $el; | |
| 6702 | + }, | |
| 6703 | + onEnterKey: function onEnterKey(e) { | |
| 6704 | + var swiper = this; | |
| 6705 | + var params = swiper.params.a11y; | |
| 6706 | + if (e.keyCode !== 13) { return; } | |
| 6707 | + var $targetEl = $(e.target); | |
| 6708 | + if (swiper.navigation && swiper.navigation.$nextEl && $targetEl.is(swiper.navigation.$nextEl)) { | |
| 6709 | + if (!(swiper.isEnd && !swiper.params.loop)) { | |
| 6710 | + swiper.slideNext(); | |
| 6711 | + } | |
| 6712 | + if (swiper.isEnd) { | |
| 6713 | + swiper.a11y.notify(params.lastSlideMessage); | |
| 6714 | + } else { | |
| 6715 | + swiper.a11y.notify(params.nextSlideMessage); | |
| 6716 | + } | |
| 6717 | + } | |
| 6718 | + if (swiper.navigation && swiper.navigation.$prevEl && $targetEl.is(swiper.navigation.$prevEl)) { | |
| 6719 | + if (!(swiper.isBeginning && !swiper.params.loop)) { | |
| 6720 | + swiper.slidePrev(); | |
| 6721 | + } | |
| 6722 | + if (swiper.isBeginning) { | |
| 6723 | + swiper.a11y.notify(params.firstSlideMessage); | |
| 6724 | + } else { | |
| 6725 | + swiper.a11y.notify(params.prevSlideMessage); | |
| 6726 | + } | |
| 6727 | + } | |
| 6728 | + if (swiper.pagination && $targetEl.is(("." + (swiper.params.pagination.bulletClass)))) { | |
| 6729 | + $targetEl[0].click(); | |
| 6730 | + } | |
| 6731 | + }, | |
| 6732 | + notify: function notify(message) { | |
| 6733 | + var swiper = this; | |
| 6734 | + var notification = swiper.a11y.liveRegion; | |
| 6735 | + if (notification.length === 0) { return; } | |
| 6736 | + notification.html(''); | |
| 6737 | + notification.html(message); | |
| 6738 | + }, | |
| 6739 | + updateNavigation: function updateNavigation() { | |
| 6740 | + var swiper = this; | |
| 6741 | + | |
| 6742 | + if (swiper.params.loop) { return; } | |
| 6743 | + var ref = swiper.navigation; | |
| 6744 | + var $nextEl = ref.$nextEl; | |
| 6745 | + var $prevEl = ref.$prevEl; | |
| 6746 | + | |
| 6747 | + if ($prevEl && $prevEl.length > 0) { | |
| 6748 | + if (swiper.isBeginning) { | |
| 6749 | + swiper.a11y.disableEl($prevEl); | |
| 6750 | + } else { | |
| 6751 | + swiper.a11y.enableEl($prevEl); | |
| 6752 | + } | |
| 6753 | + } | |
| 6754 | + if ($nextEl && $nextEl.length > 0) { | |
| 6755 | + if (swiper.isEnd) { | |
| 6756 | + swiper.a11y.disableEl($nextEl); | |
| 6757 | + } else { | |
| 6758 | + swiper.a11y.enableEl($nextEl); | |
| 6759 | + } | |
| 6760 | + } | |
| 6761 | + }, | |
| 6762 | + updatePagination: function updatePagination() { | |
| 6763 | + var swiper = this; | |
| 6764 | + var params = swiper.params.a11y; | |
| 6765 | + if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { | |
| 6766 | + swiper.pagination.bullets.each(function (bulletIndex, bulletEl) { | |
| 6767 | + var $bulletEl = $(bulletEl); | |
| 6768 | + swiper.a11y.makeElFocusable($bulletEl); | |
| 6769 | + swiper.a11y.addElRole($bulletEl, 'button'); | |
| 6770 | + swiper.a11y.addElLabel($bulletEl, params.paginationBulletMessage.replace(/{{index}}/, $bulletEl.index() + 1)); | |
| 6771 | + }); | |
| 6772 | + } | |
| 6773 | + }, | |
| 6774 | + init: function init() { | |
| 6775 | + var swiper = this; | |
| 6776 | + | |
| 6777 | + swiper.$el.append(swiper.a11y.liveRegion); | |
| 6778 | + | |
| 6779 | + // Navigation | |
| 6780 | + var params = swiper.params.a11y; | |
| 6781 | + var $nextEl; | |
| 6782 | + var $prevEl; | |
| 6783 | + if (swiper.navigation && swiper.navigation.$nextEl) { | |
| 6784 | + $nextEl = swiper.navigation.$nextEl; | |
| 6785 | + } | |
| 6786 | + if (swiper.navigation && swiper.navigation.$prevEl) { | |
| 6787 | + $prevEl = swiper.navigation.$prevEl; | |
| 6788 | + } | |
| 6789 | + if ($nextEl) { | |
| 6790 | + swiper.a11y.makeElFocusable($nextEl); | |
| 6791 | + swiper.a11y.addElRole($nextEl, 'button'); | |
| 6792 | + swiper.a11y.addElLabel($nextEl, params.nextSlideMessage); | |
| 6793 | + $nextEl.on('keydown', swiper.a11y.onEnterKey); | |
| 6794 | + } | |
| 6795 | + if ($prevEl) { | |
| 6796 | + swiper.a11y.makeElFocusable($prevEl); | |
| 6797 | + swiper.a11y.addElRole($prevEl, 'button'); | |
| 6798 | + swiper.a11y.addElLabel($prevEl, params.prevSlideMessage); | |
| 6799 | + $prevEl.on('keydown', swiper.a11y.onEnterKey); | |
| 6800 | + } | |
| 6801 | + | |
| 6802 | + // Pagination | |
| 6803 | + if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { | |
| 6804 | + swiper.pagination.$el.on('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey); | |
| 6805 | + } | |
| 6806 | + }, | |
| 6807 | + destroy: function destroy() { | |
| 6808 | + var swiper = this; | |
| 6809 | + if (swiper.a11y.liveRegion && swiper.a11y.liveRegion.length > 0) { swiper.a11y.liveRegion.remove(); } | |
| 6810 | + | |
| 6811 | + var $nextEl; | |
| 6812 | + var $prevEl; | |
| 6813 | + if (swiper.navigation && swiper.navigation.$nextEl) { | |
| 6814 | + $nextEl = swiper.navigation.$nextEl; | |
| 6815 | + } | |
| 6816 | + if (swiper.navigation && swiper.navigation.$prevEl) { | |
| 6817 | + $prevEl = swiper.navigation.$prevEl; | |
| 6818 | + } | |
| 6819 | + if ($nextEl) { | |
| 6820 | + $nextEl.off('keydown', swiper.a11y.onEnterKey); | |
| 6821 | + } | |
| 6822 | + if ($prevEl) { | |
| 6823 | + $prevEl.off('keydown', swiper.a11y.onEnterKey); | |
| 6824 | + } | |
| 6825 | + | |
| 6826 | + // Pagination | |
| 6827 | + if (swiper.pagination && swiper.params.pagination.clickable && swiper.pagination.bullets && swiper.pagination.bullets.length) { | |
| 6828 | + swiper.pagination.$el.off('keydown', ("." + (swiper.params.pagination.bulletClass)), swiper.a11y.onEnterKey); | |
| 6829 | + } | |
| 6830 | + }, | |
| 6831 | + }; | |
| 6832 | + var A11y = { | |
| 6833 | + name: 'a11y', | |
| 6834 | + params: { | |
| 6835 | + a11y: { | |
| 6836 | + enabled: true, | |
| 6837 | + notificationClass: 'swiper-notification', | |
| 6838 | + prevSlideMessage: 'Previous slide', | |
| 6839 | + nextSlideMessage: 'Next slide', | |
| 6840 | + firstSlideMessage: 'This is the first slide', | |
| 6841 | + lastSlideMessage: 'This is the last slide', | |
| 6842 | + paginationBulletMessage: 'Go to slide {{index}}', | |
| 6843 | + }, | |
| 6844 | + }, | |
| 6845 | + create: function create() { | |
| 6846 | + var swiper = this; | |
| 6847 | + Utils.extend(swiper, { | |
| 6848 | + a11y: { | |
| 6849 | + liveRegion: $(("<span class=\"" + (swiper.params.a11y.notificationClass) + "\" aria-live=\"assertive\" aria-atomic=\"true\"></span>")), | |
| 6850 | + }, | |
| 6851 | + }); | |
| 6852 | + Object.keys(a11y).forEach(function (methodName) { | |
| 6853 | + swiper.a11y[methodName] = a11y[methodName].bind(swiper); | |
| 6854 | + }); | |
| 6855 | + }, | |
| 6856 | + on: { | |
| 6857 | + init: function init() { | |
| 6858 | + var swiper = this; | |
| 6859 | + if (!swiper.params.a11y.enabled) { return; } | |
| 6860 | + swiper.a11y.init(); | |
| 6861 | + swiper.a11y.updateNavigation(); | |
| 6862 | + }, | |
| 6863 | + toEdge: function toEdge() { | |
| 6864 | + var swiper = this; | |
| 6865 | + if (!swiper.params.a11y.enabled) { return; } | |
| 6866 | + swiper.a11y.updateNavigation(); | |
| 6867 | + }, | |
| 6868 | + fromEdge: function fromEdge() { | |
| 6869 | + var swiper = this; | |
| 6870 | + if (!swiper.params.a11y.enabled) { return; } | |
| 6871 | + swiper.a11y.updateNavigation(); | |
| 6872 | + }, | |
| 6873 | + paginationUpdate: function paginationUpdate() { | |
| 6874 | + var swiper = this; | |
| 6875 | + if (!swiper.params.a11y.enabled) { return; } | |
| 6876 | + swiper.a11y.updatePagination(); | |
| 6877 | + }, | |
| 6878 | + destroy: function destroy() { | |
| 6879 | + var swiper = this; | |
| 6880 | + if (!swiper.params.a11y.enabled) { return; } | |
| 6881 | + swiper.a11y.destroy(); | |
| 6882 | + }, | |
| 6883 | + }, | |
| 6884 | + }; | |
| 6885 | + | |
| 6886 | + var History = { | |
| 6887 | + init: function init() { | |
| 6888 | + var swiper = this; | |
| 6889 | + if (!swiper.params.history) { return; } | |
| 6890 | + if (!win.history || !win.history.pushState) { | |
| 6891 | + swiper.params.history.enabled = false; | |
| 6892 | + swiper.params.hashNavigation.enabled = true; | |
| 6893 | + return; | |
| 6894 | + } | |
| 6895 | + var history = swiper.history; | |
| 6896 | + history.initialized = true; | |
| 6897 | + history.paths = History.getPathValues(); | |
| 6898 | + if (!history.paths.key && !history.paths.value) { return; } | |
| 6899 | + history.scrollToSlide(0, history.paths.value, swiper.params.runCallbacksOnInit); | |
| 6900 | + if (!swiper.params.history.replaceState) { | |
| 6901 | + win.addEventListener('popstate', swiper.history.setHistoryPopState); | |
| 6902 | + } | |
| 6903 | + }, | |
| 6904 | + destroy: function destroy() { | |
| 6905 | + var swiper = this; | |
| 6906 | + if (!swiper.params.history.replaceState) { | |
| 6907 | + win.removeEventListener('popstate', swiper.history.setHistoryPopState); | |
| 6908 | + } | |
| 6909 | + }, | |
| 6910 | + setHistoryPopState: function setHistoryPopState() { | |
| 6911 | + var swiper = this; | |
| 6912 | + swiper.history.paths = History.getPathValues(); | |
| 6913 | + swiper.history.scrollToSlide(swiper.params.speed, swiper.history.paths.value, false); | |
| 6914 | + }, | |
| 6915 | + getPathValues: function getPathValues() { | |
| 6916 | + var pathArray = win.location.pathname.slice(1).split('/').filter(function (part) { return part !== ''; }); | |
| 6917 | + var total = pathArray.length; | |
| 6918 | + var key = pathArray[total - 2]; | |
| 6919 | + var value = pathArray[total - 1]; | |
| 6920 | + return { key: key, value: value }; | |
| 6921 | + }, | |
| 6922 | + setHistory: function setHistory(key, index) { | |
| 6923 | + var swiper = this; | |
| 6924 | + if (!swiper.history.initialized || !swiper.params.history.enabled) { return; } | |
| 6925 | + var slide = swiper.slides.eq(index); | |
| 6926 | + var value = History.slugify(slide.attr('data-history')); | |
| 6927 | + if (!win.location.pathname.includes(key)) { | |
| 6928 | + value = key + "/" + value; | |
| 6929 | + } | |
| 6930 | + var currentState = win.history.state; | |
| 6931 | + if (currentState && currentState.value === value) { | |
| 6932 | + return; | |
| 6933 | + } | |
| 6934 | + if (swiper.params.history.replaceState) { | |
| 6935 | + win.history.replaceState({ value: value }, null, value); | |
| 6936 | + } else { | |
| 6937 | + win.history.pushState({ value: value }, null, value); | |
| 6938 | + } | |
| 6939 | + }, | |
| 6940 | + slugify: function slugify(text) { | |
| 6941 | + return text.toString().toLowerCase() | |
| 6942 | + .replace(/\s+/g, '-') | |
| 6943 | + .replace(/[^\w-]+/g, '') | |
| 6944 | + .replace(/--+/g, '-') | |
| 6945 | + .replace(/^-+/, '') | |
| 6946 | + .replace(/-+$/, ''); | |
| 6947 | + }, | |
| 6948 | + scrollToSlide: function scrollToSlide(speed, value, runCallbacks) { | |
| 6949 | + var swiper = this; | |
| 6950 | + if (value) { | |
| 6951 | + for (var i = 0, length = swiper.slides.length; i < length; i += 1) { | |
| 6952 | + var slide = swiper.slides.eq(i); | |
| 6953 | + var slideHistory = History.slugify(slide.attr('data-history')); | |
| 6954 | + if (slideHistory === value && !slide.hasClass(swiper.params.slideDuplicateClass)) { | |
| 6955 | + var index = slide.index(); | |
| 6956 | + swiper.slideTo(index, speed, runCallbacks); | |
| 6957 | + } | |
| 6958 | + } | |
| 6959 | + } else { | |
| 6960 | + swiper.slideTo(0, speed, runCallbacks); | |
| 6961 | + } | |
| 6962 | + }, | |
| 6963 | + }; | |
| 6964 | + | |
| 6965 | + var History$1 = { | |
| 6966 | + name: 'history', | |
| 6967 | + params: { | |
| 6968 | + history: { | |
| 6969 | + enabled: false, | |
| 6970 | + replaceState: false, | |
| 6971 | + key: 'slides', | |
| 6972 | + }, | |
| 6973 | + }, | |
| 6974 | + create: function create() { | |
| 6975 | + var swiper = this; | |
| 6976 | + Utils.extend(swiper, { | |
| 6977 | + history: { | |
| 6978 | + init: History.init.bind(swiper), | |
| 6979 | + setHistory: History.setHistory.bind(swiper), | |
| 6980 | + setHistoryPopState: History.setHistoryPopState.bind(swiper), | |
| 6981 | + scrollToSlide: History.scrollToSlide.bind(swiper), | |
| 6982 | + destroy: History.destroy.bind(swiper), | |
| 6983 | + }, | |
| 6984 | + }); | |
| 6985 | + }, | |
| 6986 | + on: { | |
| 6987 | + init: function init() { | |
| 6988 | + var swiper = this; | |
| 6989 | + if (swiper.params.history.enabled) { | |
| 6990 | + swiper.history.init(); | |
| 6991 | + } | |
| 6992 | + }, | |
| 6993 | + destroy: function destroy() { | |
| 6994 | + var swiper = this; | |
| 6995 | + if (swiper.params.history.enabled) { | |
| 6996 | + swiper.history.destroy(); | |
| 6997 | + } | |
| 6998 | + }, | |
| 6999 | + transitionEnd: function transitionEnd() { | |
| 7000 | + var swiper = this; | |
| 7001 | + if (swiper.history.initialized) { | |
| 7002 | + swiper.history.setHistory(swiper.params.history.key, swiper.activeIndex); | |
| 7003 | + } | |
| 7004 | + }, | |
| 7005 | + }, | |
| 7006 | + }; | |
| 7007 | + | |
| 7008 | + var HashNavigation = { | |
| 7009 | + onHashCange: function onHashCange() { | |
| 7010 | + var swiper = this; | |
| 7011 | + var newHash = doc.location.hash.replace('#', ''); | |
| 7012 | + var activeSlideHash = swiper.slides.eq(swiper.activeIndex).attr('data-hash'); | |
| 7013 | + if (newHash !== activeSlideHash) { | |
| 7014 | + var newIndex = swiper.$wrapperEl.children(("." + (swiper.params.slideClass) + "[data-hash=\"" + newHash + "\"]")).index(); | |
| 7015 | + if (typeof newIndex === 'undefined') { return; } | |
| 7016 | + swiper.slideTo(newIndex); | |
| 7017 | + } | |
| 7018 | + }, | |
| 7019 | + setHash: function setHash() { | |
| 7020 | + var swiper = this; | |
| 7021 | + if (!swiper.hashNavigation.initialized || !swiper.params.hashNavigation.enabled) { return; } | |
| 7022 | + if (swiper.params.hashNavigation.replaceState && win.history && win.history.replaceState) { | |
| 7023 | + win.history.replaceState(null, null, (("#" + (swiper.slides.eq(swiper.activeIndex).attr('data-hash'))) || '')); | |
| 7024 | + } else { | |
| 7025 | + var slide = swiper.slides.eq(swiper.activeIndex); | |
| 7026 | + var hash = slide.attr('data-hash') || slide.attr('data-history'); | |
| 7027 | + doc.location.hash = hash || ''; | |
| 7028 | + } | |
| 7029 | + }, | |
| 7030 | + init: function init() { | |
| 7031 | + var swiper = this; | |
| 7032 | + if (!swiper.params.hashNavigation.enabled || (swiper.params.history && swiper.params.history.enabled)) { return; } | |
| 7033 | + swiper.hashNavigation.initialized = true; | |
| 7034 | + var hash = doc.location.hash.replace('#', ''); | |
| 7035 | + if (hash) { | |
| 7036 | + var speed = 0; | |
| 7037 | + for (var i = 0, length = swiper.slides.length; i < length; i += 1) { | |
| 7038 | + var slide = swiper.slides.eq(i); | |
| 7039 | + var slideHash = slide.attr('data-hash') || slide.attr('data-history'); | |
| 7040 | + if (slideHash === hash && !slide.hasClass(swiper.params.slideDuplicateClass)) { | |
| 7041 | + var index = slide.index(); | |
| 7042 | + swiper.slideTo(index, speed, swiper.params.runCallbacksOnInit, true); | |
| 7043 | + } | |
| 7044 | + } | |
| 7045 | + } | |
| 7046 | + if (swiper.params.hashNavigation.watchState) { | |
| 7047 | + $(win).on('hashchange', swiper.hashNavigation.onHashCange); | |
| 7048 | + } | |
| 7049 | + }, | |
| 7050 | + destroy: function destroy() { | |
| 7051 | + var swiper = this; | |
| 7052 | + if (swiper.params.hashNavigation.watchState) { | |
| 7053 | + $(win).off('hashchange', swiper.hashNavigation.onHashCange); | |
| 7054 | + } | |
| 7055 | + }, | |
| 7056 | + }; | |
| 7057 | + var HashNavigation$1 = { | |
| 7058 | + name: 'hash-navigation', | |
| 7059 | + params: { | |
| 7060 | + hashNavigation: { | |
| 7061 | + enabled: false, | |
| 7062 | + replaceState: false, | |
| 7063 | + watchState: false, | |
| 7064 | + }, | |
| 7065 | + }, | |
| 7066 | + create: function create() { | |
| 7067 | + var swiper = this; | |
| 7068 | + Utils.extend(swiper, { | |
| 7069 | + hashNavigation: { | |
| 7070 | + initialized: false, | |
| 7071 | + init: HashNavigation.init.bind(swiper), | |
| 7072 | + destroy: HashNavigation.destroy.bind(swiper), | |
| 7073 | + setHash: HashNavigation.setHash.bind(swiper), | |
| 7074 | + onHashCange: HashNavigation.onHashCange.bind(swiper), | |
| 7075 | + }, | |
| 7076 | + }); | |
| 7077 | + }, | |
| 7078 | + on: { | |
| 7079 | + init: function init() { | |
| 7080 | + var swiper = this; | |
| 7081 | + if (swiper.params.hashNavigation.enabled) { | |
| 7082 | + swiper.hashNavigation.init(); | |
| 7083 | + } | |
| 7084 | + }, | |
| 7085 | + destroy: function destroy() { | |
| 7086 | + var swiper = this; | |
| 7087 | + if (swiper.params.hashNavigation.enabled) { | |
| 7088 | + swiper.hashNavigation.destroy(); | |
| 7089 | + } | |
| 7090 | + }, | |
| 7091 | + transitionEnd: function transitionEnd() { | |
| 7092 | + var swiper = this; | |
| 7093 | + if (swiper.hashNavigation.initialized) { | |
| 7094 | + swiper.hashNavigation.setHash(); | |
| 7095 | + } | |
| 7096 | + }, | |
| 7097 | + }, | |
| 7098 | + }; | |
| 7099 | + | |
| 7100 | + /* eslint no-underscore-dangle: "off" */ | |
| 7101 | + | |
| 7102 | + var Autoplay = { | |
| 7103 | + run: function run() { | |
| 7104 | + var swiper = this; | |
| 7105 | + var $activeSlideEl = swiper.slides.eq(swiper.activeIndex); | |
| 7106 | + var delay = swiper.params.autoplay.delay; | |
| 7107 | + if ($activeSlideEl.attr('data-swiper-autoplay')) { | |
| 7108 | + delay = $activeSlideEl.attr('data-swiper-autoplay') || swiper.params.autoplay.delay; | |
| 7109 | + } | |
| 7110 | + swiper.autoplay.timeout = Utils.nextTick(function () { | |
| 7111 | + if (swiper.params.autoplay.reverseDirection) { | |
| 7112 | + if (swiper.params.loop) { | |
| 7113 | + swiper.loopFix(); | |
| 7114 | + swiper.slidePrev(swiper.params.speed, true, true); | |
| 7115 | + swiper.emit('autoplay'); | |
| 7116 | + } else if (!swiper.isBeginning) { | |
| 7117 | + swiper.slidePrev(swiper.params.speed, true, true); | |
| 7118 | + swiper.emit('autoplay'); | |
| 7119 | + } else if (!swiper.params.autoplay.stopOnLastSlide) { | |
| 7120 | + swiper.slideTo(swiper.slides.length - 1, swiper.params.speed, true, true); | |
| 7121 | + swiper.emit('autoplay'); | |
| 7122 | + } else { | |
| 7123 | + swiper.autoplay.stop(); | |
| 7124 | + } | |
| 7125 | + } else if (swiper.params.loop) { | |
| 7126 | + swiper.loopFix(); | |
| 7127 | + swiper.slideNext(swiper.params.speed, true, true); | |
| 7128 | + swiper.emit('autoplay'); | |
| 7129 | + } else if (!swiper.isEnd) { | |
| 7130 | + swiper.slideNext(swiper.params.speed, true, true); | |
| 7131 | + swiper.emit('autoplay'); | |
| 7132 | + } else if (!swiper.params.autoplay.stopOnLastSlide) { | |
| 7133 | + swiper.slideTo(0, swiper.params.speed, true, true); | |
| 7134 | + swiper.emit('autoplay'); | |
| 7135 | + } else { | |
| 7136 | + swiper.autoplay.stop(); | |
| 7137 | + } | |
| 7138 | + }, delay); | |
| 7139 | + }, | |
| 7140 | + start: function start() { | |
| 7141 | + var swiper = this; | |
| 7142 | + if (typeof swiper.autoplay.timeout !== 'undefined') { return false; } | |
| 7143 | + if (swiper.autoplay.running) { return false; } | |
| 7144 | + swiper.autoplay.running = true; | |
| 7145 | + swiper.emit('autoplayStart'); | |
| 7146 | + swiper.autoplay.run(); | |
| 7147 | + return true; | |
| 7148 | + }, | |
| 7149 | + stop: function stop() { | |
| 7150 | + var swiper = this; | |
| 7151 | + if (!swiper.autoplay.running) { return false; } | |
| 7152 | + if (typeof swiper.autoplay.timeout === 'undefined') { return false; } | |
| 7153 | + | |
| 7154 | + if (swiper.autoplay.timeout) { | |
| 7155 | + clearTimeout(swiper.autoplay.timeout); | |
| 7156 | + swiper.autoplay.timeout = undefined; | |
| 7157 | + } | |
| 7158 | + swiper.autoplay.running = false; | |
| 7159 | + swiper.emit('autoplayStop'); | |
| 7160 | + return true; | |
| 7161 | + }, | |
| 7162 | + pause: function pause(speed) { | |
| 7163 | + var swiper = this; | |
| 7164 | + if (!swiper.autoplay.running) { return; } | |
| 7165 | + if (swiper.autoplay.paused) { return; } | |
| 7166 | + if (swiper.autoplay.timeout) { clearTimeout(swiper.autoplay.timeout); } | |
| 7167 | + swiper.autoplay.paused = true; | |
| 7168 | + if (speed === 0 || !swiper.params.autoplay.waitForTransition) { | |
| 7169 | + swiper.autoplay.paused = false; | |
| 7170 | + swiper.autoplay.run(); | |
| 7171 | + } else { | |
| 7172 | + swiper.$wrapperEl[0].addEventListener('transitionend', swiper.autoplay.onTransitionEnd); | |
| 7173 | + swiper.$wrapperEl[0].addEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); | |
| 7174 | + } | |
| 7175 | + }, | |
| 7176 | + }; | |
| 7177 | + | |
| 7178 | + var Autoplay$1 = { | |
| 7179 | + name: 'autoplay', | |
| 7180 | + params: { | |
| 7181 | + autoplay: { | |
| 7182 | + enabled: false, | |
| 7183 | + delay: 3000, | |
| 7184 | + waitForTransition: true, | |
| 7185 | + disableOnInteraction: true, | |
| 7186 | + stopOnLastSlide: false, | |
| 7187 | + reverseDirection: false, | |
| 7188 | + }, | |
| 7189 | + }, | |
| 7190 | + create: function create() { | |
| 7191 | + var swiper = this; | |
| 7192 | + Utils.extend(swiper, { | |
| 7193 | + autoplay: { | |
| 7194 | + running: false, | |
| 7195 | + paused: false, | |
| 7196 | + run: Autoplay.run.bind(swiper), | |
| 7197 | + start: Autoplay.start.bind(swiper), | |
| 7198 | + stop: Autoplay.stop.bind(swiper), | |
| 7199 | + pause: Autoplay.pause.bind(swiper), | |
| 7200 | + onTransitionEnd: function onTransitionEnd(e) { | |
| 7201 | + if (!swiper || swiper.destroyed || !swiper.$wrapperEl) { return; } | |
| 7202 | + if (e.target !== this) { return; } | |
| 7203 | + swiper.$wrapperEl[0].removeEventListener('transitionend', swiper.autoplay.onTransitionEnd); | |
| 7204 | + swiper.$wrapperEl[0].removeEventListener('webkitTransitionEnd', swiper.autoplay.onTransitionEnd); | |
| 7205 | + swiper.autoplay.paused = false; | |
| 7206 | + if (!swiper.autoplay.running) { | |
| 7207 | + swiper.autoplay.stop(); | |
| 7208 | + } else { | |
| 7209 | + swiper.autoplay.run(); | |
| 7210 | + } | |
| 7211 | + }, | |
| 7212 | + }, | |
| 7213 | + }); | |
| 7214 | + }, | |
| 7215 | + on: { | |
| 7216 | + init: function init() { | |
| 7217 | + var swiper = this; | |
| 7218 | + if (swiper.params.autoplay.enabled) { | |
| 7219 | + swiper.autoplay.start(); | |
| 7220 | + } | |
| 7221 | + }, | |
| 7222 | + beforeTransitionStart: function beforeTransitionStart(speed, internal) { | |
| 7223 | + var swiper = this; | |
| 7224 | + if (swiper.autoplay.running) { | |
| 7225 | + if (internal || !swiper.params.autoplay.disableOnInteraction) { | |
| 7226 | + swiper.autoplay.pause(speed); | |
| 7227 | + } else { | |
| 7228 | + swiper.autoplay.stop(); | |
| 7229 | + } | |
| 7230 | + } | |
| 7231 | + }, | |
| 7232 | + sliderFirstMove: function sliderFirstMove() { | |
| 7233 | + var swiper = this; | |
| 7234 | + if (swiper.autoplay.running) { | |
| 7235 | + if (swiper.params.autoplay.disableOnInteraction) { | |
| 7236 | + swiper.autoplay.stop(); | |
| 7237 | + } else { | |
| 7238 | + swiper.autoplay.pause(); | |
| 7239 | + } | |
| 7240 | + } | |
| 7241 | + }, | |
| 7242 | + destroy: function destroy() { | |
| 7243 | + var swiper = this; | |
| 7244 | + if (swiper.autoplay.running) { | |
| 7245 | + swiper.autoplay.stop(); | |
| 7246 | + } | |
| 7247 | + }, | |
| 7248 | + }, | |
| 7249 | + }; | |
| 7250 | + | |
| 7251 | + var Fade = { | |
| 7252 | + setTranslate: function setTranslate() { | |
| 7253 | + var swiper = this; | |
| 7254 | + var slides = swiper.slides; | |
| 7255 | + for (var i = 0; i < slides.length; i += 1) { | |
| 7256 | + var $slideEl = swiper.slides.eq(i); | |
| 7257 | + var offset = $slideEl[0].swiperSlideOffset; | |
| 7258 | + var tx = -offset; | |
| 7259 | + if (!swiper.params.virtualTranslate) { tx -= swiper.translate; } | |
| 7260 | + var ty = 0; | |
| 7261 | + if (!swiper.isHorizontal()) { | |
| 7262 | + ty = tx; | |
| 7263 | + tx = 0; | |
| 7264 | + } | |
| 7265 | + var slideOpacity = swiper.params.fadeEffect.crossFade | |
| 7266 | + ? Math.max(1 - Math.abs($slideEl[0].progress), 0) | |
| 7267 | + : 1 + Math.min(Math.max($slideEl[0].progress, -1), 0); | |
| 7268 | + $slideEl | |
| 7269 | + .css({ | |
| 7270 | + opacity: slideOpacity, | |
| 7271 | + }) | |
| 7272 | + .transform(("translate3d(" + tx + "px, " + ty + "px, 0px)")); | |
| 7273 | + } | |
| 7274 | + }, | |
| 7275 | + setTransition: function setTransition(duration) { | |
| 7276 | + var swiper = this; | |
| 7277 | + var slides = swiper.slides; | |
| 7278 | + var $wrapperEl = swiper.$wrapperEl; | |
| 7279 | + slides.transition(duration); | |
| 7280 | + if (swiper.params.virtualTranslate && duration !== 0) { | |
| 7281 | + var eventTriggered = false; | |
| 7282 | + slides.transitionEnd(function () { | |
| 7283 | + if (eventTriggered) { return; } | |
| 7284 | + if (!swiper || swiper.destroyed) { return; } | |
| 7285 | + eventTriggered = true; | |
| 7286 | + swiper.animating = false; | |
| 7287 | + var triggerEvents = ['webkitTransitionEnd', 'transitionend']; | |
| 7288 | + for (var i = 0; i < triggerEvents.length; i += 1) { | |
| 7289 | + $wrapperEl.trigger(triggerEvents[i]); | |
| 7290 | + } | |
| 7291 | + }); | |
| 7292 | + } | |
| 7293 | + }, | |
| 7294 | + }; | |
| 7295 | + | |
| 7296 | + var EffectFade = { | |
| 7297 | + name: 'effect-fade', | |
| 7298 | + params: { | |
| 7299 | + fadeEffect: { | |
| 7300 | + crossFade: false, | |
| 7301 | + }, | |
| 7302 | + }, | |
| 7303 | + create: function create() { | |
| 7304 | + var swiper = this; | |
| 7305 | + Utils.extend(swiper, { | |
| 7306 | + fadeEffect: { | |
| 7307 | + setTranslate: Fade.setTranslate.bind(swiper), | |
| 7308 | + setTransition: Fade.setTransition.bind(swiper), | |
| 7309 | + }, | |
| 7310 | + }); | |
| 7311 | + }, | |
| 7312 | + on: { | |
| 7313 | + beforeInit: function beforeInit() { | |
| 7314 | + var swiper = this; | |
| 7315 | + if (swiper.params.effect !== 'fade') { return; } | |
| 7316 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "fade")); | |
| 7317 | + var overwriteParams = { | |
| 7318 | + slidesPerView: 1, | |
| 7319 | + slidesPerColumn: 1, | |
| 7320 | + slidesPerGroup: 1, | |
| 7321 | + watchSlidesProgress: true, | |
| 7322 | + spaceBetween: 0, | |
| 7323 | + virtualTranslate: true, | |
| 7324 | + }; | |
| 7325 | + Utils.extend(swiper.params, overwriteParams); | |
| 7326 | + Utils.extend(swiper.originalParams, overwriteParams); | |
| 7327 | + }, | |
| 7328 | + setTranslate: function setTranslate() { | |
| 7329 | + var swiper = this; | |
| 7330 | + if (swiper.params.effect !== 'fade') { return; } | |
| 7331 | + swiper.fadeEffect.setTranslate(); | |
| 7332 | + }, | |
| 7333 | + setTransition: function setTransition(duration) { | |
| 7334 | + var swiper = this; | |
| 7335 | + if (swiper.params.effect !== 'fade') { return; } | |
| 7336 | + swiper.fadeEffect.setTransition(duration); | |
| 7337 | + }, | |
| 7338 | + }, | |
| 7339 | + }; | |
| 7340 | + | |
| 7341 | + var Cube = { | |
| 7342 | + setTranslate: function setTranslate() { | |
| 7343 | + var swiper = this; | |
| 7344 | + var $el = swiper.$el; | |
| 7345 | + var $wrapperEl = swiper.$wrapperEl; | |
| 7346 | + var slides = swiper.slides; | |
| 7347 | + var swiperWidth = swiper.width; | |
| 7348 | + var swiperHeight = swiper.height; | |
| 7349 | + var rtl = swiper.rtlTranslate; | |
| 7350 | + var swiperSize = swiper.size; | |
| 7351 | + var params = swiper.params.cubeEffect; | |
| 7352 | + var isHorizontal = swiper.isHorizontal(); | |
| 7353 | + var isVirtual = swiper.virtual && swiper.params.virtual.enabled; | |
| 7354 | + var wrapperRotate = 0; | |
| 7355 | + var $cubeShadowEl; | |
| 7356 | + if (params.shadow) { | |
| 7357 | + if (isHorizontal) { | |
| 7358 | + $cubeShadowEl = $wrapperEl.find('.swiper-cube-shadow'); | |
| 7359 | + if ($cubeShadowEl.length === 0) { | |
| 7360 | + $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); | |
| 7361 | + $wrapperEl.append($cubeShadowEl); | |
| 7362 | + } | |
| 7363 | + $cubeShadowEl.css({ height: (swiperWidth + "px") }); | |
| 7364 | + } else { | |
| 7365 | + $cubeShadowEl = $el.find('.swiper-cube-shadow'); | |
| 7366 | + if ($cubeShadowEl.length === 0) { | |
| 7367 | + $cubeShadowEl = $('<div class="swiper-cube-shadow"></div>'); | |
| 7368 | + $el.append($cubeShadowEl); | |
| 7369 | + } | |
| 7370 | + } | |
| 7371 | + } | |
| 7372 | + for (var i = 0; i < slides.length; i += 1) { | |
| 7373 | + var $slideEl = slides.eq(i); | |
| 7374 | + var slideIndex = i; | |
| 7375 | + if (isVirtual) { | |
| 7376 | + slideIndex = parseInt($slideEl.attr('data-swiper-slide-index'), 10); | |
| 7377 | + } | |
| 7378 | + var slideAngle = slideIndex * 90; | |
| 7379 | + var round = Math.floor(slideAngle / 360); | |
| 7380 | + if (rtl) { | |
| 7381 | + slideAngle = -slideAngle; | |
| 7382 | + round = Math.floor(-slideAngle / 360); | |
| 7383 | + } | |
| 7384 | + var progress = Math.max(Math.min($slideEl[0].progress, 1), -1); | |
| 7385 | + var tx = 0; | |
| 7386 | + var ty = 0; | |
| 7387 | + var tz = 0; | |
| 7388 | + if (slideIndex % 4 === 0) { | |
| 7389 | + tx = -round * 4 * swiperSize; | |
| 7390 | + tz = 0; | |
| 7391 | + } else if ((slideIndex - 1) % 4 === 0) { | |
| 7392 | + tx = 0; | |
| 7393 | + tz = -round * 4 * swiperSize; | |
| 7394 | + } else if ((slideIndex - 2) % 4 === 0) { | |
| 7395 | + tx = swiperSize + (round * 4 * swiperSize); | |
| 7396 | + tz = swiperSize; | |
| 7397 | + } else if ((slideIndex - 3) % 4 === 0) { | |
| 7398 | + tx = -swiperSize; | |
| 7399 | + tz = (3 * swiperSize) + (swiperSize * 4 * round); | |
| 7400 | + } | |
| 7401 | + if (rtl) { | |
| 7402 | + tx = -tx; | |
| 7403 | + } | |
| 7404 | + | |
| 7405 | + if (!isHorizontal) { | |
| 7406 | + ty = tx; | |
| 7407 | + tx = 0; | |
| 7408 | + } | |
| 7409 | + | |
| 7410 | + var transform = "rotateX(" + (isHorizontal ? 0 : -slideAngle) + "deg) rotateY(" + (isHorizontal ? slideAngle : 0) + "deg) translate3d(" + tx + "px, " + ty + "px, " + tz + "px)"; | |
| 7411 | + if (progress <= 1 && progress > -1) { | |
| 7412 | + wrapperRotate = (slideIndex * 90) + (progress * 90); | |
| 7413 | + if (rtl) { wrapperRotate = (-slideIndex * 90) - (progress * 90); } | |
| 7414 | + } | |
| 7415 | + $slideEl.transform(transform); | |
| 7416 | + if (params.slideShadows) { | |
| 7417 | + // Set shadows | |
| 7418 | + var shadowBefore = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); | |
| 7419 | + var shadowAfter = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); | |
| 7420 | + if (shadowBefore.length === 0) { | |
| 7421 | + shadowBefore = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>")); | |
| 7422 | + $slideEl.append(shadowBefore); | |
| 7423 | + } | |
| 7424 | + if (shadowAfter.length === 0) { | |
| 7425 | + shadowAfter = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>")); | |
| 7426 | + $slideEl.append(shadowAfter); | |
| 7427 | + } | |
| 7428 | + if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); } | |
| 7429 | + if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); } | |
| 7430 | + } | |
| 7431 | + } | |
| 7432 | + $wrapperEl.css({ | |
| 7433 | + '-webkit-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), | |
| 7434 | + '-moz-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), | |
| 7435 | + '-ms-transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), | |
| 7436 | + 'transform-origin': ("50% 50% -" + (swiperSize / 2) + "px"), | |
| 7437 | + }); | |
| 7438 | + | |
| 7439 | + if (params.shadow) { | |
| 7440 | + if (isHorizontal) { | |
| 7441 | + $cubeShadowEl.transform(("translate3d(0px, " + ((swiperWidth / 2) + params.shadowOffset) + "px, " + (-swiperWidth / 2) + "px) rotateX(90deg) rotateZ(0deg) scale(" + (params.shadowScale) + ")")); | |
| 7442 | + } else { | |
| 7443 | + var shadowAngle = Math.abs(wrapperRotate) - (Math.floor(Math.abs(wrapperRotate) / 90) * 90); | |
| 7444 | + var multiplier = 1.5 - ( | |
| 7445 | + (Math.sin((shadowAngle * 2 * Math.PI) / 360) / 2) | |
| 7446 | + + (Math.cos((shadowAngle * 2 * Math.PI) / 360) / 2) | |
| 7447 | + ); | |
| 7448 | + var scale1 = params.shadowScale; | |
| 7449 | + var scale2 = params.shadowScale / multiplier; | |
| 7450 | + var offset = params.shadowOffset; | |
| 7451 | + $cubeShadowEl.transform(("scale3d(" + scale1 + ", 1, " + scale2 + ") translate3d(0px, " + ((swiperHeight / 2) + offset) + "px, " + (-swiperHeight / 2 / scale2) + "px) rotateX(-90deg)")); | |
| 7452 | + } | |
| 7453 | + } | |
| 7454 | + var zFactor = (Browser.isSafari || Browser.isUiWebView) ? (-swiperSize / 2) : 0; | |
| 7455 | + $wrapperEl | |
| 7456 | + .transform(("translate3d(0px,0," + zFactor + "px) rotateX(" + (swiper.isHorizontal() ? 0 : wrapperRotate) + "deg) rotateY(" + (swiper.isHorizontal() ? -wrapperRotate : 0) + "deg)")); | |
| 7457 | + }, | |
| 7458 | + setTransition: function setTransition(duration) { | |
| 7459 | + var swiper = this; | |
| 7460 | + var $el = swiper.$el; | |
| 7461 | + var slides = swiper.slides; | |
| 7462 | + slides | |
| 7463 | + .transition(duration) | |
| 7464 | + .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') | |
| 7465 | + .transition(duration); | |
| 7466 | + if (swiper.params.cubeEffect.shadow && !swiper.isHorizontal()) { | |
| 7467 | + $el.find('.swiper-cube-shadow').transition(duration); | |
| 7468 | + } | |
| 7469 | + }, | |
| 7470 | + }; | |
| 7471 | + | |
| 7472 | + var EffectCube = { | |
| 7473 | + name: 'effect-cube', | |
| 7474 | + params: { | |
| 7475 | + cubeEffect: { | |
| 7476 | + slideShadows: true, | |
| 7477 | + shadow: true, | |
| 7478 | + shadowOffset: 20, | |
| 7479 | + shadowScale: 0.94, | |
| 7480 | + }, | |
| 7481 | + }, | |
| 7482 | + create: function create() { | |
| 7483 | + var swiper = this; | |
| 7484 | + Utils.extend(swiper, { | |
| 7485 | + cubeEffect: { | |
| 7486 | + setTranslate: Cube.setTranslate.bind(swiper), | |
| 7487 | + setTransition: Cube.setTransition.bind(swiper), | |
| 7488 | + }, | |
| 7489 | + }); | |
| 7490 | + }, | |
| 7491 | + on: { | |
| 7492 | + beforeInit: function beforeInit() { | |
| 7493 | + var swiper = this; | |
| 7494 | + if (swiper.params.effect !== 'cube') { return; } | |
| 7495 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "cube")); | |
| 7496 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); | |
| 7497 | + var overwriteParams = { | |
| 7498 | + slidesPerView: 1, | |
| 7499 | + slidesPerColumn: 1, | |
| 7500 | + slidesPerGroup: 1, | |
| 7501 | + watchSlidesProgress: true, | |
| 7502 | + resistanceRatio: 0, | |
| 7503 | + spaceBetween: 0, | |
| 7504 | + centeredSlides: false, | |
| 7505 | + virtualTranslate: true, | |
| 7506 | + }; | |
| 7507 | + Utils.extend(swiper.params, overwriteParams); | |
| 7508 | + Utils.extend(swiper.originalParams, overwriteParams); | |
| 7509 | + }, | |
| 7510 | + setTranslate: function setTranslate() { | |
| 7511 | + var swiper = this; | |
| 7512 | + if (swiper.params.effect !== 'cube') { return; } | |
| 7513 | + swiper.cubeEffect.setTranslate(); | |
| 7514 | + }, | |
| 7515 | + setTransition: function setTransition(duration) { | |
| 7516 | + var swiper = this; | |
| 7517 | + if (swiper.params.effect !== 'cube') { return; } | |
| 7518 | + swiper.cubeEffect.setTransition(duration); | |
| 7519 | + }, | |
| 7520 | + }, | |
| 7521 | + }; | |
| 7522 | + | |
| 7523 | + var Flip = { | |
| 7524 | + setTranslate: function setTranslate() { | |
| 7525 | + var swiper = this; | |
| 7526 | + var slides = swiper.slides; | |
| 7527 | + var rtl = swiper.rtlTranslate; | |
| 7528 | + for (var i = 0; i < slides.length; i += 1) { | |
| 7529 | + var $slideEl = slides.eq(i); | |
| 7530 | + var progress = $slideEl[0].progress; | |
| 7531 | + if (swiper.params.flipEffect.limitRotation) { | |
| 7532 | + progress = Math.max(Math.min($slideEl[0].progress, 1), -1); | |
| 7533 | + } | |
| 7534 | + var offset = $slideEl[0].swiperSlideOffset; | |
| 7535 | + var rotate = -180 * progress; | |
| 7536 | + var rotateY = rotate; | |
| 7537 | + var rotateX = 0; | |
| 7538 | + var tx = -offset; | |
| 7539 | + var ty = 0; | |
| 7540 | + if (!swiper.isHorizontal()) { | |
| 7541 | + ty = tx; | |
| 7542 | + tx = 0; | |
| 7543 | + rotateX = -rotateY; | |
| 7544 | + rotateY = 0; | |
| 7545 | + } else if (rtl) { | |
| 7546 | + rotateY = -rotateY; | |
| 7547 | + } | |
| 7548 | + | |
| 7549 | + $slideEl[0].style.zIndex = -Math.abs(Math.round(progress)) + slides.length; | |
| 7550 | + | |
| 7551 | + if (swiper.params.flipEffect.slideShadows) { | |
| 7552 | + // Set shadows | |
| 7553 | + var shadowBefore = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); | |
| 7554 | + var shadowAfter = swiper.isHorizontal() ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); | |
| 7555 | + if (shadowBefore.length === 0) { | |
| 7556 | + shadowBefore = $(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'left' : 'top') + "\"></div>")); | |
| 7557 | + $slideEl.append(shadowBefore); | |
| 7558 | + } | |
| 7559 | + if (shadowAfter.length === 0) { | |
| 7560 | + shadowAfter = $(("<div class=\"swiper-slide-shadow-" + (swiper.isHorizontal() ? 'right' : 'bottom') + "\"></div>")); | |
| 7561 | + $slideEl.append(shadowAfter); | |
| 7562 | + } | |
| 7563 | + if (shadowBefore.length) { shadowBefore[0].style.opacity = Math.max(-progress, 0); } | |
| 7564 | + if (shadowAfter.length) { shadowAfter[0].style.opacity = Math.max(progress, 0); } | |
| 7565 | + } | |
| 7566 | + $slideEl | |
| 7567 | + .transform(("translate3d(" + tx + "px, " + ty + "px, 0px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)")); | |
| 7568 | + } | |
| 7569 | + }, | |
| 7570 | + setTransition: function setTransition(duration) { | |
| 7571 | + var swiper = this; | |
| 7572 | + var slides = swiper.slides; | |
| 7573 | + var activeIndex = swiper.activeIndex; | |
| 7574 | + var $wrapperEl = swiper.$wrapperEl; | |
| 7575 | + slides | |
| 7576 | + .transition(duration) | |
| 7577 | + .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') | |
| 7578 | + .transition(duration); | |
| 7579 | + if (swiper.params.virtualTranslate && duration !== 0) { | |
| 7580 | + var eventTriggered = false; | |
| 7581 | + // eslint-disable-next-line | |
| 7582 | + slides.eq(activeIndex).transitionEnd(function onTransitionEnd() { | |
| 7583 | + if (eventTriggered) { return; } | |
| 7584 | + if (!swiper || swiper.destroyed) { return; } | |
| 7585 | + // if (!$(this).hasClass(swiper.params.slideActiveClass)) return; | |
| 7586 | + eventTriggered = true; | |
| 7587 | + swiper.animating = false; | |
| 7588 | + var triggerEvents = ['webkitTransitionEnd', 'transitionend']; | |
| 7589 | + for (var i = 0; i < triggerEvents.length; i += 1) { | |
| 7590 | + $wrapperEl.trigger(triggerEvents[i]); | |
| 7591 | + } | |
| 7592 | + }); | |
| 7593 | + } | |
| 7594 | + }, | |
| 7595 | + }; | |
| 7596 | + | |
| 7597 | + var EffectFlip = { | |
| 7598 | + name: 'effect-flip', | |
| 7599 | + params: { | |
| 7600 | + flipEffect: { | |
| 7601 | + slideShadows: true, | |
| 7602 | + limitRotation: true, | |
| 7603 | + }, | |
| 7604 | + }, | |
| 7605 | + create: function create() { | |
| 7606 | + var swiper = this; | |
| 7607 | + Utils.extend(swiper, { | |
| 7608 | + flipEffect: { | |
| 7609 | + setTranslate: Flip.setTranslate.bind(swiper), | |
| 7610 | + setTransition: Flip.setTransition.bind(swiper), | |
| 7611 | + }, | |
| 7612 | + }); | |
| 7613 | + }, | |
| 7614 | + on: { | |
| 7615 | + beforeInit: function beforeInit() { | |
| 7616 | + var swiper = this; | |
| 7617 | + if (swiper.params.effect !== 'flip') { return; } | |
| 7618 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "flip")); | |
| 7619 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); | |
| 7620 | + var overwriteParams = { | |
| 7621 | + slidesPerView: 1, | |
| 7622 | + slidesPerColumn: 1, | |
| 7623 | + slidesPerGroup: 1, | |
| 7624 | + watchSlidesProgress: true, | |
| 7625 | + spaceBetween: 0, | |
| 7626 | + virtualTranslate: true, | |
| 7627 | + }; | |
| 7628 | + Utils.extend(swiper.params, overwriteParams); | |
| 7629 | + Utils.extend(swiper.originalParams, overwriteParams); | |
| 7630 | + }, | |
| 7631 | + setTranslate: function setTranslate() { | |
| 7632 | + var swiper = this; | |
| 7633 | + if (swiper.params.effect !== 'flip') { return; } | |
| 7634 | + swiper.flipEffect.setTranslate(); | |
| 7635 | + }, | |
| 7636 | + setTransition: function setTransition(duration) { | |
| 7637 | + var swiper = this; | |
| 7638 | + if (swiper.params.effect !== 'flip') { return; } | |
| 7639 | + swiper.flipEffect.setTransition(duration); | |
| 7640 | + }, | |
| 7641 | + }, | |
| 7642 | + }; | |
| 7643 | + | |
| 7644 | + var Coverflow = { | |
| 7645 | + setTranslate: function setTranslate() { | |
| 7646 | + var swiper = this; | |
| 7647 | + var swiperWidth = swiper.width; | |
| 7648 | + var swiperHeight = swiper.height; | |
| 7649 | + var slides = swiper.slides; | |
| 7650 | + var $wrapperEl = swiper.$wrapperEl; | |
| 7651 | + var slidesSizesGrid = swiper.slidesSizesGrid; | |
| 7652 | + var params = swiper.params.coverflowEffect; | |
| 7653 | + var isHorizontal = swiper.isHorizontal(); | |
| 7654 | + var transform = swiper.translate; | |
| 7655 | + var center = isHorizontal ? -transform + (swiperWidth / 2) : -transform + (swiperHeight / 2); | |
| 7656 | + var rotate = isHorizontal ? params.rotate : -params.rotate; | |
| 7657 | + var translate = params.depth; | |
| 7658 | + // Each slide offset from center | |
| 7659 | + for (var i = 0, length = slides.length; i < length; i += 1) { | |
| 7660 | + var $slideEl = slides.eq(i); | |
| 7661 | + var slideSize = slidesSizesGrid[i]; | |
| 7662 | + var slideOffset = $slideEl[0].swiperSlideOffset; | |
| 7663 | + var offsetMultiplier = ((center - slideOffset - (slideSize / 2)) / slideSize) * params.modifier; | |
| 7664 | + | |
| 7665 | + var rotateY = isHorizontal ? rotate * offsetMultiplier : 0; | |
| 7666 | + var rotateX = isHorizontal ? 0 : rotate * offsetMultiplier; | |
| 7667 | + // var rotateZ = 0 | |
| 7668 | + var translateZ = -translate * Math.abs(offsetMultiplier); | |
| 7669 | + | |
| 7670 | + var translateY = isHorizontal ? 0 : params.stretch * (offsetMultiplier); | |
| 7671 | + var translateX = isHorizontal ? params.stretch * (offsetMultiplier) : 0; | |
| 7672 | + | |
| 7673 | + // Fix for ultra small values | |
| 7674 | + if (Math.abs(translateX) < 0.001) { translateX = 0; } | |
| 7675 | + if (Math.abs(translateY) < 0.001) { translateY = 0; } | |
| 7676 | + if (Math.abs(translateZ) < 0.001) { translateZ = 0; } | |
| 7677 | + if (Math.abs(rotateY) < 0.001) { rotateY = 0; } | |
| 7678 | + if (Math.abs(rotateX) < 0.001) { rotateX = 0; } | |
| 7679 | + | |
| 7680 | + var slideTransform = "translate3d(" + translateX + "px," + translateY + "px," + translateZ + "px) rotateX(" + rotateX + "deg) rotateY(" + rotateY + "deg)"; | |
| 7681 | + | |
| 7682 | + $slideEl.transform(slideTransform); | |
| 7683 | + $slideEl[0].style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1; | |
| 7684 | + if (params.slideShadows) { | |
| 7685 | + // Set shadows | |
| 7686 | + var $shadowBeforeEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-left') : $slideEl.find('.swiper-slide-shadow-top'); | |
| 7687 | + var $shadowAfterEl = isHorizontal ? $slideEl.find('.swiper-slide-shadow-right') : $slideEl.find('.swiper-slide-shadow-bottom'); | |
| 7688 | + if ($shadowBeforeEl.length === 0) { | |
| 7689 | + $shadowBeforeEl = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'left' : 'top') + "\"></div>")); | |
| 7690 | + $slideEl.append($shadowBeforeEl); | |
| 7691 | + } | |
| 7692 | + if ($shadowAfterEl.length === 0) { | |
| 7693 | + $shadowAfterEl = $(("<div class=\"swiper-slide-shadow-" + (isHorizontal ? 'right' : 'bottom') + "\"></div>")); | |
| 7694 | + $slideEl.append($shadowAfterEl); | |
| 7695 | + } | |
| 7696 | + if ($shadowBeforeEl.length) { $shadowBeforeEl[0].style.opacity = offsetMultiplier > 0 ? offsetMultiplier : 0; } | |
| 7697 | + if ($shadowAfterEl.length) { $shadowAfterEl[0].style.opacity = (-offsetMultiplier) > 0 ? -offsetMultiplier : 0; } | |
| 7698 | + } | |
| 7699 | + } | |
| 7700 | + | |
| 7701 | + // Set correct perspective for IE10 | |
| 7702 | + if (Support.pointerEvents || Support.prefixedPointerEvents) { | |
| 7703 | + var ws = $wrapperEl[0].style; | |
| 7704 | + ws.perspectiveOrigin = center + "px 50%"; | |
| 7705 | + } | |
| 7706 | + }, | |
| 7707 | + setTransition: function setTransition(duration) { | |
| 7708 | + var swiper = this; | |
| 7709 | + swiper.slides | |
| 7710 | + .transition(duration) | |
| 7711 | + .find('.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left') | |
| 7712 | + .transition(duration); | |
| 7713 | + }, | |
| 7714 | + }; | |
| 7715 | + | |
| 7716 | + var EffectCoverflow = { | |
| 7717 | + name: 'effect-coverflow', | |
| 7718 | + params: { | |
| 7719 | + coverflowEffect: { | |
| 7720 | + rotate: 50, | |
| 7721 | + stretch: 0, | |
| 7722 | + depth: 100, | |
| 7723 | + modifier: 1, | |
| 7724 | + slideShadows: true, | |
| 7725 | + }, | |
| 7726 | + }, | |
| 7727 | + create: function create() { | |
| 7728 | + var swiper = this; | |
| 7729 | + Utils.extend(swiper, { | |
| 7730 | + coverflowEffect: { | |
| 7731 | + setTranslate: Coverflow.setTranslate.bind(swiper), | |
| 7732 | + setTransition: Coverflow.setTransition.bind(swiper), | |
| 7733 | + }, | |
| 7734 | + }); | |
| 7735 | + }, | |
| 7736 | + on: { | |
| 7737 | + beforeInit: function beforeInit() { | |
| 7738 | + var swiper = this; | |
| 7739 | + if (swiper.params.effect !== 'coverflow') { return; } | |
| 7740 | + | |
| 7741 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "coverflow")); | |
| 7742 | + swiper.classNames.push(((swiper.params.containerModifierClass) + "3d")); | |
| 7743 | + | |
| 7744 | + swiper.params.watchSlidesProgress = true; | |
| 7745 | + swiper.originalParams.watchSlidesProgress = true; | |
| 7746 | + }, | |
| 7747 | + setTranslate: function setTranslate() { | |
| 7748 | + var swiper = this; | |
| 7749 | + if (swiper.params.effect !== 'coverflow') { return; } | |
| 7750 | + swiper.coverflowEffect.setTranslate(); | |
| 7751 | + }, | |
| 7752 | + setTransition: function setTransition(duration) { | |
| 7753 | + var swiper = this; | |
| 7754 | + if (swiper.params.effect !== 'coverflow') { return; } | |
| 7755 | + swiper.coverflowEffect.setTransition(duration); | |
| 7756 | + }, | |
| 7757 | + }, | |
| 7758 | + }; | |
| 7759 | + | |
| 7760 | + var Thumbs = { | |
| 7761 | + init: function init() { | |
| 7762 | + var swiper = this; | |
| 7763 | + var ref = swiper.params; | |
| 7764 | + var thumbsParams = ref.thumbs; | |
| 7765 | + var SwiperClass = swiper.constructor; | |
| 7766 | + if (thumbsParams.swiper instanceof SwiperClass) { | |
| 7767 | + swiper.thumbs.swiper = thumbsParams.swiper; | |
| 7768 | + Utils.extend(swiper.thumbs.swiper.originalParams, { | |
| 7769 | + watchSlidesProgress: true, | |
| 7770 | + slideToClickedSlide: false, | |
| 7771 | + }); | |
| 7772 | + Utils.extend(swiper.thumbs.swiper.params, { | |
| 7773 | + watchSlidesProgress: true, | |
| 7774 | + slideToClickedSlide: false, | |
| 7775 | + }); | |
| 7776 | + } else if (Utils.isObject(thumbsParams.swiper)) { | |
| 7777 | + swiper.thumbs.swiper = new SwiperClass(Utils.extend({}, thumbsParams.swiper, { | |
| 7778 | + watchSlidesVisibility: true, | |
| 7779 | + watchSlidesProgress: true, | |
| 7780 | + slideToClickedSlide: false, | |
| 7781 | + })); | |
| 7782 | + swiper.thumbs.swiperCreated = true; | |
| 7783 | + } | |
| 7784 | + swiper.thumbs.swiper.$el.addClass(swiper.params.thumbs.thumbsContainerClass); | |
| 7785 | + swiper.thumbs.swiper.on('tap', swiper.thumbs.onThumbClick); | |
| 7786 | + }, | |
| 7787 | + onThumbClick: function onThumbClick() { | |
| 7788 | + var swiper = this; | |
| 7789 | + var thumbsSwiper = swiper.thumbs.swiper; | |
| 7790 | + if (!thumbsSwiper) { return; } | |
| 7791 | + var clickedIndex = thumbsSwiper.clickedIndex; | |
| 7792 | + var clickedSlide = thumbsSwiper.clickedSlide; | |
| 7793 | + if (clickedSlide && $(clickedSlide).hasClass(swiper.params.thumbs.slideThumbActiveClass)) { return; } | |
| 7794 | + if (typeof clickedIndex === 'undefined' || clickedIndex === null) { return; } | |
| 7795 | + var slideToIndex; | |
| 7796 | + if (thumbsSwiper.params.loop) { | |
| 7797 | + slideToIndex = parseInt($(thumbsSwiper.clickedSlide).attr('data-swiper-slide-index'), 10); | |
| 7798 | + } else { | |
| 7799 | + slideToIndex = clickedIndex; | |
| 7800 | + } | |
| 7801 | + if (swiper.params.loop) { | |
| 7802 | + var currentIndex = swiper.activeIndex; | |
| 7803 | + if (swiper.slides.eq(currentIndex).hasClass(swiper.params.slideDuplicateClass)) { | |
| 7804 | + swiper.loopFix(); | |
| 7805 | + // eslint-disable-next-line | |
| 7806 | + swiper._clientLeft = swiper.$wrapperEl[0].clientLeft; | |
| 7807 | + currentIndex = swiper.activeIndex; | |
| 7808 | + } | |
| 7809 | + var prevIndex = swiper.slides.eq(currentIndex).prevAll(("[data-swiper-slide-index=\"" + slideToIndex + "\"]")).eq(0).index(); | |
| 7810 | + var nextIndex = swiper.slides.eq(currentIndex).nextAll(("[data-swiper-slide-index=\"" + slideToIndex + "\"]")).eq(0).index(); | |
| 7811 | + if (typeof prevIndex === 'undefined') { slideToIndex = nextIndex; } | |
| 7812 | + else if (typeof nextIndex === 'undefined') { slideToIndex = prevIndex; } | |
| 7813 | + else if (nextIndex - currentIndex < currentIndex - prevIndex) { slideToIndex = nextIndex; } | |
| 7814 | + else { slideToIndex = prevIndex; } | |
| 7815 | + } | |
| 7816 | + swiper.slideTo(slideToIndex); | |
| 7817 | + }, | |
| 7818 | + update: function update(initial) { | |
| 7819 | + var swiper = this; | |
| 7820 | + var thumbsSwiper = swiper.thumbs.swiper; | |
| 7821 | + if (!thumbsSwiper) { return; } | |
| 7822 | + | |
| 7823 | + var slidesPerView = thumbsSwiper.params.slidesPerView === 'auto' | |
| 7824 | + ? thumbsSwiper.slidesPerViewDynamic() | |
| 7825 | + : thumbsSwiper.params.slidesPerView; | |
| 7826 | + | |
| 7827 | + if (swiper.realIndex !== thumbsSwiper.realIndex) { | |
| 7828 | + var currentThumbsIndex = thumbsSwiper.activeIndex; | |
| 7829 | + var newThumbsIndex; | |
| 7830 | + if (thumbsSwiper.params.loop) { | |
| 7831 | + if (thumbsSwiper.slides.eq(currentThumbsIndex).hasClass(thumbsSwiper.params.slideDuplicateClass)) { | |
| 7832 | + thumbsSwiper.loopFix(); | |
| 7833 | + // eslint-disable-next-line | |
| 7834 | + thumbsSwiper._clientLeft = thumbsSwiper.$wrapperEl[0].clientLeft; | |
| 7835 | + currentThumbsIndex = thumbsSwiper.activeIndex; | |
| 7836 | + } | |
| 7837 | + // Find actual thumbs index to slide to | |
| 7838 | + var prevThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).prevAll(("[data-swiper-slide-index=\"" + (swiper.realIndex) + "\"]")).eq(0).index(); | |
| 7839 | + var nextThumbsIndex = thumbsSwiper.slides.eq(currentThumbsIndex).nextAll(("[data-swiper-slide-index=\"" + (swiper.realIndex) + "\"]")).eq(0).index(); | |
| 7840 | + if (typeof prevThumbsIndex === 'undefined') { newThumbsIndex = nextThumbsIndex; } | |
| 7841 | + else if (typeof nextThumbsIndex === 'undefined') { newThumbsIndex = prevThumbsIndex; } | |
| 7842 | + else if (nextThumbsIndex - currentThumbsIndex === currentThumbsIndex - prevThumbsIndex) { newThumbsIndex = currentThumbsIndex; } | |
| 7843 | + else if (nextThumbsIndex - currentThumbsIndex < currentThumbsIndex - prevThumbsIndex) { newThumbsIndex = nextThumbsIndex; } | |
| 7844 | + else { newThumbsIndex = prevThumbsIndex; } | |
| 7845 | + } else { | |
| 7846 | + newThumbsIndex = swiper.realIndex; | |
| 7847 | + } | |
| 7848 | + if (thumbsSwiper.visibleSlidesIndexes.indexOf(newThumbsIndex) < 0) { | |
| 7849 | + if (thumbsSwiper.params.centeredSlides) { | |
| 7850 | + if (newThumbsIndex > currentThumbsIndex) { | |
| 7851 | + newThumbsIndex = newThumbsIndex - Math.floor(slidesPerView / 2) + 1; | |
| 7852 | + } else { | |
| 7853 | + newThumbsIndex = newThumbsIndex + Math.floor(slidesPerView / 2) - 1; | |
| 7854 | + } | |
| 7855 | + } else if (newThumbsIndex > currentThumbsIndex) { | |
| 7856 | + newThumbsIndex = newThumbsIndex - slidesPerView + 1; | |
| 7857 | + } | |
| 7858 | + thumbsSwiper.slideTo(newThumbsIndex, initial ? 0 : undefined); | |
| 7859 | + } | |
| 7860 | + } | |
| 7861 | + | |
| 7862 | + // Activate thumbs | |
| 7863 | + var thumbsToActivate = 1; | |
| 7864 | + var thumbActiveClass = swiper.params.thumbs.slideThumbActiveClass; | |
| 7865 | + | |
| 7866 | + if (swiper.params.slidesPerView > 1 && !swiper.params.centeredSlides) { | |
| 7867 | + thumbsToActivate = swiper.params.slidesPerView; | |
| 7868 | + } | |
| 7869 | + | |
| 7870 | + thumbsSwiper.slides.removeClass(thumbActiveClass); | |
| 7871 | + if (thumbsSwiper.params.loop) { | |
| 7872 | + for (var i = 0; i < thumbsToActivate; i += 1) { | |
| 7873 | + thumbsSwiper.$wrapperEl.children(("[data-swiper-slide-index=\"" + (swiper.realIndex + i) + "\"]")).addClass(thumbActiveClass); | |
| 7874 | + } | |
| 7875 | + } else { | |
| 7876 | + for (var i$1 = 0; i$1 < thumbsToActivate; i$1 += 1) { | |
| 7877 | + thumbsSwiper.slides.eq(swiper.realIndex + i$1).addClass(thumbActiveClass); | |
| 7878 | + } | |
| 7879 | + } | |
| 7880 | + }, | |
| 7881 | + }; | |
| 7882 | + var Thumbs$1 = { | |
| 7883 | + name: 'thumbs', | |
| 7884 | + params: { | |
| 7885 | + thumbs: { | |
| 7886 | + swiper: null, | |
| 7887 | + slideThumbActiveClass: 'swiper-slide-thumb-active', | |
| 7888 | + thumbsContainerClass: 'swiper-container-thumbs', | |
| 7889 | + }, | |
| 7890 | + }, | |
| 7891 | + create: function create() { | |
| 7892 | + var swiper = this; | |
| 7893 | + Utils.extend(swiper, { | |
| 7894 | + thumbs: { | |
| 7895 | + swiper: null, | |
| 7896 | + init: Thumbs.init.bind(swiper), | |
| 7897 | + update: Thumbs.update.bind(swiper), | |
| 7898 | + onThumbClick: Thumbs.onThumbClick.bind(swiper), | |
| 7899 | + }, | |
| 7900 | + }); | |
| 7901 | + }, | |
| 7902 | + on: { | |
| 7903 | + beforeInit: function beforeInit() { | |
| 7904 | + var swiper = this; | |
| 7905 | + var ref = swiper.params; | |
| 7906 | + var thumbs = ref.thumbs; | |
| 7907 | + if (!thumbs || !thumbs.swiper) { return; } | |
| 7908 | + swiper.thumbs.init(); | |
| 7909 | + swiper.thumbs.update(true); | |
| 7910 | + }, | |
| 7911 | + slideChange: function slideChange() { | |
| 7912 | + var swiper = this; | |
| 7913 | + if (!swiper.thumbs.swiper) { return; } | |
| 7914 | + swiper.thumbs.update(); | |
| 7915 | + }, | |
| 7916 | + update: function update() { | |
| 7917 | + var swiper = this; | |
| 7918 | + if (!swiper.thumbs.swiper) { return; } | |
| 7919 | + swiper.thumbs.update(); | |
| 7920 | + }, | |
| 7921 | + resize: function resize() { | |
| 7922 | + var swiper = this; | |
| 7923 | + if (!swiper.thumbs.swiper) { return; } | |
| 7924 | + swiper.thumbs.update(); | |
| 7925 | + }, | |
| 7926 | + observerUpdate: function observerUpdate() { | |
| 7927 | + var swiper = this; | |
| 7928 | + if (!swiper.thumbs.swiper) { return; } | |
| 7929 | + swiper.thumbs.update(); | |
| 7930 | + }, | |
| 7931 | + setTransition: function setTransition(duration) { | |
| 7932 | + var swiper = this; | |
| 7933 | + var thumbsSwiper = swiper.thumbs.swiper; | |
| 7934 | + if (!thumbsSwiper) { return; } | |
| 7935 | + thumbsSwiper.setTransition(duration); | |
| 7936 | + }, | |
| 7937 | + beforeDestroy: function beforeDestroy() { | |
| 7938 | + var swiper = this; | |
| 7939 | + var thumbsSwiper = swiper.thumbs.swiper; | |
| 7940 | + if (!thumbsSwiper) { return; } | |
| 7941 | + if (swiper.thumbs.swiperCreated && thumbsSwiper) { | |
| 7942 | + thumbsSwiper.destroy(); | |
| 7943 | + } | |
| 7944 | + }, | |
| 7945 | + }, | |
| 7946 | + }; | |
| 7947 | + | |
| 7948 | + // Swiper Class | |
| 7949 | + | |
| 7950 | + var components = [ | |
| 7951 | + Device$1, | |
| 7952 | + Support$1, | |
| 7953 | + Browser$1, | |
| 7954 | + Resize, | |
| 7955 | + Observer$1, | |
| 7956 | + Virtual$1, | |
| 7957 | + Keyboard$1, | |
| 7958 | + Mousewheel$1, | |
| 7959 | + Navigation$1, | |
| 7960 | + Pagination$1, | |
| 7961 | + Scrollbar$1, | |
| 7962 | + Parallax$1, | |
| 7963 | + Zoom$1, | |
| 7964 | + Lazy$1, | |
| 7965 | + Controller$1, | |
| 7966 | + A11y, | |
| 7967 | + History$1, | |
| 7968 | + HashNavigation$1, | |
| 7969 | + Autoplay$1, | |
| 7970 | + EffectFade, | |
| 7971 | + EffectCube, | |
| 7972 | + EffectFlip, | |
| 7973 | + EffectCoverflow, | |
| 7974 | + Thumbs$1 | |
| 7975 | + ]; | |
| 7976 | + | |
| 7977 | + if (typeof Swiper.use === 'undefined') { | |
| 7978 | + Swiper.use = Swiper.Class.use; | |
| 7979 | + Swiper.installModule = Swiper.Class.installModule; | |
| 7980 | + } | |
| 7981 | + | |
| 7982 | + Swiper.use(components); | |
| 7983 | + | |
| 7984 | + return Swiper; | |
| 7985 | + | |
| 7986 | +}))); | ... | ... |