-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
snap-slider.min.js
2 lines (2 loc) · 31.7 KB
/
snap-slider.min.js
1
2
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.SnapSlider=e():t.SnapSlider=e()}(window,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(o,i,function(e){return t[e]}.bind(null,i));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=18)}([function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(t,e,n){var o=n(0),i=n(7),r=n(10),a=Math.max,s=Math.min;t.exports=function(t,e,n){var l,c,u,d,f,p,h=0,v=!1,g=!1,b=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var n=l,o=c;return l=c=void 0,h=e,d=t.apply(o,n)}function m(t){return h=t,f=setTimeout(x,e),v?y(t):d}function S(t){var n=t-p;return void 0===p||n>=e||n<0||g&&t-h>=u}function x(){var t=i();if(S(t))return w(t);f=setTimeout(x,function(t){var n=e-(t-p);return g?s(n,u-(t-h)):n}(t))}function w(t){return f=void 0,b&&l?y(t):(l=c=void 0,d)}function k(){var t=i(),n=S(t);if(l=arguments,c=this,p=t,n){if(void 0===f)return m(p);if(g)return clearTimeout(f),f=setTimeout(x,e),y(p)}return void 0===f&&(f=setTimeout(x,e)),d}return e=r(e)||0,o(n)&&(v=!!n.leading,u=(g="maxWait"in n)?a(r(n.maxWait)||0,e):u,b="trailing"in n?!!n.trailing:b),k.cancel=function(){void 0!==f&&clearTimeout(f),h=0,l=p=c=f=void 0},k.flush=function(){return void 0===f?d:w(i())},k}},function(t,e,n){var o=n(1),i=n(0);t.exports=function(t,e,n){var r=!0,a=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return i(n)&&(r="leading"in n?!!n.leading:r,a="trailing"in n?!!n.trailing:a),o(t,e,{leading:r,maxWait:e,trailing:a})}},function(t,e,n){var o=n(8),i="object"==typeof self&&self&&self.Object===Object&&self,r=o||i||Function("return this")();t.exports=r},function(t,e,n){var o=n(3).Symbol;t.exports=o},function(t,e,n){!function(){"use strict";t.exports={polyfill:function(){var t=window,e=document;if(!("scrollBehavior"in e.documentElement.style)||!0===t.__forceSmoothScrollPolyfill__){var n,o=t.HTMLElement||t.Element,i={scroll:t.scroll||t.scrollTo,scrollBy:t.scrollBy,elementScroll:o.prototype.scroll||s,scrollIntoView:o.prototype.scrollIntoView},r=t.performance&&t.performance.now?t.performance.now.bind(t.performance):Date.now,a=(n=t.navigator.userAgent,new RegExp(["MSIE ","Trident/","Edge/"].join("|")).test(n)?1:0);t.scroll=t.scrollTo=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?h.call(t,e.body,void 0!==arguments[0].left?~~arguments[0].left:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?~~arguments[0].top:t.scrollY||t.pageYOffset):i.scroll.call(t,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:t.scrollX||t.pageXOffset,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:t.scrollY||t.pageYOffset))},t.scrollBy=function(){void 0!==arguments[0]&&(l(arguments[0])?i.scrollBy.call(t,void 0!==arguments[0].left?arguments[0].left:"object"!=typeof arguments[0]?arguments[0]:0,void 0!==arguments[0].top?arguments[0].top:void 0!==arguments[1]?arguments[1]:0):h.call(t,e.body,~~arguments[0].left+(t.scrollX||t.pageXOffset),~~arguments[0].top+(t.scrollY||t.pageYOffset)))},o.prototype.scroll=o.prototype.scrollTo=function(){if(void 0!==arguments[0])if(!0!==l(arguments[0])){var t=arguments[0].left,e=arguments[0].top;h.call(this,this,void 0===t?this.scrollLeft:~~t,void 0===e?this.scrollTop:~~e)}else{if("number"==typeof arguments[0]&&void 0===arguments[1])throw new SyntaxError("Value could not be converted");i.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left:"object"!=typeof arguments[0]?~~arguments[0]:this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top:void 0!==arguments[1]?~~arguments[1]:this.scrollTop)}},o.prototype.scrollBy=function(){void 0!==arguments[0]&&(!0!==l(arguments[0])?this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior}):i.elementScroll.call(this,void 0!==arguments[0].left?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,void 0!==arguments[0].top?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop))},o.prototype.scrollIntoView=function(){if(!0!==l(arguments[0])){var n=f(this),o=n.getBoundingClientRect(),r=this.getBoundingClientRect();n!==e.body?(h.call(this,n,n.scrollLeft+r.left-o.left,n.scrollTop+r.top-o.top),"fixed"!==t.getComputedStyle(n).position&&t.scrollBy({left:o.left,top:o.top,behavior:"smooth"})):t.scrollBy({left:r.left,top:r.top,behavior:"smooth"})}else i.scrollIntoView.call(this,void 0===arguments[0]||arguments[0])}}function s(t,e){this.scrollLeft=t,this.scrollTop=e}function l(t){if(null===t||"object"!=typeof t||void 0===t.behavior||"auto"===t.behavior||"instant"===t.behavior)return!0;if("object"==typeof t&&"smooth"===t.behavior)return!1;throw new TypeError("behavior member of ScrollOptions "+t.behavior+" is not a valid value for enumeration ScrollBehavior.")}function c(t,e){return"Y"===e?t.clientHeight+a<t.scrollHeight:"X"===e?t.clientWidth+a<t.scrollWidth:void 0}function u(e,n){var o=t.getComputedStyle(e,null)["overflow"+n];return"auto"===o||"scroll"===o}function d(t){var e=c(t,"Y")&&u(t,"Y"),n=c(t,"X")&&u(t,"X");return e||n}function f(t){for(;t!==e.body&&!1===d(t);)t=t.parentNode||t.host;return t}function p(e){var n,o,i,a,s=(r()-e.startTime)/468;a=s=s>1?1:s,n=.5*(1-Math.cos(Math.PI*a)),o=e.startX+(e.x-e.startX)*n,i=e.startY+(e.y-e.startY)*n,e.method.call(e.scrollable,o,i),o===e.x&&i===e.y||t.requestAnimationFrame(p.bind(t,e))}function h(n,o,a){var l,c,u,d,f=r();n===e.body?(l=t,c=t.scrollX||t.pageXOffset,u=t.scrollY||t.pageYOffset,d=i.scroll):(l=n,c=n.scrollLeft,u=n.scrollTop,d=s),p({scrollable:l,method:d,startTime:f,startX:c,startY:u,x:o,y:a})}}}}()},function(t,e){var n=["input","select","textarea","a[href]","button","[tabindex]","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])'],o=n.join(","),i="undefined"==typeof Element?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector;function r(t,e){e=e||{};var n,r,s,l=[],d=[],f=t.querySelectorAll(o);for(e.includeContainer&&i.call(t,o)&&(f=Array.prototype.slice.apply(f)).unshift(t),n=0;n<f.length;n++)a(r=f[n])&&(0===(s=c(r))?l.push(r):d.push({documentOrder:n,tabIndex:s,node:r}));return d.sort(u).map((function(t){return t.node})).concat(l)}function a(t){return!(!s(t)||function(t){return function(t){return d(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e=function(t){for(var e=0;e<t.length;e++)if(t[e].checked)return t[e]}(t.ownerDocument.querySelectorAll('input[type="radio"][name="'+t.name+'"]'));return!e||e===t}(t)}(t)||c(t)<0)}function s(t){return!(t.disabled||function(t){return d(t)&&"hidden"===t.type}(t)||function(t){return null===t.offsetParent||"hidden"===getComputedStyle(t).visibility}(t))}r.isTabbable=function(t){if(!t)throw new Error("No node provided");return!1!==i.call(t,o)&&a(t)},r.isFocusable=function(t){if(!t)throw new Error("No node provided");return!1!==i.call(t,l)&&s(t)};var l=n.concat("iframe").join(",");function c(t){var e=parseInt(t.getAttribute("tabindex"),10);return isNaN(e)?function(t){return"true"===t.contentEditable}(t)?0:t.tabIndex:e}function u(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex}function d(t){return"INPUT"===t.tagName}t.exports=r},function(t,e,n){var o=n(3);t.exports=function(){return o.Date.now()}},function(t,e,n){(function(e){var n="object"==typeof e&&e&&e.Object===Object&&e;t.exports=n}).call(this,n(9))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var o=n(11),i=n(0),r=n(13),a=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(r(t))return NaN;if(i(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=i(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=o(t);var n=s.test(t);return n||l.test(t)?c(t.slice(2),n?2:8):a.test(t)?NaN:+t}},function(t,e,n){var o=n(12),i=/^\s+/;t.exports=function(t){return t?t.slice(0,o(t)+1).replace(i,""):t}},function(t,e){var n=/\s/;t.exports=function(t){for(var e=t.length;e--&&n.test(t.charAt(e)););return e}},function(t,e,n){var o=n(14),i=n(17);t.exports=function(t){return"symbol"==typeof t||i(t)&&"[object Symbol]"==o(t)}},function(t,e,n){var o=n(4),i=n(15),r=n(16),a=o?o.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":a&&a in Object(t)?i(t):r(t)}},function(t,e,n){var o=n(4),i=Object.prototype,r=i.hasOwnProperty,a=i.toString,s=o?o.toStringTag:void 0;t.exports=function(t){var e=r.call(t,s),n=t[s];try{t[s]=void 0;var o=!0}catch(t){}var i=a.call(t);return o&&(e?t[s]=n:delete t[s]),i}},function(t,e){var n=Object.prototype.toString;t.exports=function(t){return n.call(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e,n){"use strict";n.r(e);var o=function(t){var e=t.Element.prototype;"function"!=typeof e.matches&&(e.matches=e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),n=0;e[n]&&e[n]!==this;)++n;return Boolean(e[n])}),"function"!=typeof e.closest&&(e.closest=function(t){for(var e=this;e&&1===e.nodeType;){if(e.matches(t))return e;e=e.parentNode}return null})},i=n(5),r=n.n(i),a=n(6),s=n.n(a),l=n(1),c=n.n(l),u=n(2),d=n.n(u);function f(t){return Array.prototype.slice.call(t)}function p(t,e){return t?f((e||document).querySelectorAll(t)):[]}function h(t,e){return"string"==typeof t?p(t,e):t instanceof Element?[t]:t?Array.prototype.slice.call(t):[]}function v(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function g(t){return t&&"Object"===t.constructor.name}function b(t,e,n){return t=Math.min(n,t),t=Math.max(e,t)}var y=function(){var t=!1;try{var e=Object.defineProperty({},"passive",{get:function(){t={passive:!0}}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}return t}();function m(t,e){return e.reduce((function(e,n){return e[n]=t[n],e}),{})}function S(t){var e=[];for(var n in t)v(t,n)&&e.push(t[n]);return e}"function"==typeof Object.values&&Object.values;function x(t){return(x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function w(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function k(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?w(Object(n),!0).forEach((function(e){O(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function O(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function A(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}var T=n(19),j=1,I=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};E(this,t),this.terms={prev:/(prev|back|before|left|up)/,next:/(next|forward|after|right|down)/},this.callbacks={load:[],change:[],"change.click":[],"change.scroll":[],"change.keydown":[],"change.focusin":[],scroll:[],"scroll.start":[],"scroll.end":[]},this.init(e,n),this.container&&(this.watchForChanges(),this.container.SnapSlider=this,window._SnapSliders[this.id]=this)}var e,n,o;return e=t,o=[{key:"isValidIndex",value:function(t){return["first","middle","last","prev","next"].indexOf(t)>=0||parseInt(t,10)>=1}},{key:"getButtonTarget",value:function(t){var e=t?t.getAttribute("data-snap-slider-goto"):"";if(!e)return{};var n=e.split(":").map((function(t){return t.trim()})),o=n.pop(),i=n.pop();if(!i){var r=t.closest("[data-snap-slider-nav]"),a=t.closest("[data-snap-slider]");r&&(i=r.getAttribute("data-snap-slider-nav")),a&&(i=a.getAttribute("data-snap-slider"))}if(!i){var s=t.closest("data-snap-slider");s&&(i=s.getAttribute("data-snap-slider"))}return{sliderID:i,index:o}}},{key:"handleGoto",value:function(e){var n=e.target.closest("[data-snap-slider-goto]"),o=t.getButtonTarget(n),i=o.sliderID,r=o.index,a=window._SnapSliders[i];a&&a.goto(r,null,e)}},{key:"isRelative",value:function(t){return"prev"===t||"next"===t}},{key:"notFound",value:function(t){console.log("\n😢 Oh no! Snap Slider couldn't find a slider for \"".concat(t,"\".\n\n-------------------------------------------------------------------------------------------\nℹ️ NOTE: Make sure the elements you're trying to debug have a `data-snap-slider` attribute.\n-------------------------------------------------------------------------------------------\n\n"))}},{key:"get",value:function(t){return window._SnapSliders[t]}},{key:"debug",value:function(e){var n=[];0===arguments.length&&(e="[data-snap-slider]"),"string"==typeof e&&v(window._SnapSliders,e)&&(e='[data-snap-slider="'.concat(e,'"]')),(n=h(e)).length?n.forEach((function(o,i){var r=o.closest("[data-snap-slider-goto]"),a=o.closest("[data-snap-slider-nav]"),s=o.closest("[data-snap-slider]"),l=n.length>1?"#".concat(i+1," "):"";if(r){var c=t.getButtonTarget(r),u=window._SnapSliders[c.sliderID],d=c.index,f=t.isValidIndex(d)?'"'.concat(d,'"'):'🚫 "'.concat(d,'" - Yikes! This index is invalid.\n\nUse a positive number instead, or one of the following aliases:\n\n ').concat(["first","middle","last","prev","next"].map((function(t){return"• ".concat(t)})).join("\n")),h=c.sliderID?'"'.concat(c.sliderID,'"'):"🤷♀️ We couldn't find any.\n\n • Make sure your button is inside a `data-snap-slider-nav` element, or...\n • Include the slider ID you want to target in your `data-snap-slider-goto` attribute.\n ◦ For example, `data-snap-slider-goto=\"example-slider:".concat(c.index||"prev",'"`.'),v='🤷♀️ We couldn\'t find any.\n\n • Double check that your slider ID is correct (👆).\n • Make sure your slider has the same ID in its `data-snap-slider` attribute.\n ◦ For example, `data-snap-slider="example-slider"`.',g="🤷♀️ We couldn't find any.\n\n • Double check that your index is valid (👆).\n • Make sure a slide actually exists at that index (👇).",b="🤷♀️ We couldn't find any.\n\n • Double check that your index is valid (👆).\n • Make sure a slide actually exists at that index.\n • Make sure your slider recognizes the slide element as a slide.";return u&&u.container&&(v=u.container,g=u.getIndexNumber(d),b=u.getSlide(d)),T.section({heading:"🕹 Button ".concat(l),description:r,groups:[{heading:"1. What slider is this button targeting?",items:[{heading:"Slider ID",description:h},{heading:"Slider Element",description:v},{heading:"Slider Object",description:u||"🤷♀️ We couldn't find any."}]},{heading:"2. Which slide will it go to?",items:[{heading:"Slide Index",description:f},{heading:"Slide Index (Number)",description:g},{heading:"Slide Element",description:b}]}],collapsed:!0})}if(a){var y=a.getAttribute("data-snap-slider-nav"),m=window._SnapSliders[y],S=p("[data-snap-slider-goto]",a);y=y?'"'.concat(y,'"'):'🤷♀️ We couldn\'t find any.\n\n • Include the slider ID you want to target in your `data-snap-slider-nav` attribute.\n ◦ For example, `data-snap-slider-nav="example-slider"`.';var x="🤷♀️ We couldn't find any.\n\n • Make sure the ID in your container's `data-snap-slider` attribute and the ID in your nav's `data-snap-slider-nav` attribute both match.";return S.length||(S="🤷♀️ We couldn't find any.\n\n • Make sure your buttons have a `data-snap-slider-goto` attribute."),m&&m.container&&(x=m.container),T.section({heading:"🗺 Navigation ".concat(l),description:a,groups:[{heading:"1. What slider is this nav targeting?",items:[{heading:"Slider ID",description:y},{heading:"Slider Element",description:x},{heading:"Slider Object",description:m||"🤷♀️ We couldn't find any."}]},{heading:"2. What buttons are in this nav?",items:[{heading:"Buttons",description:S}]}],collapsed:!0})}if(s){var w=s.getAttribute("data-snap-slider"),k=window._SnapSliders[w],O=p('[data-snap-slider-nav="'.concat(w,'"]')),E=k?k.getButtons():[];return w=w?'"'.concat(w,'"'):'🤷♀️ We couldn\'t find any.\n\n • Include the slider ID you want in your `data-snap-slider` attribute.\n ◦ For example, `data-snap-slider="example-slider"`.',O.length||(O="🤷♀️ We couldn't find any.\n\n • Make sure the ID in your container's `data-snap-slider` attribute and the ID in your nav's `data-snap-slider-nav` attribute both match."),E.length||(E='🤷♀️ We couldn\'t find any.\n\n • Make sure your button is inside a `data-snap-slider-nav` element, or...\n • Include the slider ID you want to target in your `data-snap-slider-goto` attribute.\n ◦ For example, `data-snap-slider-goto="example-slider:prev"`.'),T.section({heading:"🥨 Slider ".concat(l),description:s,groups:[{heading:"1. What slider is this?",items:[{heading:"Slider ID",description:w},{heading:"Slider Object",description:k||"🤷♀️ We couldn't find any."}]},{heading:"2. What navs target this slider?",items:[{heading:"Navs",description:O}]},{heading:"3. What buttons target this slider?",items:[{heading:"Buttons",description:E}]}],collapsed:!0})}return t.notFound(e)})):t.notFound(e)}}],(n=[{key:"init",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(t)&&(e=t),this.options=k({container:t,id:"",slides:"",nav:"",buttons:"",prev:"",next:"",start:0,loop:null,on:{}},e);var n=h(this.options.container).shift();if(n){for(var o in this.container=n,this.options.buttons=e.buttons||this.container.getAttribute("data-snap-slider-buttons"),this.options.prev=e.prev||this.container.getAttribute("data-snap-slider-prev"),this.options.next=e.next||this.container.getAttribute("data-snap-slider-next"),this.id=this.getMaybeSetID(n,this.options.id),this.slides=this.getMaybeSetSlides(n,this.options.slides),this.align=this.getMaybeSetAlign(n,this.options.align),this.current=this.getMaybeSetStart(n,this.options.start),this.loop=this.getMaybeSetLoop(n,this.options.loop),this.transition=null,this.scrolling=!1,this.options.on)v(this.options.on,o)&&this.on(o,this.options.on[o]);var i=m(this.options,["buttons","prev","next"]);this.addGotoButtons(k(k({},i),{},{container:n})),this.addNav('[data-snap-slider-nav="'.concat(this.id,'"]'),i),this.options.nav&&this.addNav(this.options.nav,i),this.update()}else console.log("\n🚫 Whoops! Snap Slider can't find a container element matching \"".concat(this.options.container,"\".\n\n🔍 Please check your selectors for typos. Make sure the element actually exists\n in the DOM when Snap Slider tries to initialize it.\n\n👇 Here's a copy of the options you tried to initialize with for debugging:\n\n"),this.options,"\n\n")}},{key:"getMaybeSetID",value:function(t,e){return(e=e||t.getAttribute("data-snap-slider")||t.id)||(e="slider-".concat(j),j+=1),t.setAttribute("data-snap-slider",e),e}},{key:"getMaybeSetSlides",value:function(t,e){e=e&&"string"==typeof e?e:t.getAttribute("data-snap-slider-slides"),t.setAttribute("data-snap-slider-slides",e||"");var n=e?h(e,t):f(t.children);return n.forEach((function(t){return t.setAttribute("tabindex","-1")})),n}},{key:"getMaybeSetAlign",value:function(t,e){return e=e||t.getAttribute("data-snap-slider-align")||"",t.setAttribute("data-snap-slider-align",e),e}},{key:"getMaybeSetStart",value:function(e,n){return t.isValidIndex(n)||(n=e.getAttribute("data-snap-slider-start")||1),e.setAttribute("data-snap-slider-start",n),n}},{key:"getMaybeSetLoop",value:function(t,e){return e="boolean"==typeof e?e:"true"===t.getAttribute("data-snap-slider-loop"),t.setAttribute("data-snap-slider-loop",e),e}},{key:"getSnapAlign",value:function(t){var e=function(t,e){var n=window.getComputedStyle(t);return n&&v(n,e)?n[e]:""}(t,"scrollSnapAlign");return e&&e.indexOf("none")<0?e:function(t,e){return t&&(t=t.closest("[".concat(e,"]")))?t.getAttribute(e):""}(t,"data-snap-slider-align")||"start"}},{key:"getSlide",value:function(t){return t=this.getIndexNumber(t),this.slides[t-1]}},{key:"getCurrentSlide",value:function(){return this.slides[this.current-1]}},{key:"getIndexNumber",value:function(t){var e;return e="first"===t?1:"middle"===t?Math.ceil(this.slides.length/2):"last"===t?this.slides.length:"prev"===t?this.current-1:"next"===t?this.current+1:parseInt(t,10)||-1,this.loop?(e<1&&(e=this.slides.length),e>this.slides.length&&(e=1)):(e<1||e>this.slides.length)&&(e=-1),e||1}},{key:"getScrollOffset",value:function(t){var e=this.container,n=this.getSnapAlign(t),o=t.offsetTop,i=t.offsetLeft;return n.indexOf("center")>=0?(o=t.offsetTop+t.offsetHeight/2-e.offsetHeight/2,i=t.offsetLeft+t.offsetWidth/2-e.offsetWidth/2):n.indexOf("end")>=0&&(o=t.offsetTop-e.offsetHeight+t.offsetHeight,i=t.offsetLeft-e.offsetWidth+t.offsetWidth),{top:o=b(o,0,e.scrollHeight),left:i=b(i,0,e.scrollWidth)}}},{key:"goto",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;e=k({focus:!0,force:!1,ignoreCallbacks:!1,immediate:!1},e);var o=this.getIndexNumber(t);if(!e.force&&o===this.current)return!1;var i=this.getSlide(o);if(!i)return!1;var r=this.getScrollOffset(i),a=r.top,s=r.left;return e.immediate?this.container.scroll({top:a,left:s}):(this.startTransition(o),this.container.scroll({top:a,left:s,behavior:"smooth"})),this.current=o,this.fireEvent("change",n,e),!0}},{key:"buildGoto",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="";return t||(n+="".concat(this.id,":")),n+e}},{key:"setGoto",value:function(t,e){var n=this;(t=h(t)).forEach((function(t){t.setAttribute("data-snap-slider-goto",n.buildGoto(t.closest("[data-snap-slider], [data-snap-slider-nav]"),e))}))}},{key:"startTransition",value:function(t){var e=this;this.transition={from:this.current,to:t,diff:Math.abs(t-this.current)};var n=this.transition.to;this.checkTransition&&clearTimeout(this.checkTransition),this.checkTransition=setTimeout((function(){e.transition.to===n&&e.stopTransition()}),1e3)}},{key:"stopTransition",value:function(){this.transition=null,clearTimeout(this.checkTransition)}},{key:"isPrevButton",value:function(t){return!!(t=h(t).shift())&&((t.getAttribute("data-snap-slider-goto")||"").match(/\bprev$/)||t.textContent.toLowerCase().match(this.terms.prev)||t.className.toLowerCase().match(this.terms.prev))}},{key:"isNextButton",value:function(t){return!!(t=h(t).shift())&&((t.getAttribute("data-snap-slider-goto")||"").match(/\bnext$/)||t.textContent.toLowerCase().match(this.terms.next)||t.className.toLowerCase().match(this.terms.next))}},{key:"isCurrent",value:function(e){return!t.isRelative(e)&&this.getIndexNumber(e)===this.current}},{key:"addGotoButtons",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(t)&&(n=t);var o=h((n=k({container:"",buttons:t,prev:"",next:""},n)).buttons,n.container),i=h(n.prev,n.container),r=h(n.next,n.container);i.forEach((function(t){return t.hasAttribute("data-snap-slider-goto")||e.setGoto(i,"prev")})),r.forEach((function(t){return t.hasAttribute("data-snap-slider-goto")||e.setGoto(r,"next")}));var a=1;return o.forEach((function(t){if(t.hasAttribute("data-snap-slider-goto"))return null;if(e.isPrevButton(t))return e.setGoto(t,"prev");if(e.isNextButton(t))return e.setGoto(t,"next");var n=parseInt(t.textContent.replace(/.*\b(\d+)\b.*/,"$1"),10)||a;return a=n+1,e.setGoto(t,n)})),this.updateButtons(),!0}},{key:"getNavs",value:function(){var t=this;return p("[data-snap-slider-nav]").filter((function(e){return e.getAttribute("data-snap-slider-nav")===t.id}))}},{key:"getButtons",value:function(){var e=this;return p("[data-snap-slider-goto]").filter((function(n){return t.getButtonTarget(n).sliderID===e.id}))}},{key:"updateButtons",value:function(){var e=this;this.current&&this.getButtons().forEach((function(n){var o=t.getButtonTarget(n).index;e.isCurrent(o)?n.classList.add("is-current"):n.classList.remove("is-current"),!e.loop&&t.isRelative(o)&&("prev"===o&&1===e.current||"next"===o&&e.current===e.slides.length?n.classList.add("is-disabled"):n.classList.remove("is-disabled"))}))}},{key:"updateSlides",value:function(){var t=this;this.slides.forEach((function(e,n){n===t.current-1?(e.classList.add("is-current"),e.removeAttribute("aria-hidden"),p("[data-snap-slider-tabindex]",e).forEach((function(t){t.removeAttribute("tabindex")}))):(e.classList.remove("is-current"),e.setAttribute("aria-hidden","true"),s()(e).forEach((function(t){t.setAttribute("tabindex","-1"),t.setAttribute("data-snap-slider-tabindex","")})))}))}},{key:"addNav",value:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};g(t)&&(n=t);var o=h((n=k({container:t,buttons:"",prev:"",next:""},n)).container);return!!o.length&&(o.forEach((function(t){t.setAttribute("data-snap-slider-nav",e.id);var o=t.getAttribute("data-snap-slider-buttons")||n.buttons||"button",i=n.prev||t.getAttribute("data-snap-slider-prev"),r=n.next||t.getAttribute("data-snap-slider-next");e.addGotoButtons({container:t,buttons:o,prev:i,next:r})})),!0)}},{key:"getClosest",value:function(){var t=this;return this.slides.reduce((function(e,n,o){o+=1;var i=t.getScrollOffset(n),r={index:o,slide:n,diff:{top:Math.abs(t.container.scrollTop-i.top),left:Math.abs(t.container.scrollLeft-i.left)}};return e?r.diff.left<=e.diff.left&&r.diff.top<=e.diff.top?r:e:r}),!1)}},{key:"watchForChanges",value:function(){var t=this;this.scrollListener=d()((function(e){var n=t.getClosest();t.transition||n.index===t.current||(t.current=n.index,t.fireEvent("change",e)),t.scrolling||(t.scrolling=!0,t.fireEvent("scroll.start",e)),t.fireEvent("scroll",e)}),250),this.scrollEndListener=c()((function(e){t.scrolling=!1,t.fireEvent("scroll.end",e),t.stopTransition()}),250),this.arrowKeyListener=d()((function(e){if(!e.defaultPrevented){var n=["Up","ArrowUp","Left","ArrowLeft"].indexOf(e.key)>=0,o=["Down","ArrowDown","Right","ArrowRight"].indexOf(e.key)>=0;(n||o)&&(t.goto(o?"next":"prev",null,e),e.preventDefault())}}),250),this.focusListener=function(e){var n,o;t.scrolling&&!t.transition||(t.slides.forEach((function(t,i){t.contains(e.target)&&(n=t,o=i+1)}),null),n&&t.goto(o,null,e))},this.resizeObserver={observe:function(){},disconnect:function(){}},"ResizeObserver"in window&&(this.resizeObserver=new ResizeObserver(this.resizeCallback.bind(this))),setTimeout((function(){t.container.addEventListener("scroll",t.scrollListener,y),t.container.addEventListener("scroll",t.scrollEndListener,y),t.container.addEventListener("keydown",t.arrowKeyListener),t.container.addEventListener("focusin",t.focusListener),t.resizeObserver.observe(t.container),t.fireEvent("load")}),100)}},{key:"hasLoaded",value:function(){this.container.classList.add("has-loaded")}},{key:"update",value:function(){this.goto(this.current,{focus:!1,force:!0,ignoreCallbacks:!0,immediate:!0})}},{key:"destroy",value:function(){for(var t in this.stopTransition(),this.container.removeEventListener("scroll",this.scrollListener),this.container.removeEventListener("scroll",this.scrollEndListener),this.container.removeEventListener("keydown",this.arrowKeyListener),this.resizeObserver.disconnect(),this.callbacks)v(this.callbacks,t)&&(this.callbacks[t]=[]);delete this.container.SnapSlider,delete window._SnapSliders[this.id]}},{key:"reset",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=this.options;delete e.on,delete t.container,delete t.id,this.init(this.container,k(k({},e),t))}},{key:"resizeCallback",value:function(){this.update()}},{key:"fireEvent",value:function(t,e){var n=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(v(this.callbacks,t)&&(o=k({focus:!0,ignoreCallbacks:!1},o),"load"===t&&this.hasLoaded(),"change"===t&&(this.updateButtons(),this.updateSlides()),o.focus&&this.handleFocus(t,e),!o.ignoreCallbacks)){e=e||{};var i=[t];v(this.callbacks,"".concat(t,".").concat(e.type))&&i.push("".concat(t,".").concat(e.type)),i.forEach((function(t){n.callbacks[t].forEach((function(t){"function"==typeof t&&t(n,e)}))}))}}},{key:"handleFocus",value:function(e,n){if(this.transition){if(n&&"change"===e){var o=n.target.closest("[data-snap-slider-goto]"),i=t.getButtonTarget(o).index;if(t.isRelative(i))return}this.transition.diff<=1&&"change"===e&&this.getCurrentSlide().focus({preventScroll:!0}),this.transition.diff>1&&"scroll.end"===e&&(document.activeElement&&document.activeElement!==document.body&&!document.activeElement.closest("[data-snap-slider-goto]")||this.getCurrentSlide().focus({preventScroll:!0}))}}},{key:"on",value:function(t,e){v(this.callbacks,t)?"function"==typeof e?this.callbacks[t].push(e):console.log('\n 🚫 Whoops! Snap Slider can only add functions as callbacks.\n\n 👀 It looks like you passed a "'.concat(x(e),'" instead.\n\n'),e,"\n\n"):console.log("\n🚫 Whoops! Snap Slider can't add events for \"".concat(t,'".\n\n📝 Please make sure your event matches one of the ones in this list:\n\n'),Object.keys(this.callbacks),"\n\n")}}])&&A(e.prototype,n),o&&A(e,o),t}();window._SnapSliders=[],window.SnapSlider=I,"undefined"!=typeof $&&($.fn.snapSlider=function(t){return new I(this,t)}),function(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t)}((function(){o(window),r.a.polyfill(),p("[data-snap-slider]").forEach((function(t){return new I(t)})),function(t,e,n,o){var i=document.querySelector(t);!!i&&i.addEventListener(e,(function(t){for(var e=i.querySelectorAll(n),r=t.target,a=0,s=e.length;a<s;a+=1)for(var l=r,c=e[a];l&&l!==i;){if(l===c)return o.call(c,t);l=l.parentNode}}))}("body","click","[data-snap-slider-goto]",I.handleGoto)}));e.default=I},function(t,e,n){"use strict";function o(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-",n="",o=0;o<t;o+=1)n+=e;return n}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t){return"object"===i(t)?"%o":"number"==typeof t?"%d":"%s"}function a(t){var e=t.heading,n=t.description,i=t.groups,a=t.collapsed?"groupCollapsed":"group";console.log("%c\n┏━━".concat(o(e.length,"━"),"━━┓\n┃ ").concat(e," ┃\n┗━━").concat(o(e.length,"━"),"━━┛"),"font-size: 1.25em;","\n\n",n,"\n\n"),i.forEach((function(t){var e;console[a]("%c".concat(t.heading),"font-weight: bold;");var n=[],o="";t.items.forEach((function(t){var e=t.heading,i=t.description;o+="\n%c".concat(r(e),"\n"),n.push("text-decoration: underline;",e),o+="\n%c".concat(r(i),"\n"),n.push("text-decoration: none;",i)})),(e=console).log.apply(e,[o].concat(n)),console.groupEnd()})),console.log("\n")}n.r(e),n.d(e,"getSubstitution",(function(){return r})),n.d(e,"section",(function(){return a}))}]).default}));
//# sourceMappingURL=snap-slider.min.js.map