Comparing version 2.1.4 to 2.2.0
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["sm-slider"]=e():t["sm-slider"]=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var r=i[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,i){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r="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},s=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},o=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}();e.default=function(){function t(e,i){n(this,t),this.handler=function(){},this.state=e,this.handler=i}return o(t,[{key:"getState",value:function(){return this.state}},{key:"setState",value:function(t){var e=s({},this.state);switch(void 0===t?"undefined":r(t)){case"function":this.state=s({},this.state,t(this.state));break;case"object":this.state=s({},this.state,t);break;default:throw Error()}this.handler(e)}}]),t}(),t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(0);e.default=function(t,e){var i=2>=arguments.length||void 0===arguments[2]||arguments[2],n=t.getState(),r=n.visibleSlides,s=n.totalSlides,o=n.isInfinite,a=!o&&0===e||r>=s,u=!o&&e===s-r||r>=s;t.setState(function(t){return{currentSlide:e,isNextDisabled:u,isPrevDisabled:a,animate:i}})},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function r(t,e,i,n,r){e.classList.remove("animatable"),(i===n||0>i)&&t.setState(function(t){return{currentSlide:r,animate:!1}})}function s(t,e,i,n,r,s,o){if(i>=n)return 0;var a=s/i,u=r*a;return-(a*t+(o?a*e:0))+u}Object.defineProperty(e,"__esModule",{value:!0});var o=i(0),a=(n(o),i(12)),u=n(a);e.default=function(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=i.getState(),a=o.currentSlide,l=o.innerSize,d=o.totalSlides,f=o.animate,c=o.visibleSlides,v=o.offsetLeft,h=o.step,p=o.isVertical,b=o.isInfinite,y=a;a===d?y=0:0>a&&(y=d-h),f&&!n&&(e.classList.add("animatable"),(0,u.default)(e,"transitionend",r.bind(void 0,i,e,a,d,y)),t.dispatchEvent(new CustomEvent("slide",{detail:{to:y,internal:!0}}))),e.style.transform=(p?"translateY":"translateX")+"("+s(a,h,c,d,v,l,b)+"px)"},t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t,e,i){return t.getBoundingClientRect().width-(e&&!e.classList.contains("inset")?e.getBoundingClientRect().width:0)-(i&&!i.classList.contains("inset")?i.getBoundingClientRect().width:0)},r=function(t,e,i){return t.getBoundingClientRect().height-(e&&!e.classList.contains("inset")?e.getBoundingClientRect().height:0)-(i&&!i.classList.contains("inset")?i.getBoundingClientRect().height:0)};e.default=function(t,e,i){return arguments.length>3&&void 0!==arguments[3]&&arguments[3]?r(t,e,i):n(t,e,i)},t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){var i=t.visibleSlides,n=t.step,r=t.offsetLeft,s=t.breakpoints;return s&&Object.keys(s).length?Object.keys(s).reduce(function(t,o){return e<parseInt(o,10)?t:{visibleSlides:s[o].visibleSlides||i,step:s[o].step||n,offsetLeft:s[o].offsetLeft||r}},{visibleSlides:i,step:n,offsetLeft:r}):{visibleSlides:i,step:n,offsetLeft:r}},t.exports=e.default},function(t,e,i){t.exports=i(6)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(7),r=function(t){return t&&t.__esModule?t:{default:t}}(n);i(24),i(25),e.default=r.default,t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var s=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(t[n]=i[n])}return t},o=function(){function t(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),a=i(8),u=n(a),l=i(0),d=n(l),f=i(10),c=n(f),v=i(11),h=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e.default=t,e}(v),p=i(2),b=n(p),y=i(13),S=n(y),m=i(14),g=n(m),w=i(15),$=n(w),_=i(16),x=n(_),L=i(1),E=n(L),O=i(3),j=n(O),M=i(17),P=n(M),A=i(18),N=n(A),C=i(19),D=n(C),I=i(20),T=n(I),k=i(22),R=n(k),q=i(23),F=n(q),z=i(4),V=n(z),B=new c.default,W={infinite:!1,visibleSlides:1,step:1,offsetLeft:0,autoplay:0,showEmptySlides:!0,disabledSwipe:!1},X={currentSlide:0,innerSize:0,totalSlides:0,step:1,visibleSlides:1,offsetLeft:0,isNextDisabled:!1,isPrevDisabled:!1,isVertical:!1,isInfinite:!1},H=function(){var t=this;this.nextSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,x.default)(B(t).$ref,B(t).$slides,B(t).store,B(t).options,e)},this.previousSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,$.default)(B(t).$ref,B(t).$slides,B(t).store,B(t).options,e)},this.toSlide=function(e){(0,E.default)(B(t).store,e)},this.addEventListener=function(e,i,n){B(t).$ref.addEventListener(e,i,n)},this.removeEventListener=function(e,i){B(t).$ref.removeEventListener(e,i)},this.handleChange=function(e){var i=B(t),n=i.$slides,r=i.store,s=i.options,o=r.getState(),a=o.currentSlide,u=o.innerSize,l=o.visibleSlides,d=o.step,f=o.isNextDisabled,c=o.isPrevDisabled;u!==e.innerSize&&(0,g.default)(B(t).$ref,n,r),l===e.visibleSlides&&d===e.step||((0,N.default)(n),(0,D.default)(n,s,r),B(t).$navigationDots=(0,T.default)(B(t).$navigation,B(t).store)),B(t).$arrowLeft&&c!==e.isPrevDisabled&&(B(t).$arrowLeft.style.visibility=c?"hidden":"visible"),B(t).$arrowRight&&f!==e.isNextDisabled&&(B(t).$arrowRight.style.visibility=f?"hidden":"visible"),(a!==e.currentSlide||s.infinite)&&((0,b.default)(B(t).$ref,n,r),B(t).$navigationDots&&(0,I.updateNavigation)(B(t).$navigationDots,a,B(t).store),B(t).$textDots&&(0,k.updateTextNavigation)(B(t).$textDots,a,B(t).$slides))}};e.default=function(){function t(e,i){var n=this;if(r(this,t),H.call(this),B(this).$ref=e,B(this).options=s({},W,i),B(this).$slides=(0,F.default)(B(this).$ref.querySelector(".slides"),B(this).options),B(this).$arrowLeft=B(this).$ref.querySelector(".arrow-left"),B(this).$arrowRight=B(this).$ref.querySelector(".arrow-right"),B(this).$navigation=B(this).$ref.querySelector(".dot-nav"),B(this).$textNavigations=B(this).$ref.querySelectorAll(".text-nav"),!B(this).$slides||!B(this).$slides.children.length)throw h.NO_CHILDREN;(0,N.default)(B(this).$slides);var o=B(this).$ref.classList.contains("sm-slider--vertical"),a=(0,j.default)(B(this).$ref,B(this).$arrowLeft,B(this).$arrowRight,o),l=(0,V.default)(B(this).options,window.innerWidth),f=l.visibleSlides,c=l.step,v=l.offsetLeft;if(0>v||v>1)throw h.INVALID_OFFSET_LEFT;var p=B(this).$slides.children.length,b=f>=p,y=!i.infinite||f>=p,m=s({},X,{totalSlides:p,innerSize:a,visibleSlides:f,step:c,offsetLeft:v,isVertical:o,isPrevDisabled:y,isNextDisabled:b,isInfinite:i.infinite});B(this).store=new d.default(m,this.handleChange),(0,D.default)(B(this).$slides,B(this).options,B(this).store),(0,g.default)(B(this).$ref,B(this).$slides,B(this).store),B(this).$navigationDots=(0,T.default)(B(this).$navigation,B(this).store),B(this).$textDots=(0,R.default)(B(this).$textNavigations,B(this).store,B(this).$slides),B(this).$arrowLeft&&(B(this).$arrowLeft.addEventListener("click",$.default.bind(this,B(this).$ref,B(this).$slides,B(this).store,B(this).options,!1)),B(this).$arrowLeft.style.visibility=y?"hidden":"visible"),B(this).$arrowRight&&(B(this).$arrowRight.addEventListener("click",x.default.bind(this,B(this).$ref,B(this).$slides,B(this).store,B(this).options,!1)),B(this).$arrowRight.style.visibility=b?"hidden":"visible"),window.addEventListener("resize",(0,u.default)(S.default.bind(this,B(this).$ref,B(this).store,B(this).options,B(this).$arrowLeft,B(this).$arrowRight),200)),b||B(this).options.disabledSwipe||(0,P.default)(B(this).$slides,B(this).store,B(this).options,function(t){switch(t){case"left":B(n).store.setState(function(t){return{step:1}}),(0,x.default)(B(n).$ref,B(n).$slides,B(n).store,B(n).options,!1),B(n).store.setState(function(t){return{step:B(n).options.step||1}});break;case"right":(0,$.default)(B(n).$ref,B(n).$slides,B(n).store,B(n).options,!1);break;default:(0,E.default)(B(n).store,B(n).store.getState().currentSlide)}}),B(this).$ref.addEventListener("slide",function(t){var e=t.detail,i=e.internal,r=e.to;return i?null:n.toSlide(r)}),B(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:n.nextSlide(!0)}),B(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:n.previousSlide(!0)}),B(this).options.autoplay&&(B(this).isIntervalPaused=!1,setInterval(function(){return!B(n).isIntervalPaused&&n.nextSlide()},B(this).options.autoplay),B(this).$ref.addEventListener("mouseenter",function(){B(n).isIntervalPaused=!0}),B(this).$ref.addEventListener("mouseleave",function(){B(n).isIntervalPaused=!1})),B(this).$ref.classList.remove("cloaked")}return o(t,null,[{key:"init",value:function(){var e=document.querySelectorAll("[data-sm-slider]"),i=[];return Array.prototype.forEach.call(e,function(e){var n=e.getAttribute("data-sm-slider");if(n){var r=void 0;try{r=JSON.parse(n)}catch(t){throw h.INVALID_OPTIONS}i.push(new t(e,r))}}),i}}]),t}(),t.exports=e.default},function(t,e,i){"use strict";(function(e){function i(t,e,i){function r(e){var i=p,n=b;return p=b=void 0,x=e,S=t.apply(n,i)}function s(t){return x=t,m=setTimeout(d,e),L?r(t):S}function a(t){var i=t-g,n=t-x,r=e-i;return E?$(r,y-n):r}function l(t){var i=t-g,n=t-x;return void 0===g||i>=e||0>i||E&&n>=y}function d(){var t=_();if(l(t))return f(t);m=setTimeout(d,a(t))}function f(t){return m=void 0,O&&p?r(t):(p=b=void 0,S)}function c(){void 0!==m&&clearTimeout(m),x=0,p=g=b=m=void 0}function v(){return void 0===m?S:f(_())}function h(){var t=_(),i=l(t);if(p=arguments,b=this,g=t,i){if(void 0===m)return s(g);if(E)return m=setTimeout(d,e),r(g)}return void 0===m&&(m=setTimeout(d,e)),S}var p,b,y,S,m,g,x=0,L=!1,E=!1,O=!0;if("function"!=typeof t)throw new TypeError(u);return e=o(e)||0,n(i)&&(L=!!i.leading,E="maxWait"in i,y=E?w(o(i.maxWait)||0,e):y,O="trailing"in i?!!i.trailing:O),h.cancel=c,h.flush=v,h}function n(t){var e=void 0===t?"undefined":a(t);return!!t&&("object"==e||"function"==e)}function r(t){return!!t&&"object"==(void 0===t?"undefined":a(t))}function s(t){return"symbol"==(void 0===t?"undefined":a(t))||r(t)&&g.call(t)==d}function o(t){if("number"==typeof t)return t;if(s(t))return l;if(n(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=n(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(f,"");var i=v.test(t);return i||h.test(t)?p(t.slice(2),i?2:8):c.test(t)?l:+t}var a="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},u="Expected a function",l=NaN,d="[object Symbol]",f=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,v=/^0b[01]+$/i,h=/^0o[0-7]+$/i,p=parseInt,b="object"==(void 0===e?"undefined":a(e))&&e&&e.Object===Object&&e,y="object"==("undefined"==typeof self?"undefined":a(self))&&self&&self.Object===Object&&self,S=b||y||Function("return this")(),m=Object.prototype,g=m.toString,w=Math.max,$=Math.min,_=function(){return S.Date.now()};t.exports=i}).call(e,i(9))},function(t,e,i){"use strict";var n,r="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};n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(n=window)}t.exports=n},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){var t=new WeakMap;return function(e){var i=t.get(e);return i||(i={},t.set(e,i)),i}},t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(t){return new(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Error)("[smSlider] "+t)};e.INVALID_OPTIONS=n("Slider could not be initialized with the provided options. Please check that you provided valid JSON."),e.NO_CHILDREN=n("Slider needs to contain children to be initialized."),e.INVALID_OFFSET_LEFT=n("The property `offsetLeft` has an invalid value. Please only provide values >= 0 and <= 1.")},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,i){t.addEventListener(e,function n(r){t.removeEventListener(e,n),i(r)})},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),s=(n(r),i(3)),o=n(s),a=i(4),u=n(a);e.default=function(t,e,i,n,r){var s=e.getState(),a=s.totalSlides,l=s.isVertical,d=s.currentSlide,f=s.isInfinite,c=(0,u.default)(i,window.innerWidth),v=c.visibleSlides,h=c.step,p=(0,o.default)(t,n,r,l),b=0===d&&!f,y=v>=a||d+v===a;e.setState(function(t){return{innerSize:p,visibleSlides:v,step:h,isNextDisabled:y,isPrevDisabled:b}})},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),s=(n(r),i(2)),o=n(s);e.default=function(t,e,i){var n=i.getState(),r=n.innerSize,s=n.visibleSlides,a=n.isVertical,u=a?"height":"width";(0,o.default)(t,e,i,!0),Array.prototype.forEach.call(e.children,function(t){t.style[u]=Math.round(r/s)+"px"})},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),s=(n(r),i(1)),o=n(s);e.default=function(t,e,i,n,r){var s=i.getState(),a=s.currentSlide,u=s.step,l=0,d=0!==a?a%u||u:u;r||t.dispatchEvent(new CustomEvent("previous",{detail:{internal:!0}})),l=n.infinite||a-d>0?a-d:0,requestAnimationFrame(function(){return(0,o.default)(i,l)})},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),s=(n(r),i(1)),o=n(s);e.default=function(t,e,i,n,r){var s=i.getState(),a=s.currentSlide,u=s.totalSlides,l=s.step,d=s.visibleSlides,f=s.isInfinite,c=0,v=a+l>u?u-a:l;r||t.dispatchEvent(new CustomEvent("next",{detail:{internal:!0}})),c=a+v,f||u-d>c||(c=u-d),requestAnimationFrame(function(){return(0,o.default)(i,c)})},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),s=(n(r),i(1)),o=n(s);e.default=function(t,e,i,n){var r=void 0,s=void 0,a=void 0,u=void 0,l=void 0,d=void 0,f=50,c=0;e.getState().isVertical||(t.addEventListener("touchstart",function(n){var o=n.changedTouches[0];r="none",f=e.getState().innerSize/i.visibleSlides/5,s=o.pageX,a=o.pageY;var u=t.style.transform.match(/-?\d+/i);u&&u[0]&&(t.classList.remove("animatable"),d=parseInt(u[0],10))},{passive:!0}),t.addEventListener("touchmove",function(e){var i=e.changedTouches[0];u=i.pageX-s,l=i.pageY-a,null!==d&&void 0!==d&&(t.style.transform="translateX("+(d+u)+"px)")},{passive:!0}),t.addEventListener("touchend",function(s){if(u||l){Math.abs(u)<f||Math.abs(l)>100?Math.abs(l)<f||Math.abs(u)>100?(t.classList.add("animatable"),t.style.transform="translateX("+d+"px)"):r=0>l?"up":"down":r=0>u?"left":"right";var a=window.getComputedStyle(t.children[0]).width.split("px")[0],v=void 0;v=0>u?-parseInt(a):parseInt(a),c=Math.abs(Math.round((d+v)/a)),i.infinite&&(c=Math.abs(Math.round((d+v)/a))-1),v>0&&d>=0&&v+d>0&&(c=0),window.setTimeout(function(){i.step>1&&i.infinite?c=c-i.step+1:i.infinite||c<e.getState().totalSlides-e.getState().visibleSlides||(c=e.getState().totalSlides-e.getState().visibleSlides,requestAnimationFrame(function(){return(0,o.default)(e,c+2)})),0===e.getState().currentSlide&&e.getState().currentSlide===c&&(0,o.default)(e,c+1),requestAnimationFrame(function(){return(0,o.default)(e,c)})},20),u=0,l=0,n(r)}},{passive:!0}))},t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){for(var e=t.children.length-1;e>=0;e--)t.children[e].hasAttribute("data-sm-slider-duplicate")?t.removeChild(t.children[e]):t.children[e].setAttribute("data-sm-slider-index",""+e)},t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(0);e.default=function(t,e,i){var n=i.getState(),r=n.step,s=n.visibleSlides,o=n.totalSlides;if(e.infinite&&o>=s){for(var a=[],u=[],l=t.children.length-1,d=0;r>d;d++)a.push(t.children[l-d].cloneNode(!0));for(var f=0;s>f;f++)u.push(t.children[f].cloneNode(!0));Array.prototype.forEach.call(a,function(e,i){e.setAttribute("data-sm-slider-index",l-i),e.setAttribute("data-sm-slider-duplicate",!0),t.insertBefore(e,t.firstElementChild)}),Array.prototype.forEach.call(u,function(e,i){e.setAttribute("data-sm-slider-index",i),e.setAttribute("data-sm-slider-duplicate",!0),t.appendChild(e)})}},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.updateNavigation=void 0;var r=i(0),s=(n(r),i(21)),o=n(s),a=i(1),u=n(a);e.default=function(t,e){var i=e.getState(),n=i.totalSlides,r=i.step;if(!(0,o.default)(t))return null;for(var s=Math.ceil(n/r),a=[],l=0;s>l;l++)!function(i){var n=document.createElement("div");n.classList.add("dot"),n.addEventListener("click",function(){return(0,u.default)(e,i)}),a.push(n),t.appendChild(n)}(l);return a[0].classList.add("active"),a};e.updateNavigation=function(t,e,i){var n=i.getState(),r=n.step,s=Math.floor(e/r);t.forEach(function(t,e){e===s?t.classList.add("active"):t.classList.remove("active")})}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){if(!t)return!1;for(;t.firstChild;)t.removeChild(t.firstChild);return!0},t.exports=e.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.updateTextNavigation=void 0;var r=i(0),s=(n(r),i(1)),o=n(s);e.default=function(t,e,i){var n=[];return t?(Array.prototype.forEach.call(t,function(t,r){t.getAttribute("data-sm-slider-ref")||t.setAttribute("data-sm-slider-ref",r);var s=t.getAttribute("data-sm-slider-ref"),a=i.querySelector('[data-sm-slider-hash="'+s+'"]');a&&(t.addEventListener("click",function(){return(0,o.default)(e,parseInt(a.getAttribute("data-sm-slider-index"),10))}),n=n.concat(t))}),n[0]&&n[0].classList.add("active"),n):n};e.updateTextNavigation=function(t,e,i){var n=i.querySelector('[data-sm-slider-index="'+e+'"]');n&&t.forEach(function(t){t.getAttribute("data-sm-slider-ref")===n.getAttribute("data-sm-slider-hash")?t.classList.add("active"):t.classList.remove("active")})}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(e.showEmptySlides)return t;var i=t.querySelectorAll(".slide");return Array.prototype.forEach.call(i,function(e){""===e.innerHTML&&t.removeChild(e)}),t},t.exports=e.default},function(t,e,i){"use strict";try{var n=new window.CustomEvent("test");if(n.preventDefault(),!0!==n.defaultPrevented)throw Error("Could not prevent default")}catch(t){var r=function(t,e){var i,n;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},i=document.createEvent("CustomEvent"),i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n=i.preventDefault,i.preventDefault=function(){n.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},i};r.prototype=window.Event.prototype,window.CustomEvent=r}},function(t,e){}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["sm-slider"]=e():t["sm-slider"]=e()}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var r=i[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,i){"use strict";function n(t){return(n="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,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,n)}return i}function s(t){for(var e=1;arguments.length>e;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach(function(e){l(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function c(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}function l(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}i.d(e,"a",function(){return u});var u=function(){function t(e,i){a(this,t),l(this,"state",void 0),l(this,"handler",function(){}),this.state=e,this.handler=i}return c(t,[{key:"getState",value:function(){return this.state}},{key:"setState",value:function(t){var e=s({},this.state);switch(n(t)){case"function":this.state=s({},this.state,{},t(this.state));break;case"object":this.state=s({},this.state,{},t);break;default:throw Error()}this.handler(e)}}]),t}()},function(t,e,i){"use strict";i(0);e.a=function(t,e){var i=2>=arguments.length||void 0===arguments[2]||arguments[2],n=t.getState(),r=n.visibleSlides,s=n.totalSlides,a=n.isInfinite,o=n.isClassActive,c=n.slidesWrapper,l=!a&&0===e||r>=s,u=!a&&e===s-r||r>=s;t.setState(function(t){return{currentSlide:e,isNextDisabled:u,isPrevDisabled:l,animate:i}});var d=function(t){var e=window.setTimeout(function(){null===t||void 0===t||t.classList.add("active"),clearTimeout(e)},300)};if(o){var f=t.getState().currentSlide,v=null===c||void 0===c?void 0:c.querySelectorAll(".slide:not([data-sm-slider-duplicate])").length,h=null===c||void 0===c?void 0:c.querySelectorAll(".slide"),p=t.getState().step;a&&(f+=p>1?p:1),Array.prototype.forEach.call(h,function(t){if(null===t||void 0===t||t.classList.remove("active"),a?d(h[f]):h[f].classList.add("active"),f>=v){null===t||void 0===t||t.classList.remove("active");var e=c.querySelector('.slide[data-sm-slider-index="0"]:not([data-sm-slider-duplicate])'),i=e||c.querySelector('.slide[data-sm-slider-index="1"]:not([data-sm-slider-duplicate])');return void(a?d(i):i.classList.add("active"))}if(0>=f){if(1===p){var n=c.querySelector('.slide[data-sm-slider-index="'+v+'"]:not([data-sm-slider-duplicate])'),r=n||c.querySelector('.slide[data-sm-slider-index="'+(v-1)+'"]:not([data-sm-slider-duplicate])');return void(a?d(r):r.classList.add("active"))}if(p>1){var s=c.querySelector('.slide[data-sm-slider-index="'+(v-p)+'"]:not([data-sm-slider-duplicate])'),o=s||c.querySelector('.slide[data-sm-slider-index="'+(v-p+1)+'"]:not([data-sm-slider-duplicate])');a?d(o):o.classList.add("active")}}})}}},function(t,e,i){"use strict";function n(t,e,i,n,r){e.classList.remove("animatable"),(i===n||0>i)&&t.setState(function(t){return{currentSlide:r,animate:!1}})}function r(t,e,i,n,r,s,a){if(i>=n)return 0;var o=s/i,c=r*o;return-(o*t+(a?o*e:0))+c}var s=(i(0),i(12));e.a=function(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],o=i.getState(),c=o.currentSlide,l=o.innerSize,u=o.totalSlides,d=o.animate,f=o.visibleSlides,v=o.offsetLeft,h=o.step,p=o.isVertical,b=o.isInfinite,y=c;c===u?y=0:0>c&&(y=u-h),d&&!a&&(e.classList.add("animatable"),Object(s.a)(e,"transitionend",n.bind(void 0,i,e,c,u,y)),t.dispatchEvent(new CustomEvent("slide",{detail:{to:y,internal:!0}})));var m=p?"translateY":"translateX",S=r(c,h,f,u,v,l,b);e.style.transform="".concat(m,"(").concat(S,"px)")}},function(t,e,i){"use strict";var n=function(t,e,i){return t.getBoundingClientRect().width-(e&&!e.classList.contains("inset")?e.getBoundingClientRect().width:0)-(i&&!i.classList.contains("inset")?i.getBoundingClientRect().width:0)},r=function(t,e,i){return t.getBoundingClientRect().height-(e&&!e.classList.contains("inset")?e.getBoundingClientRect().height:0)-(i&&!i.classList.contains("inset")?i.getBoundingClientRect().height:0)};e.a=function(t,e,i){return arguments.length>3&&void 0!==arguments[3]&&arguments[3]?r(t,e,i):n(t,e,i)}},function(t,e,i){"use strict";e.a=function(t,e){var i=t.visibleSlides,n=t.step,r=t.offsetLeft,s=t.breakpoints;return s&&Object.keys(s).length?Object.keys(s).reduce(function(t,a){return e<parseInt(a,10)?t:{visibleSlides:s[a].visibleSlides||i,step:s[a].step||n,offsetLeft:s[a].offsetLeft||r}},{visibleSlides:i,step:n,offsetLeft:r}):{visibleSlides:i,step:n,offsetLeft:r}}},function(t,e,i){t.exports=i(6)},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(7),r=i(24),s=(i.n(r),i(25));i.n(s);e.default=n.a},function(t,e,i){"use strict";function n(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,n)}return i}function r(t){for(var e=1;arguments.length>e;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?n(Object(i),!0).forEach(function(e){c(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):n(Object(i)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var i=0;e.length>i;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,i){return e&&a(t.prototype,e),i&&a(t,i),t}function c(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}i.d(e,"a",function(){return D});var l=i(8),u=i.n(l),d=i(0),f=i(10),v=i(11),h=i(2),p=i(13),b=i(14),y=i(15),m=i(16),S=i(1),g=i(3),w=i(17),O=i(18),j=i(19),$=i(20),L=i(22),E=i(23),x=i(4),P=new f.a,A={infinite:!1,visibleSlides:1,step:1,offsetLeft:0,autoplay:0,showEmptySlides:!0,disabledSwipe:!1,activeClass:!1},C={currentSlide:0,innerSize:0,totalSlides:0,step:1,visibleSlides:1,offsetLeft:0,isNextDisabled:!1,isPrevDisabled:!1,isVertical:!1,isInfinite:!1,isClassActive:!1},D=function(){function t(e,i){var n=this;if(s(this,t),c(this,"store",void 0),c(this,"nextSlide",function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Object(m.a)(P(n).$ref,P(n).$slides,P(n).store,P(n).options,t)}),c(this,"previousSlide",function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];Object(y.a)(P(n).$ref,P(n).$slides,P(n).store,P(n).options,t)}),c(this,"toSlide",function(t){Object(S.a)(P(n).store,t)}),c(this,"addEventListener",function(t,e,i){P(n).$ref.addEventListener(t,e,i)}),c(this,"removeEventListener",function(t,e){P(n).$ref.removeEventListener(t,e)}),c(this,"handleChange",function(t){var e=P(n),i=e.$slides,r=e.store,s=e.options,a=r.getState(),o=a.currentSlide,c=a.innerSize,l=a.visibleSlides,u=a.step,d=a.isNextDisabled,f=a.isPrevDisabled;c!==t.innerSize&&Object(b.a)(P(n).$ref,i,r),l===t.visibleSlides&&u===t.step||(Object(O.a)(i),Object(j.a)(i,s,r),P(n).$navigationDots=Object($.a)(P(n).$navigation,P(n).store)),P(n).$arrowLeft&&f!==t.isPrevDisabled&&(P(n).$arrowLeft.style.visibility=f?"hidden":"visible"),P(n).$arrowRight&&d!==t.isNextDisabled&&(P(n).$arrowRight.style.visibility=d?"hidden":"visible"),(o!==t.currentSlide||s.infinite)&&(Object(h.a)(P(n).$ref,i,r),P(n).$navigationDots&&Object($.b)(P(n).$navigationDots,o,P(n).store),P(n).$textDots&&Object(L.b)(P(n).$textDots,o,P(n).$slides))}),P(this).$ref=e,P(this).options=r({},A,{},i),P(this).$slides=Object(E.a)(P(this).$ref.querySelector(".slides"),P(this).options),P(this).$arrowLeft=P(this).$ref.querySelector(".arrow-left"),P(this).$arrowRight=P(this).$ref.querySelector(".arrow-right"),P(this).$navigation=P(this).$ref.querySelector(".dot-nav"),P(this).$textNavigations=P(this).$ref.querySelectorAll(".text-nav"),!P(this).$slides||!P(this).$slides.children.length)throw v.c;Object(O.a)(P(this).$slides);var a=P(this).$ref.classList.contains("sm-slider--vertical"),o=Object(g.a)(P(this).$ref,P(this).$arrowLeft,P(this).$arrowRight,a),l=Object(x.a)(P(this).options,window.innerWidth),f=l.visibleSlides,D=l.step,q=l.offsetLeft;if(0>q||q>1)throw v.a;var k=P(this).$slides.children.length,I=f>=k,M=!i.infinite||f>=k,T=r({},C,{totalSlides:k,innerSize:o,visibleSlides:f,step:D,offsetLeft:q,isVertical:a,isPrevDisabled:M,isNextDisabled:I,isInfinite:i.infinite,isClassActive:P(this).options.activeClass,slidesWrapper:P(this).$slides});if(P(this).store=new d.a(T,this.handleChange),Object(j.a)(P(this).$slides,P(this).options,P(this).store),Object(b.a)(P(this).$ref,P(this).$slides,P(this).store),P(this).$navigationDots=Object($.a)(P(this).$navigation,P(this).store),P(this).$textDots=Object(L.a)(P(this).$textNavigations,P(this).store,P(this).$slides),P(this).$arrowLeft&&(P(this).$arrowLeft.addEventListener("click",y.a.bind(this,P(this).$ref,P(this).$slides,P(this).store,P(this).options,!1)),P(this).$arrowLeft.style.visibility=M?"hidden":"visible"),P(this).$arrowRight&&(P(this).$arrowRight.addEventListener("click",m.a.bind(this,P(this).$ref,P(this).$slides,P(this).store,P(this).options,!1)),P(this).$arrowRight.style.visibility=I?"hidden":"visible"),window.addEventListener("resize",u()(p.a.bind(this,P(this).$ref,P(this).store,P(this).options,P(this).$arrowLeft,P(this).$arrowRight),200)),T.isClassActive){var N;null===(N=P(this).$slides.querySelectorAll(".slide:not([data-sm-slider-duplicate])")[0])||void 0===N||N.classList.add("active")}I||P(this).options.disabledSwipe||Object(w.a)(P(this).$slides,P(this).store,P(this).options,function(t){switch(t){case"left":P(n).store.setState(function(t){return{step:1}}),Object(m.a)(P(n).$ref,P(n).$slides,P(n).store,P(n).options,!1),P(n).store.setState(function(t){return{step:P(n).options.step||1}});break;case"right":Object(y.a)(P(n).$ref,P(n).$slides,P(n).store,P(n).options,!1);break;default:Object(S.a)(P(n).store,P(n).store.getState().currentSlide)}}),P(this).$ref.addEventListener("slide",function(t){var e=t.detail,i=e.internal,r=e.to;return i?null:n.toSlide(r)}),P(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:n.nextSlide(!0)}),P(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:n.previousSlide(!0)}),P(this).options.autoplay&&(P(this).isIntervalPaused=!1,setInterval(function(){return!P(n).isIntervalPaused&&n.nextSlide()},P(this).options.autoplay),P(this).$ref.addEventListener("mouseenter",function(){P(n).isIntervalPaused=!0}),P(this).$ref.addEventListener("mouseleave",function(){P(n).isIntervalPaused=!1})),P(this).$ref.classList.remove("cloaked")}return o(t,null,[{key:"init",value:function(){var e=document.querySelectorAll("[data-sm-slider]"),i=[];return Array.prototype.forEach.call(e,function(e){var n=e.getAttribute("data-sm-slider");if(n){var r;try{r=JSON.parse(n)}catch(t){throw v.b}i.push(new t(e,r))}}),i}}]),t}()},function(t,e,i){(function(e){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 n(t,e,i){function n(e){var i=p,n=b;return p=b=void 0,$=e,m=t.apply(n,i)}function s(t){return $=t,S=setTimeout(u,e),L?n(t):m}function a(t){var i=t-g,n=t-$,r=e-i;return E?O(r,y-n):r}function l(t){var i=t-g,n=t-$;return void 0===g||i>=e||0>i||E&&n>=y}function u(){var t=j();if(l(t))return d(t);S=setTimeout(u,a(t))}function d(t){return S=void 0,x&&p?n(t):(p=b=void 0,m)}function f(){void 0!==S&&clearTimeout(S),$=0,p=g=b=S=void 0}function v(){return void 0===S?m:d(j())}function h(){var t=j(),i=l(t);if(p=arguments,b=this,g=t,i){if(void 0===S)return s(g);if(E)return S=setTimeout(u,e),n(g)}return void 0===S&&(S=setTimeout(u,e)),m}var p,b,y,m,S,g,$=0,L=!1,E=!1,x=!0;if("function"!=typeof t)throw new TypeError(c);return e=o(e)||0,r(i)&&(L=!!i.leading,E="maxWait"in i,y=E?w(o(i.maxWait)||0,e):y,x="trailing"in i?!!i.trailing:x),h.cancel=f,h.flush=v,h}function r(t){var e=i(t);return!!t&&("object"==e||"function"==e)}function s(t){return!!t&&"object"==i(t)}function a(t){return"symbol"==i(t)||s(t)&&g.call(t)==u}function o(t){if("number"==typeof t)return t;if(a(t))return l;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(d,"");var i=v.test(t);return i||h.test(t)?p(t.slice(2),i?2:8):f.test(t)?l:+t}var c="Expected a function",l=NaN,u="[object Symbol]",d=/^\s+|\s+$/g,f=/^[-+]0x[0-9a-f]+$/i,v=/^0b[01]+$/i,h=/^0o[0-7]+$/i,p=parseInt,b="object"==(void 0===e?"undefined":i(e))&&e&&e.Object===Object&&e,y="object"==("undefined"==typeof self?"undefined":i(self))&&self&&self.Object===Object&&self,m=b||y||Function("return this")(),S=Object.prototype,g=S.toString,w=Math.max,O=Math.min,j=function(){return m.Date.now()};t.exports=n}).call(e,i(9))},function(t,e){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)}var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":i(window))&&(n=window)}t.exports=n},function(t,e,i){"use strict";e.a=function(){var t=new WeakMap;return function(e){var i=t.get(e);return i||(i={},t.set(e,i)),i}}},function(t,e,i){"use strict";i.d(e,"b",function(){return r}),i.d(e,"c",function(){return s}),i.d(e,"a",function(){return a});var n=function(t){return new(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Error)("".concat("[smSlider]"," ").concat(t))},r=n("Slider could not be initialized with the provided options. Please check that you provided valid JSON."),s=n("Slider needs to contain children to be initialized."),a=n("The property `offsetLeft` has an invalid value. Please only provide values >= 0 and <= 1.")},function(t,e,i){"use strict";e.a=function(t,e,i){t.addEventListener(e,function n(r){t.removeEventListener(e,n),i(r)})}},function(t,e,i){"use strict";var n=(i(0),i(3)),r=i(4);e.a=function(t,e,i,s,a){var o=e.getState(),c=o.totalSlides,l=o.isVertical,u=o.currentSlide,d=o.isInfinite,f=Object(r.a)(i,window.innerWidth),v=f.visibleSlides,h=f.step,p=Object(n.a)(t,s,a,l),b=0===u&&!d,y=v>=c||u+v===c;e.setState(function(t){return{innerSize:p,visibleSlides:v,step:h,isNextDisabled:y,isPrevDisabled:b}})}},function(t,e,i){"use strict";var n=(i(0),i(2));e.a=function(t,e,i){var r=i.getState(),s=r.innerSize,a=r.visibleSlides,o=r.isVertical,c=o?"height":"width";Object(n.a)(t,e,i,!0),Array.prototype.forEach.call(e.children,function(t){t.style[c]="".concat(Math.round(s/a),"px")})}},function(t,e,i){"use strict";var n=(i(0),i(1));e.a=function(t,e,i,r,s){var a=i.getState(),o=a.currentSlide,c=a.step,l=0,u=0!==o?o%c||c:c;s||t.dispatchEvent(new CustomEvent("previous",{detail:{internal:!0}})),l=r.infinite||o-u>0?o-u:0,requestAnimationFrame(function(){return Object(n.a)(i,l)})}},function(t,e,i){"use strict";var n=(i(0),i(1));e.a=function(t,e,i,r,s){var a=i.getState(),o=a.currentSlide,c=a.totalSlides,l=a.step,u=a.visibleSlides,d=a.isInfinite,f=0,v=o+l>c?c-o:l;s||t.dispatchEvent(new CustomEvent("next",{detail:{internal:!0}})),f=o+v,d||c-u>f||(f=c-u),requestAnimationFrame(function(){return Object(n.a)(i,f)})}},function(t,e,i){"use strict";var n=(i(0),i(1));e.a=function(t,e,i,r){var s,a,o,c,l,u,d=50,f=0;e.getState().isVertical||(t.addEventListener("touchstart",function(n){var r=n.changedTouches[0];s="none",d=e.getState().innerSize/i.visibleSlides/5,a=r.pageX,o=r.pageY;var c=t.style.transform.match(/-?\d+/i);c&&c[0]&&(t.classList.remove("animatable"),u=parseInt(c[0],10))},{passive:!0}),t.addEventListener("touchmove",function(e){var i=e.changedTouches[0];c=i.pageX-a,l=i.pageY-o,null!==u&&void 0!==u&&(t.style.transform="translateX(".concat(u+c,"px)"))},{passive:!0}),t.addEventListener("touchend",function(a){if(c||l){Math.abs(c)<d||Math.abs(l)>100?Math.abs(l)<d||Math.abs(c)>100?(t.classList.add("animatable"),t.style.transform="translateX(".concat(u,"px)")):s=0>l?"up":"down":s=0>c?"left":"right";var o,v=window.getComputedStyle(t.children[0]).width.split("px")[0];o=0>c?-parseInt(v):parseInt(v),f=Math.abs(Math.round((u+o)/v)),i.infinite&&(f=Math.abs(Math.round((u+o)/v))-1),o>0&&u>=0&&o+u>0&&(f=0),window.setTimeout(function(){i.step>1&&i.infinite?f=f-i.step+1:i.infinite||f<e.getState().totalSlides-e.getState().visibleSlides||(f=e.getState().totalSlides-e.getState().visibleSlides,requestAnimationFrame(function(){return Object(n.a)(e,f+2)})),0===e.getState().currentSlide&&e.getState().currentSlide===f&&Object(n.a)(e,f+1),requestAnimationFrame(function(){return Object(n.a)(e,f)})},20),c=0,l=0,r(s)}},{passive:!0}))}},function(t,e,i){"use strict";e.a=function(t){for(var e=t.children.length-1;e>=0;e--)t.children[e].hasAttribute("data-sm-slider-duplicate")?t.removeChild(t.children[e]):t.children[e].setAttribute("data-sm-slider-index",""+e)}},function(t,e,i){"use strict";i(0);e.a=function(t,e,i){var n=i.getState(),r=n.step,s=n.visibleSlides,a=n.totalSlides;if(e.infinite&&a>=s){for(var o=[],c=[],l=t.children.length-1,u=0;r>u;u++)o.push(t.children[l-u].cloneNode(!0));for(var d=0;s>d;d++)c.push(t.children[d].cloneNode(!0));Array.prototype.forEach.call(o,function(e,i){e.setAttribute("data-sm-slider-index",l-i),e.setAttribute("data-sm-slider-duplicate",!0),t.insertBefore(e,t.firstElementChild)}),Array.prototype.forEach.call(c,function(e,i){e.setAttribute("data-sm-slider-index",i),e.setAttribute("data-sm-slider-duplicate",!0),t.appendChild(e)})}}},function(t,e,i){"use strict";i.d(e,"b",function(){return s});var n=(i(0),i(21)),r=i(1);e.a=function(t,e){var i=e.getState(),s=i.totalSlides,a=i.step;if(!Object(n.a)(t))return null;for(var o=Math.ceil(s/a),c=[],l=0;o>l;l++)!function(i){var n=document.createElement("div");n.classList.add("dot"),n.addEventListener("click",function(){return Object(r.a)(e,i)}),c.push(n),t.appendChild(n)}(l);return c[0].classList.add("active"),c};var s=function(t,e,i){var n=i.getState(),r=n.step,s=Math.floor(e/r);t.forEach(function(t,e){e===s?t.classList.add("active"):t.classList.remove("active")})}},function(t,e,i){"use strict";e.a=function(t){if(!t)return!1;for(;t.firstChild;)t.removeChild(t.firstChild);return!0}},function(t,e,i){"use strict";i.d(e,"b",function(){return r});var n=(i(0),i(1));e.a=function(t,e,i){var r=[];return t?(Array.prototype.forEach.call(t,function(t,s){t.getAttribute("data-sm-slider-ref")||t.setAttribute("data-sm-slider-ref",s);var a=t.getAttribute("data-sm-slider-ref"),o=i.querySelector('[data-sm-slider-hash="'.concat(a,'"]'));o&&(t.addEventListener("click",function(){return Object(n.a)(e,parseInt(o.getAttribute("data-sm-slider-index"),10))}),r=r.concat(t))}),r[0]&&r[0].classList.add("active"),r):r};var r=function(t,e,i){var n=i.querySelector('[data-sm-slider-index="'.concat(e,'"]'));n&&t.forEach(function(t){t.getAttribute("data-sm-slider-ref")===n.getAttribute("data-sm-slider-hash")?t.classList.add("active"):t.classList.remove("active")})}},function(t,e,i){"use strict";e.a=function(t,e){if(e.showEmptySlides)return t;var i=t.querySelectorAll(".slide");return Array.prototype.forEach.call(i,function(e){""===e.innerHTML&&t.removeChild(e)}),t}},function(t,e){try{var i=new window.CustomEvent("test");if(i.preventDefault(),!0!==i.defaultPrevented)throw Error("Could not prevent default")}catch(t){var n=function(t,e){var i,n;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},i=document.createEvent("CustomEvent"),i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n=i.preventDefault,i.preventDefault=function(){n.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},i};n.prototype=window.Event.prototype,window.CustomEvent=n}},function(t,e){}])}); |
{ | ||
"name": "sm-slider", | ||
"version": "2.1.4", | ||
"version": "2.2.0", | ||
"description": "A minimalistic, configurable, responsive slider library.", | ||
@@ -11,2 +11,3 @@ "main": "lib/sm-slider.js", | ||
"build": "cross-env NODE_ENV=production webpack --config webpack/prod.js", | ||
"watch": "cross-env NODE_ENV=development webpack-dev-server --config webpack/dev.js -w", | ||
"prepublish": "npm run build" | ||
@@ -41,9 +42,11 @@ }, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-loader": "^7.1.2", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-preset-env": "^1.6.0", | ||
"babel-preset-flow": "^6.23.0", | ||
"babel-preset-stage-0": "^6.24.1", | ||
"@babel/core": "^7.8.3", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-function-bind": "^7.8.3", | ||
"@babel/plugin-proposal-optional-chaining": "^7.8.3", | ||
"@babel/plugin-transform-runtime": "^7.8.3", | ||
"@babel/preset-env": "^7.8.3", | ||
"@babel/preset-flow": "^7.8.3", | ||
"babel-loader": "^8.0.6", | ||
"babel-plugin-add-module-exports": "^1.0.2", | ||
"cross-env": "^5.0.5", | ||
@@ -50,0 +53,0 @@ "css-hot-loader": "^1.3.1", |
# smSlider | ||
smSlider is a library for creating responsive and slick sliders | ||
that serve whatever content you want them to. The general philosophy is | ||
to provide a flexible library in which to user can handle the styling | ||
to provide a flexible library in which the user can handle the styling | ||
mostly by itself. This makes it easy, to customize the slider without | ||
@@ -156,3 +156,3 @@ having to override a lot of library styles. | ||
and a `data-sm-slider-ref` Attribute. | ||
To make a reference to the slide you should insert a `data-sm-slider-hash` Attribute | ||
To create a reference to the slide you should insert a `data-sm-slider-hash` Attribute | ||
with the same value as the `data-sm-slider-ref` Attribute to the slides you want to reference on. | ||
@@ -222,5 +222,6 @@ ```html | ||
| disabledSwipe | True, if touch swiping should be disabled | boolean | false | ||
| activeClass | Adds an `active` class to the first displayed element in the viewport | boolean | false | ||
### Responsiveness | ||
smSlider is built to fit different device sizes using the `breakpoints` option. | ||
`smSlilder` is built to fit different device sizes using the `breakpoints` option. | ||
The `breakspoints` option consists of a key/value pair that can override | ||
@@ -246,3 +247,3 @@ all default options that have a `yes` in the field for responsiveness in the | ||
### Vertical slides | ||
smSlider also supports vertical alignment of slides, instead of the usual horizonal one. | ||
`smSlilder` also supports vertical alignment of slides, instead of the usual horizonal one. | ||
In order to transform the slider into a vertical one, the element with the `sm-slider` class | ||
@@ -254,6 +255,6 @@ needs to be assigned the `sm-slider--vertical` class as well. | ||
* The content of the `slide` class has a fixed height | ||
* The dynamic height calculation is going to be adressed in the upcoming releases! | ||
* The dynamic height calculation is going to be addressed in the upcoming releases! | ||
### Events | ||
smSlider uses custom events to both notify the listener of specific actions, | ||
`smSlilder` uses custom events to both notify the listener of specific actions, | ||
as well as listening to specific events itself. The following list shows | ||
@@ -260,0 +261,0 @@ the events that are implemented at the moment. |
@@ -6,3 +6,3 @@ // @flow | ||
export default (store: Store<SliderState>, slide: number, animate: boolean = true) => { | ||
const { visibleSlides, totalSlides, isInfinite } = store.getState(); | ||
const { visibleSlides, totalSlides, isInfinite, isClassActive, slidesWrapper } = store.getState(); | ||
@@ -18,2 +18,58 @@ const isPrevDisabled = !isInfinite && slide === 0 || totalSlides <= visibleSlides; | ||
})); | ||
const addActiveClass = $el => { | ||
const id = window.setTimeout(() => { | ||
$el?.classList.add('active'); | ||
clearTimeout(id); | ||
}, 300); // the timeout here is the same transition timing | ||
}; | ||
if (!isClassActive) { | ||
return; | ||
} | ||
let currentSlide = store.getState().currentSlide; | ||
const mainElementsLength = slidesWrapper?.querySelectorAll('.slide:not([data-sm-slider-duplicate])').length, | ||
slides = slidesWrapper?.querySelectorAll('.slide'), | ||
steps = store.getState().step; | ||
if (isInfinite) { | ||
currentSlide += steps > 1 ? steps : 1; | ||
} | ||
Array.prototype.forEach.call(slides, $slide => { | ||
$slide?.classList.remove('active'); | ||
// If not isInfinite then give it a class without delay | ||
!isInfinite ? slides[currentSlide].classList.add('active') : addActiveClass(slides[currentSlide]); | ||
if (currentSlide >= mainElementsLength) { | ||
$slide?.classList.remove('active'); | ||
let firstMainEle = slidesWrapper.querySelector('.slide[data-sm-slider-index="0"]:not([data-sm-slider-duplicate])'), | ||
$el = firstMainEle ? firstMainEle : slidesWrapper.querySelector('.slide[data-sm-slider-index="1"]:not([data-sm-slider-duplicate])'); | ||
!isInfinite ? $el.classList.add('active') : addActiveClass($el); | ||
return; | ||
} | ||
if (currentSlide > 0) { | ||
return; | ||
} | ||
if (steps === 1) { | ||
const lastMainEle = slidesWrapper.querySelector('.slide[data-sm-slider-index="' + (mainElementsLength) + '"]:not([data-sm-slider-duplicate])'), | ||
$el = lastMainEle ? lastMainEle : slidesWrapper.querySelector('.slide[data-sm-slider-index="' + (mainElementsLength - 1) + '"]:not([data-sm-slider-duplicate])'); | ||
!isInfinite ? $el.classList.add('active') : addActiveClass($el); | ||
return; | ||
} | ||
if (steps > 1) { | ||
const lastMainEle = slidesWrapper.querySelector('.slide[data-sm-slider-index="' + (mainElementsLength - steps) + '"]:not([data-sm-slider-duplicate])'), | ||
$el = lastMainEle ? lastMainEle : slidesWrapper.querySelector('.slide[data-sm-slider-index="' + (mainElementsLength - steps + 1) + '"]:not([data-sm-slider-duplicate])'); | ||
!isInfinite ? $el.classList.add('active') : addActiveClass($el); | ||
} | ||
}); | ||
}; |
@@ -36,2 +36,3 @@ // @flow | ||
disabledSwipe: false, | ||
activeClass: false, | ||
}; | ||
@@ -49,3 +50,4 @@ | ||
isVertical: false, | ||
isInfinite: false | ||
isInfinite: false, | ||
isClassActive: false, | ||
}; | ||
@@ -110,3 +112,5 @@ | ||
isNextDisabled, | ||
isInfinite: options.infinite | ||
isInfinite: options.infinite, | ||
isClassActive: _(this).options.activeClass, | ||
slidesWrapper: _(this).$slides, | ||
}; | ||
@@ -143,2 +147,8 @@ | ||
// If isClassActive true, add active class to the first displayed element in the viewport | ||
if (initialState.isClassActive) { | ||
const mainElements = _(this).$slides.querySelectorAll('.slide:not([data-sm-slider-duplicate])'); | ||
mainElements[0]?.classList.add('active'); | ||
} | ||
// Swipe to a different slide, based on the direction the user swipes in | ||
@@ -145,0 +155,0 @@ if (!isNextDisabled && !_(this).options.disabledSwipe) { |
@@ -10,3 +10,4 @@ // @flow | ||
showEmptySlides?: boolean, | ||
disabledSwipe?:boolean | ||
disabledSwipe?:boolean, | ||
activeClass?:boolean | ||
}; | ||
@@ -13,0 +14,0 @@ |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
193041
1285
331
0
25