1"use strict"; 2var _ie, _firefox, _opera, _webkit, _chrome, _ie_real_version, _osx, _windows, _linux, _android, _win64, _iphone, _ipad, _native, _mobile, _populated = !1; 3 4function _populate() { 5 if (!_populated) { 6 _populated = !0; 7 var t = navigator.userAgent, 8 e = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(t), 9 i = /(Mac OS X)|(Windows)|(Linux)/.exec(t); 10 if (_iphone = /\b(iPhone|iP[ao]d)/.exec(t), _ipad = /\b(iP[ao]d)/.exec(t), _android = /Android/i.exec(t), _native = /FBAN\/\w+;/i.exec(t), _mobile = /Mobile/i.exec(t), _win64 = !!/Win64/.exec(t), e) { 11 (_ie = e[1] ? parseFloat(e[1]) : e[5] ? parseFloat(e[5]) : NaN) && document && document.documentMode && (_ie = document.documentMode); 12 var s = /(?:Trident\/(\d+.\d+))/.exec(t); 13 _ie_real_version = s ? parseFloat(s[1]) + 4 : _ie, _firefox = e[2] ? parseFloat(e[2]) : NaN, _opera = e[3] ? parseFloat(e[3]) : NaN, (_webkit = e[4] ? parseFloat(e[4]) : NaN) ? (e = /(?:Chrome\/(\d+\.\d+))/.exec(t), _chrome = e && e[1] ? parseFloat(e[1]) : NaN) : _chrome = NaN 14 } else _ie = _firefox = _opera = _chrome = _webkit = NaN; 15 if (i) { 16 if (i[1]) { 17 var n = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(t); 18 _osx = !n || parseFloat(n[1].replace("_", ".")) 19 } else _osx = !1; 20 _windows = !!i[2], _linux = !!i[3] 21 } else _osx = _windows = _linux = !1 22 } 23} 24var useHasFeature, UserAgent_DEPRECATED = { 25 ie: function() { 26 return _populate() || _ie 27 }, 28 ieCompatibilityMode: function() { 29 return _populate() || _ie_real_version > _ie 30 }, 31 ie64: function() { 32 return UserAgent_DEPRECATED.ie() && _win64 33 }, 34 firefox: function() { 35 return _populate() || _firefox 36 }, 37 opera: function() { 38 return _populate() || _opera 39 }, 40 webkit: function() { 41 return _populate() || _webkit 42 }, 43 safari: function() { 44 return UserAgent_DEPRECATED.webkit() 45 }, 46 chrome: function() { 47 return _populate() || _chrome 48 }, 49 windows: function() { 50 return _populate() || _windows 51 }, 52 osx: function() { 53 return _populate() || _osx 54 }, 55 linux: function() { 56 return _populate() || _linux 57 }, 58 iphone: function() { 59 return _populate() || _iphone 60 }, 61 mobile: function() { 62 return _populate() || _iphone || _ipad || _android || _mobile 63 }, 64 nativeApp: function() { 65 return _populate() || _native 66 }, 67 android: function() { 68 return _populate() || _android 69 }, 70 ipad: function() { 71 return _populate() || _ipad 72 } 73 }, 74 canUseDOM = !("undefined" == typeof window || !window.document || !window.document.createElement), 75 ExecutionEnvironment = { 76 canUseDOM: canUseDOM, 77 canUseWorkers: "undefined" != typeof Worker, 78 canUseEventListeners: canUseDOM && !(!window.addEventListener && !window.attachEvent), 79 canUseViewport: canUseDOM && !!window.screen, 80 isInWorker: !canUseDOM 81 }; 82 83function isEventSupported(t, e) { 84 if (!ExecutionEnvironment.canUseDOM || e && !("addEventListener" in document)) return !1; 85 var i = "on" + t, 86 s = i in document; 87 if (!s) { 88 var n = document.createElement("div"); 89 n.setAttribute(i, "return;"), s = "function" == typeof n[i] 90 } 91 return !s && useHasFeature && "wheel" === t && (s = document.implementation.hasFeature("Events.wheel", "3.0")), s 92} 93ExecutionEnvironment.canUseDOM && (useHasFeature = document.implementation && document.implementation.hasFeature && !0 !== document.implementation.hasFeature("", "")); 94var PIXEL_STEP = 10, 95 LINE_HEIGHT = 40, 96 PAGE_HEIGHT = 800; 97 98function normalizeWheel(t) { 99 var e = 0, 100 i = 0, 101 s = 0, 102 n = 0; 103 return "detail" in t && (i = t.detail), "wheelDelta" in t && (i = -t.wheelDelta / 120), "wheelDeltaY" in t && (i = -t.wheelDeltaY / 120), "wheelDeltaX" in t && (e = -t.wheelDeltaX / 120), "axis" in t && t.axis === t.HORIZONTAL_AXIS && (e = i, i = 0), s = e * PIXEL_STEP, n = i * PIXEL_STEP, "deltaY" in t && (n = t.deltaY), "deltaX" in t && (s = t.deltaX), (s || n) && t.deltaMode && (1 == t.deltaMode ? (s *= LINE_HEIGHT, n *= LINE_HEIGHT) : (s *= PAGE_HEIGHT, n *= PAGE_HEIGHT)), s && !e && (e = s < 1 ? -1 : 1), n && !i && (i = n < 1 ? -1 : 1), { 104 spinX: e, 105 spinY: i, 106 pixelX: s, 107 pixelY: n 108 } 109} 110normalizeWheel.getEventType = function() { 111 return UserAgent_DEPRECATED.firefox() ? "DOMMouseScroll" : isEventSupported("wheel") ? "wheel" : "mousewheel" 112}; 113const store = { 114 ww: window.innerWidth, 115 wh: window.innerHeight, 116 isDevice: navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) 117}; 118class ClapatSlider { 119 constructor(t, e = {}) {
120 if (this.bindAll(), this.isElement(t)) this.el = t, this.el.clapat_slider = this; 121 else { 122 const i = document.querySelectorAll(t); 123 for (let t = 0; t < i.length; t++) { 124 let s = i[t]; 125 if (0 == t) this.el = s, this.el.clapat_slider = this; 126 else { 127 new ClapatSlider(s, e) 128 } 129 } 130 } 131 this.opts = Object.assign({ 132 debug: !1, 133 direction: "horizontal", 134 eventTarget: ".clapat-slider", 135 inner: ".clapat-slider-viewport", 136 slides: ".clapat-slide", 137 clones: "clapat-slide-clone", 138 snap: !1, 139 snapwait: { 140 before: 10, 141 after: 80 142 }, 143 speed: 2, 144 threshold: 50, 145 ease: .075, 146 click: !1, 147 mousewheel: !0, 148 navigation: !0, 149 pagination: !0, 150 renderBullet: null, 151 parallax: null, 152 on: { 153 init: null, 154 activeSlideChange: null, 155 slideEnterViewport: null, 156 slideLeaveViewport: null 157 } 158 }, e), this.elEventTarget = this.el.querySelector(this.opts.eventTarget), this.elInner = this.el.querySelector(this.opts.inner), this.btnNext = this.btnPrev = null, this.isObject(this.opts.navigation) || 1 == this.opts.navigation && (this.btnNext = this.el.querySelector(".clapat-button-next"), this.btnPrev = this.el.querySelector(".clapat-button-prev")), this.isObject(this.opts.navigation) && (this.btnNext = document.querySelector(this.opts.navigation.nextEl), this.btnPrev = document.querySelector(this.opts.navigation.prevEl)), null != this.btnNext && this.btnNext.addEventListener("click", this.debounce(this.onNext, 50)), null != this.btnPrev && this.btnPrev.addEventListener("click", this.debounce(this.onPrev, 50)), this.elPagination = null, this.isObject(this.opts.pagination) || 1 == this.opts.pagination && (this.elPagination = this.el.querySelector(".clapat-pagination")), this.isObject(this.opts.pagination) && (this.elPagination = this.el.querySelector(this.opts.navigation.el)), this.vh = store.wh, this.vw = store.ww, this.vshifth = 0, this.vshiftw = 0, this.state = { 159 target: 0, 160 current: 0, 161 currentRounded: 0, 162 currentScrollDirection: 0, 163 currentSlideItem: null, 164 moveOffset: 0, 165 y: 0, 166 on: { 167 x: 0, 168 y: 0 169 }, 170 off: 0, 171 progress: 0, 172 diff: 0, 173 flags: { 174 mousedown: !1, 175 dragging: !1, 176 click: !0, 177 resizing: !1 178 } 179 }, this.items = [], this.itemsInitial = [], this.itemsCloned = [], this.itemsPagination = [], this.tl = null, this.events = { 180 move: store.isDevice ? "touchmove" : "mousemove", 181 up: store.isDevice ? "touchend" : "mouseup", 182 down: store.isDevice ? "touchstart" : "mousedown", 183 click: "click", 184 wheel: "wheel", 185 mousewheel: "mousewheel", 186 resize: "resize" 187 }, this.enabled = !0, this.length = 0, this.updater = gsap.set(this.updateUI, { 188 delay: .2, 189 onRepeat: this.updateUI, 190 repeat: -1, 191 repeatDelay: .2 192 }), this.snapWheelEvents = { 193 tsSnap: null, 194 events: [] 195 }, this.init(), ClapatSlider.instances.push(this) 196 } 197 bindAll() { 198 ["onDown", "onMove", "onUp", "onClick", "onWheel", "onResize", "onPagination", "onPrev", "onNext", "updateUI", "updateWheelSnap", "tick"].forEach((t => this[t] = this[t].bind(this))) 199 } 200 init() { 201 return gsap.utils.pipe(this.setup(), this.setupEvents()) 202 } 203 on(t, e) { 204 this.opts.on[t] = e 205 } 206 destroy() { 207 this.off(), this.state = null, this.items = null, this.opts = null, this.ui = null 208 } 209 setupEvents() { 210 const { 211 move: t, 212 up: e, 213 down: i, 214 resize: s, 215 wheel: n, 216 mousewheel: l 217 } = this.events; 218 let a = this.elEventTarget; 219 null != a && (a.addEventListener(i, this.onDown), a.addEventListener(t, this.onMove), this.opts.mousewheel && (a.addEventListener(n, this.onWheel), a.addEventListener(l, this.onWheel)), window.addEventListener(e, this.onUp)), window.addEventListener(s, this.debounce(this.onResize, 250)) 220 } 221 off() { 222 const { 223 move: t, 224 up: e, 225 down: i, 226 resize: s, 227 wheel: n, 228 mousewheel: l 229 } = this.events; 230 let a = this.elEventTarget; 231 null != a && (a.removeEventListener(i, this.onDown), a.removeEventListener(t, this.onMove), this.opts.mousewheel && (a.removeEventListener(n, this.onWheel), a.removeEventListener(l, this.onWheel)), window.removeEventListener(e, this.onUp)), null != this.btnNext && this.btnNext.removeEventListener("click", this.debounce(this.onNext, 50)), null != this.btnPrev && this.btnPrev.removeEventListener("click", this.debounce(this.onPrev, 50)), null != this.el && 0 != this.opts.click && this.el.removeEventListener("click", this.onClick), window.removeEventListener(s, this.debounce(this.onResize, 250)), this.updater.kill(), this.updater = null, gsap.ticker.remove(this.tick) 232 } 233 viewportSize() { 234 return "vertical" == this.opts.direction ? this.vh : this.vw 235 } 236 viewportShift() { 237 return "vertical" == this.opts.direction ? this.vshifth : this.vshiftw 238 } 239 setup() { 240 if (null != this.el) { 241 const { 242 top: t, 243 left: e, 244 width: i, 245 height: s 246 } = this.el.getBoundingClientRect(); 247 this.vh = s, this.vw = i, this.vshifth = t, this.vshiftw = e 248 } 249 const t = this.elInner.querySelectorAll(this.opts.slides); 250 let e = 1; 251 for (let i = t.length - 1; i >= 0; i--) { 252 const s = t[i], 253 n = s.cloneNode(!0); 254 "vertical" == this.opts.direction ? (s.style.top = 100 * i + "%", n.style.top = 100 * -e + "%", n.classList.add(this.opts.clones), this.elInner.append(n)) : (s.style.left = 100 * i + "%", n.style.left = 100 * -e + "%", n.classList.add(this.opts.clones), this.elInner.prepend(n)), e++ 255 } 256 if (null != this.elPagination) 257 for (let e = 0; e < t.length; e++) { 258 t[e]; 259 let i = document.createElement("div"); 260 i.classList.add("clapat-pagination-bullet"), "function" == typeof this.opts.renderBullet && (i.innerHTML = this.opts.renderBullet()), this.elPagination.appendChild(i), i.addEventListener("click", this.onPagination), this.itemsPagination.push({ 261 el: i 262 }) 263 } 264 this.tl = gsap.timeline({ 265 paused: !0, 266 defaults: { 267 duration: 1, 268 ease: "linear" 269 } 270 }); 271 const i = this.elInner.querySelectorAll(this.opts.slides); 272 for (let t = 0; t < i.length; t++) { 273 const e = i[t], 274 { 275 left: s, 276 right: n, 277 top: l, 278 bottom: a, 279 width: h, 280 height: r 281 } = e.getBoundingClientRect(); 282 let o = null; 283 "vertical" == this.opts.direction ? (o = { 284 el: e, 285 start: l, 286 end: a, 287 length: r, 288 translate: 0 289 }, this.length += r) : (o = { 290 el: e, 291 start: s, 292 end: n, 293 length: h, 294 translate: 0 295 }, this.length += h), e.classList.contains(this.opts.clones) ? (this.itemsCloned.push(o), o.clone = !0) : (this.itemsInitial.push(o), o.clone = !1), this.items.push(o) 296 } 297 "vertical" == this.opts.direction && this.itemsCloned.reverse(); 298 const s = t.length; 299 if ("vertical" == this.opts.direction) { 300 for (let t = 0; t < s; t++) { 301 const e = this.items[t]; 302 e.prevElement = 0 == t ? this.items[s] : this.items[t - 1], e.nextElement = t == s - 1 ? this.items[this.items.length - 1] : this.items[t + 1] 303 } 304 for (let t = this.items.length - 1; t >= s; t--) { 305 const e = this.items[t]; 306 t == this.items.length - 1 ? e.prevElement = this.items[s - 1] : e.prevElement = this.items[t + 1], e.nextElement = t == s ? this.items[0] : this.items[t - 1] 307 } 308 } else 309 for (let t = 0; t < this.items.length; t++) { 310 const e = this.items[t]; 311 e.prevElement = 0 == t ? this.items[this.items.length - 1] : this.items[t - 1], t == this.items.length - 1 ? e.nextElement = this.items[0] : e.nextElement = this.items[t + 1] 312 } 313 null != this.el && 0 != this.opts.click && this.el.addEventListener("click", this.onClick), gsap.ticker.add(this.tick) 314 } 315 tick() { 316 this.render() 317 } 318 calc() { 319 const t = this.state; 320 t.current += (t.target - t.current) * this.opts.ease, t.currentRounded = Math.round(100 * t.current) / 100, t.diff = t.target - t.currentRounded;
321 const e = Math.round(-this.length / 2 * 100) / 100; 322 t.progress = gsap.utils.wrap(0, 1, t.currentRounded / e), t.moveOffset = gsap.utils.wrap(0, this.length, Math.abs(t.currentRounded)), this.tl && this.tl.progress(t.progress) 323 } 324 render() { 325 this.state.flags.resizing || (this.opts.snap && this.updateWheelSnap(), this.calc(), this.transformItems(), this.parallax()) 326 } 327 transformItems() { 328 const t = this.viewportSize(), 329 e = this.viewportShift(); 330 for (let i = 0; i < this.items.length; i++) { 331 const s = this.items[i]; 332 let n = this.state.moveOffset * Math.sign(this.state.currentRounded); 333 n < 0 && s.end + n < t + e + s.length - this.length && (n += this.length), n > 0 && s.end + n > this.length && (n -= this.length), "vertical" == this.opts.direction ? s.el.style.transform = "translate(0, " + n + "px)" : s.el.style.transform = "translate(" + n + "px, 0)" 334 } 335 } 336 updateUI() { 337 const t = this.viewportSize(), 338 e = this.viewportShift(), 339 i = this.elInner.getBoundingClientRect(), 340 s = gsap.utils.wrap(0, this.length, Math.abs(this.state.target)), 341 n = Math.sign(this.state.target); 342 null != this.el && (this.state.currentScrollDirection >= 0 ? (this.el.classList.contains("bw") && this.el.classList.remove("bw"), this.el.classList.add("fw")) : (this.el.classList.contains("fw") && this.el.classList.remove("fw"), this.el.classList.add("bw"))); 343 let l = this.state.currentSlideItem; 344 this.state.currentSlideItem = null; 345 for (let a = 0; a < this.items.length; a++) { 346 const h = this.items[a]; 347 let r = s * n; 348 r < 0 && h.end + r < t + e + h.length - this.length && (r += this.length), r > 0 && h.end + r > this.length && (r -= this.length); 349 const o = h.start + r - (e + (t - h.length) / 2); 350 if (Math.abs(o) < h.length / 2 ? (h.el.classList.add("clapat-slide-active"), h.nextElement.el.classList.add("clapat-slide-next"), h.nextElement.nextElement.el.classList.add("clapat-slide-next-two"), h.nextElement.nextElement.nextElement.el.classList.add("clapat-slide-next-three"), h.prevElement.el.classList.add("clapat-slide-prev"), h.prevElement.prevElement.el.classList.add("clapat-slide-prev-two"), h.prevElement.prevElement.prevElement.el.classList.add("clapat-slide-prev-three"), this.state.currentSlideItem = h, null != l && l !== this.state.currentSlideItem && "function" == typeof this.opts.on.activeSlideChanged && this.opts.on.activeSlideChanged(this.state.currentSlideItem.el, this.state.currentSlideItem.prevElement.el, this.state.currentSlideItem.nextElement.el)) : (h.el.classList.remove("clapat-slide-active"), h.nextElement.el.classList.remove("clapat-slide-next"), h.nextElement.nextElement.el.classList.remove("clapat-slide-next-two"), h.nextElement.nextElement.nextElement.el.classList.remove("clapat-slide-next-three"), h.prevElement.el.classList.remove("clapat-slide-prev"), h.prevElement.prevElement.el.classList.remove("clapat-slide-prev-two"), h.prevElement.prevElement.prevElement.el.classList.remove("clapat-slide-prev-three")), h.end + r > e && h.start + r < t + e ? h.el.classList.add("clapat-slide-visible") : h.el.classList.remove("clapat-slide-visible"), h.translate != r) { 351 let t = this.isItemInsideView(i, h); 352 h.translate = r; 353 let e = this.isItemInsideView(i, h); 354 t && !e && "function" == typeof this.opts.on.slideLeaveViewport && this.opts.on.slideLeaveViewport(h.el), !t && e && "function" == typeof this.opts.on.slideEnterViewport && this.opts.on.slideEnterViewport(h.el) 355 } 356 } 357 this.state.flags.dragging ? this.el.classList.add("clapat-state-dragging") : this.el.classList.remove("clapat-state-dragging"), this.updatePaginationUI(), null == l && "function" == typeof this.opts.on.init && this.opts.on.init() 358 } 359 updatePaginationUI() { 360 if (this.opts.pagination && !(this.itemsPagination.length <= 0) && null != this.state.currentSlideItem) { 361 let t = null; 362 t = this.state.currentSlideItem.clone ? this.itemsCloned : this.itemsInitial; 363 let e = -1; 364 for (let i = 0; i < t.length; i++) { 365 const s = t[i]; 366 if (this.state.currentSlideItem.el === s.el) { 367 e = i; 368 break 369 } 370 } 371 let i = this.itemsPagination[e]; 372 null != i && i.el.classList.add("clapat-pagination-bullet-active"); 373 let s = e - 1; 374 s < 0 && (s = this.itemsPagination.length - 1); 375 let n = this.itemsPagination[s]; 376 null != n && n.el.classList.add("clapat-pagination-bullet-prev"); 377 let l = e + 1; 378 l >= this.itemsPagination.length && (l = 0); 379 let a = this.itemsPagination[l]; 380 null != a && a.el.classList.add("clapat-pagination-bullet-next"); 381 for (let t = 0; t < this.itemsPagination.length; t++) { 382 let i = this.itemsPagination[t]; 383 t != e && i.el.classList.remove("clapat-pagination-bullet-active"), t != l && i.el.classList.remove("clapat-pagination-bullet-next"), t != s && i.el.classList.remove("clapat-pagination-bullet-prev") 384 } 385 } 386 } 387 parallax() { 388 if (null == this.opts.parallax || 0 == this.opts.parallax) return; 389 const t = this.viewportSize(), 390 e = this.viewportShift(), 391 i = (this.elInner.getBoundingClientRect(), this.state.moveOffset * Math.sign(this.state.currentRounded)); 392 for (let s = 0; s < this.items.length; s++) { 393 const n = this.items[s]; 394 let l = i; 395 if (l < 0 && n.end + l < t + e + n.length - this.length && (l += this.length), l > 0 && n.end + l > this.length && (l -= this.length), n.end + l > e && n.start + l < t + e) { 396 let i = n.start + l - (e + (t - n.length) / 2); 397 if (Array.isArray(this.opts.parallax)) 398 for (let e = 0; e < this.opts.parallax.length; e++) { 399 let s = this.opts.parallax[e]; 400 if (void 0 !== s.element && void 0 !== s.margin) { 401 let e = n.el.querySelectorAll(s.element), 402 l = -s.margin * i * 2 / (n.length + t); 403 for (let t = 0; t < e.length; t++) { 404 let i = e[t]; 405 "vertical" == this.opts.direction ? i.style.transform = "translateY(" + l + "%)" : i.style.transform = "translateX("
405+ l + "%)" 406 } 407 } 408 } 409 } 410 } 411 } 412 snapTargetOnDrag(t) { 413 const e = this.viewportSize(), 414 i = this.viewportShift(), 415 s = gsap.utils.wrap(0, this.length, Math.abs(t)), 416 n = Math.sign(t); 417 for (let l = 0; l < this.items.length; l++) { 418 const a = this.items[l]; 419 let h = s * n; 420 h < 0 && a.end + h < e + i + a.length - this.length && (h += this.length), h > 0 && a.end + h > this.length && (h -= this.length); 421 const r = a.start + h - (i + (e - a.length) / 2); 422 if (Math.abs(r) < a.length / 2) return t - r 423 } 424 return t 425 } 426 snapTargetOnWheel(t, e) { 427 const i = this.viewportSize(), 428 s = this.viewportShift(), 429 n = gsap.utils.wrap(0, this.length, Math.abs(t)), 430 l = Math.sign(t); 431 let a = -1; 432 for (let t = 0; t < this.items.length; t++) { 433 let e = this.items[t], 434 h = n * l; 435 h < 0 && e.end + h < i + s + e.length - this.length && (h += this.length), h > 0 && e.end + h > this.length && (h -= this.length); 436 const r = e.start + h - (s + (i - e.length) / 2); 437 if (Math.abs(r) < e.length / 2) { 438 a = t; 439 break 440 } 441 } 442 const h = gsap.utils.wrap(0, this.length, Math.abs(e)), 443 r = Math.sign(e); 444 for (let n = 0; n < this.items.length; n++) { 445 let l = this.items[n], 446 o = h * r; 447 o < 0 && l.end + o < i + s + l.length - this.length && (o += this.length), o > 0 && l.end + o > this.length && (o -= this.length); 448 const c = l.start + o - (s + (i - l.length) / 2); 449 if (Math.abs(c) < l.length / 2) { 450 return a == n && Math.abs(e - t) < this.length ? (this.log("Snapping - start and end items are the same, the scroll did not go over a full item"), this.state.currentScrollDirection > 0 ? c < 0 ? e - (l.length / 2 + c + l.nextElement.length / 2) : e - c : c < 0 ? e - c : e - c + l.prevElement.length) : (this.log("Snapping - start and end items are different"), e - c) 451 } 452 } 453 return e 454 } 455 getPos({ 456 changedTouches: t, 457 clientX: e, 458 clientY: i, 459 target: s 460 }) { 461 return { 462 x: t ? t[0].clientX : e, 463 y: t ? t[0].clientY : i, 464 target: s 465 } 466 } 467 onDown(t) { 468 if (!this.enabled) return; 469 const { 470 x: e, 471 y: i 472 } = this.getPos(t), { 473 flags: s, 474 on: n 475 } = this.state; 476 s.mousedown = !0, n.x = e, n.y = i 477 } 478 onMove(t) { 479 if (!this.enabled) return; 480 const e = this.state; 481 if (!e.flags.mousedown) return; 482 const { 483 x: i, 484 y: s 485 } = this.getPos(t); 486 e.flags.dragging = !0; 487 const { 488 off: n, 489 on: l 490 } = e, a = i - l.x, h = s - l.y; 491 Math.abs(a) > Math.abs(h) && t.cancelable && t.preventDefault(), "vertical" == this.opts.direction ? (e.target = n + h * this.opts.speed, e.currentScrollDirection = -Math.sign(h)) : (e.target = n + a * this.opts.speed, e.currentScrollDirection = -Math.sign(a)) 492 } 493 onUp(t) { 494 if (!this.enabled) return; 495 this.log("on up"); 496 const e = this.state; 497 this.opts.snap && (e.target = this.snapTargetOnDrag(e.target)); 498 let i = e.flags.dragging; 499 if (e.flags.mousedown = !1, e.flags.dragging = !1, e.off = e.target, i) { 500 if (e.flags.click = !1, t.cancelable) return t.preventDefault(), t.stopPropagation(), this.log("ending dragging"), !1 501 } else e.flags.click = !0, this.log("simple click") 502 } 503 onClick(t) { 504 if (this.enabled) { 505 if (this.log("on click. Drag? " + !this.state.flags.click), this.state.flags.click) { 506 let e = null; 507 null != t.target && (e = t.target.querySelector("a"), null != e && e.click()) 508 } 509 this.state.flags.click = !1 510 } 511 } 512 isItemInsideView(t, e) { 513 let i = 0, 514 s = 0, 515 n = e.start + e.translate, 516 l = e.end + e.translate; 517 return "vertical" == this.opts.direction ? (i = t.top + 5, s = t.bottom - 5) : (i = t.left + 5, s = t.right - 5), l > i && n < s 518 } 519 distanceToCenter(t) { 520 if (null == t) return null; 521 const e = this.viewportSize(), 522 i = this.viewportShift(); 523 let s = gsap.utils.wrap(0, this.length, Math.abs(this.state.target)) * Math.sign(this.state.target); 524 return t.start + s - (i + (e - t.length) / 2) 525 } 526 goTo(t) { 527 if (t < 0 || t >= this.items.length) return; 528 let e = this.items[t]; 529 this.state.target -= this.distanceToCenter(e), this.state.off = this.state.target 530 } 531 update() { 532 const t = this.viewportSize(), 533 e = this.viewportShift(), 534 i = gsap.utils.wrap(0, this.length, Math.abs(this.state.target)), 535 s = Math.sign(this.state.target); 536 let n = 0; 537 for (let l = 0; l < this.items.length; l++) { 538 const a = this.items[l]; 539 let h = i * s; 540 h < 0 && a.end + h < t + e + a.length - this.length && (h += this.length), h > 0 && a.end + h > this.length && (h -= this.length); 541 const r = a.start + h - (e + (t - a.length) / 2); 542 if (Math.abs(r) < a.length / 2) { 543 n = l; 544 break 545 } 546 } 547 if (null != this.el) { 548 const { 549 top: t, 550 left: e, 551 width: i, 552 height: s 553 } = this.el.getBoundingClientRect(); 554 this.vh = s, this.vw = i, this.vshifth = t, this.vshiftw = e 555 } else this.vh = store.wh, this.vw = store.ww, this.vshifth = 0, this.vshiftw = 0; 556 this.length = 0; 557 for (let t = 0; t < this.items.length; t++) { 558 const e = this.items[t]; 559 if ("vertical" == this.opts.direction) { 560 e.el.style.transform = "translate(0, 0px)"; 561 const { 562 left: t, 563 right: i, 564 top: s, 565 bottom: n, 566 width: l, 567 height: a 568 } = e.el.getBoundingClientRect(); 569 this.length += a, e.start = s, e.end = n, e.length = a 570 } else { 571 e.el.style.transform = "translate(0px, 0)"; 572 const { 573 left: t, 574 right: i, 575 top: s, 576 bottom: n, 577 width: l, 578 height: a 579 } = e.el.getBoundingClientRect(); 580 this.length += l, e.start = t, e.end = i, e.length = l 581 } 582 } 583 let l = 0; 584 if (n < this.items.length / 2) 585 if ("vertical" == this.opts.direction) 586 for (let t = 0; t < n; t++) { 587 l -= this.items[t].length 588 } else 589 for (let t = n; t < this.items.length / 2; t++) { 590 l += this.items[t].length 591 } else if ("vertical" == this.opts.direction) 592 for (let t = this.items.length / 2; t <= n; t++) { 593 l += this.items[t].length 594 } else 595 for (let t = this.items.length / 2; t < n; t++) { 596 l -= this.items[t].length 597 } 598 this.state.currentRounded = this.state.current = this.state.target = l, this.state.off = this.state.target 599 } 600 onResize(t) { 601 this.state.flags.resizing = !0, this.update(), this.state.flags.resizing = !1, this.log("on resize") 602 } 603 onPagination(t) { 604 if (!this.enabled) return; 605 let e = -1; 606 for (let i = 0; i < this.itemsPagination.length; i++) { 607 if (this.itemsPagination[i].el === t.currentTarget) { 608 e = i; 609 break 610 } 611 } 612 if (e >= 0 && null != this.state.currentSlideItem) { 613 let t = this.itemsInitial; 614 this.state.currentSlideItem.clone && (t = this.itemsCloned); 615 const i = t[e]; 616 this.state.target -= this.distanceToCenter(i), this.state.off = this.state.target 617 } 618 } 619 onPrev(t) { 620 if (!this.enabled) return; 621 const e = this.viewportSize(), 622 i = this.viewportShift(), 623 s = gsap.utils.wrap(0, this.length, Math.abs(this.state.target)), 624 n = Math.sign(this.state.target); 625 for (let t = 0; t < this.items.length; t++) { 626 const l = this.items[t]; 627 let a = s * n; 628 a < 0 && l.end + a < e + i + l.length - this.length && (a += this.length), a > 0 && l.end + a > this.length && (a -= this.length); 629 const h = l.start + a - (i + (e - l.length) / 2); 630 Math.abs(h) < l.length / 2 && (this.state.target = this.state.target - h + l.prevElement.length, this.state.off = this.state.target) 631 } 632 } 633 onNext(t) { 634 if (!this.enabled) return; 635 const e = this.viewportSize(), 636 i = this.viewportShift(), 637 s = gsap.utils.wrap(0, this.length, Math.abs(this.state.target)), 638 n = Math.sign(this.state.target); 639 for (let t = 0; t < this.items.length; t++) { 640 const l = this.items[t]; 641 let a = s * n; 642 a < 0 && l.end + a < e + i + l.length - this.length && (a += this.length), a > 0 && l.end + a > this.length && (a -= this.length); 643 const h = l.start + a - (i + (e - l.length) / 2); 644 Math.abs(h) < l.length / 2 && (this.state.target = this.state.target - (l.length / 2 + h + l.nextElement.length / 2), this.state.off = this.state.target) 645 } 646 } 647 onWheel(t) { 648 if (!this.enabled) return; 649 let e = performance.now(); 650 const i = this.state, 651 s = .2 * normalizeWheel(t).pixelY, 652 { 653 x: n, 654 y: l 655 } = this.getPos(t); 656 i.flags.dragging = !1; 657 const { 658 off: a, 659 on: h 660 } = i; 661 if (this.log("Event timestamp: " + e + " Scroll delta " + s), this.opts.snap && null != this.snapWheelEvents.tsSnap) { 662 if (e - this.snapWheelEvents.tsSnap <= this.opts.snapwait.after) return void this.log("Ignoring wheel event as there is a snapping going on"); 663 this.log("Resetting the snapping events buffer"), this.snapWheelEvents.tsSnap = null, this.snapWheelEvents.events = [] 664 } 665 i.target -= s * this.opts.speed, i.currentScrollDirection = Math.sign(s), this.opts.snap && this.snapWheelEvents.events.push({ 666 ts: e, 667 delta: s, 668 currentTarget: i.target 669 }), "vertical" == this.opts.direction ? h.y = i.target : h.x = i.target, i.off = i.target 670 } 671 updateWheelSnap() { 672 if (this.opts.snap && this.snapWheelEvents.events.length > 0) { 673 let t = performance.now(); 674 if (t - this.snapWheelEvents.events[this.snapWheelEvents.events.length - 1].ts > this.opts.snapwait.before) { 675 let e = 0, 676 i = 0, 677 s = 1e4, 678 n = 0, 679 l = 0, 680 a = 1e4, 681 h = 0; 682 for (let t = 0; t < this.snapWheelEvents.events.length; t++) { 683 let r = this.snapWheelEvents.events[t]; 684 if (0 == t && (h = r.currentTarget), t > 0) { 685 let n = this.snapWheelEvents.events[t - 1], 686 l = r.ts - n.ts; 687 e += l, i < l && (i = l), s > l && (s = l) 688 } 689 let o = r.delta; 690 n += o, l < o && (l = o), a > o && (a = o) 691 } 692 this.log("--\x3e Event timestamp: " + t + ". Snapping.\nAvg time interval between scroll events: " + e / this.snapWheelEvents.events.length + ".\nMin time interval between scroll events: " + s + ".\nMax time interval between scroll events: " + i + ".\nWheel events count: " + this.snapWheelEvents.events.length), this.log("Total delta interval: " + n + ".\nAvg delta interval between scroll events: " + n / this.snapWheelEvents.events.length + ".\nMin delta interval between scroll events: " + a + ".\nMax delta interval between scroll events: " + l + "."); 693 const r = this.state, 694 { 695 off: o, 696 on: c 697 } = r; 698 r.target = this.snapTargetOnWheel(h, r.target), "vertical" == this.opts.direction ? c.y = r.target : c.x = r.target, r.off = r.target, this.snapWheelEvents.tsSnap = t, this.snapWheelEvents.events = [] 699 } 700 } 701 } 702 debounce(t, e) { 703 let i; 704 return function(...s) { 705 i && clearTimeout(i), i = setTimeout((() => t(...s)), e) 706 } 707 } 708 isObject(t) { 709 return t instanceof Object && !Array.isArray(t) && null !== t 710 } 711 isElement(t) { 712 return "object" == typeof HTMLElement ? t instanceof HTMLElement : t && "object" == typeof t && null !== t && 1 === t.nodeType && "string" == typeof t.nodeName 713 } 714 log(t) { 715 1 == this.opts.debug && console.log(t) 716 } 717}
718ClapatSlider.instances = [];
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.