New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sm-slider

Package Overview
Dependencies
Maintainers
5
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sm-slider - npm Package Compare versions

Comparing version 0.6.5 to 1.0.0

src/core/clean.js

2

lib/sm-slider.js

@@ -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(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=5)}([function(t,e,n){"use strict";function i(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},o=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},s=function(){function t(t,e){for(var n=0;e.length>n;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();e.default=function(){function t(e,n){i(this,t),this.handler=function(){},this.state=e,this.handler=n}return s(t,[{key:"getState",value:function(){return this.state}},{key:"setState",value:function(t){var e=o({},this.state);switch(void 0===t?"undefined":r(t)){case"function":this.state=o({},this.state,t(this.state));break;case"object":this.state=o({},this.state,t);break;default:throw Error()}this.handler(e)}}]),t}(),t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0);e.default=function(t,e){var n=2>=arguments.length||void 0===arguments[2]||arguments[2];t.setState(function(t){return{currentSlide:e,animate:n}})},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0);e.default=function(t,e,n){var i=n.getState(),r=i.currentSlide,o=i.innerWidth,s=i.totalSlides,a=i.animate,u=i.visibleSlides,l=i.step,d=r;r===s?d=0:0>r&&(d=s-l),a&&(e.classList.add("animatable"),e.addEventListener("transitionend",function(){e.classList.remove("animatable"),(r===s||0>r)&&n.setState(function(t){return{currentSlide:d,animate:!1}})},{once:!0}),t.dispatchEvent(new CustomEvent("slide",{detail:{to:d,internal:!0}})));var f=o/u;e.style.transform="translateX("+(-f*r-f*l)+"px)"},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n){return t.getBoundingClientRect().width-(e&&!e.classList.contains("inset")?e.getBoundingClientRect().width:0)-(n&&!n.classList.contains("inset")?n.getBoundingClientRect().width:0)},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){var n=t.visibleSlides,i=t.step,r=t.breakpoints;return r&&Object.keys(r).length?Object.keys(r).reduce(function(t,o){return e<parseInt(o,10)?t:{visibleSlides:r[o].visibleSlides||n,step:r[o].step||i}},{visibleSlides:n,step:i}):{visibleSlides:n,step:i}},t.exports=e.default},function(t,e,n){t.exports=n(6)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(7),r=function(t){return t&&t.__esModule?t:{default:t}}(i);n(19),n(20),e.default=r.default,t.exports=e.default},function(t,e,n){"use strict";function i(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 o=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},s=function(){function t(t,e){for(var n=0;e.length>n;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=n(8),u=i(a),l=n(0),d=i(l),f=n(10),c=i(f),v=n(11),h=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(v),p=n(2),b=i(p),y=n(12),m=i(y),S=n(13),g=i(S),w=n(14),$=i(w),_=n(15),O=i(_),E=n(1),j=i(E),x=n(3),L=i(x),P=n(16),M=i(P),C=n(17),k=i(C),N=n(18),D=i(N),I=n(4),A=i(I),W=new c.default,T={infinite:!1,visibleSlides:1,step:1,autoplay:0},R={currentSlide:0,innerWidth:0,totalSlides:0,isNextDisabled:!1,isPrevDisabled:!1,isSlidingDisabled:!1},q=function(){var t=this;this.nextSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,O.default)(W(t).$ref,W(t).$slides,W(t).store,W(t).options,e)},this.previousSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,$.default)(W(t).$ref,W(t).$slides,W(t).store,W(t).options,e)},this.toSlide=function(e){(0,j.default)(W(t).store,e)},this.addEventListener=function(e,n,i){W(t).$ref.addEventListener(e,n,i)},this.removeEventListener=function(e,n){W(t).$ref.removeEventListener(e,n)},this.handleChange=function(e){var n=W(t),i=n.$slides,r=n.store,o=n.options,s=r.getState(),a=s.currentSlide;s.innerWidth!==e.innerWidth&&(0,g.default)(W(t).$ref,i,r),(a!==e.currentSlide||o.infinite)&&((0,b.default)(W(t).$ref,i,r),W(t).$navigationDots&&(0,N.updateNavigation)(W(t).$navigationDots,a,W(t).store))}};e.default=function(){function t(e,n){var i=this;if(r(this,t),q.call(this),W(this).$ref=e,W(this).options=o({},T,n),W(this).$slides=W(this).$ref.querySelector(".slides"),W(this).$arrowLeft=W(this).$ref.querySelector(".arrow-left"),W(this).$arrowRight=W(this).$ref.querySelector(".arrow-right"),W(this).$navigation=W(this).$ref.querySelector(".dot-nav"),!W(this).$slides||!W(this).$slides.children.length)throw h.NO_CHILDREN;var s=(0,L.default)(W(this).$ref,W(this).$arrowLeft,W(this).$arrowRight),a=(0,A.default)(W(this).options,window.innerWidth),l=a.visibleSlides,f=a.step,c=W(this).$slides.children.length,v=l>=c,p=o({},R,{totalSlides:c,innerWidth:s,visibleSlides:l,step:f,isSlidingDisabled:v});W(this).store=new d.default(p,this.handleChange),(0,k.default)(W(this).$slides,W(this).options,W(this).store),(0,g.default)(W(this).$ref,W(this).$slides,W(this).store),W(this).$navigation&&!v&&(W(this).$navigationDots=(0,D.default)(W(this).$navigation,W(this).store)),W(this).$arrowLeft&&(v?W(this).$arrowLeft.style.visibility="hidden":W(this).$arrowLeft.addEventListener("click",$.default.bind(this,W(this).$ref,W(this).$slides,W(this).store,W(this).options,!1))),W(this).$arrowRight&&(v?W(this).$arrowRight.style.visibility="hidden":W(this).$arrowRight.addEventListener("click",O.default.bind(this,W(this).$ref,W(this).$slides,W(this).store,W(this).options,!1))),window.addEventListener("resize",(0,u.default)(m.default.bind(this,W(this).$ref,W(this).store,W(this).options,W(this).$arrowLeft,W(this).$arrowRight),200)),v||(0,M.default)(W(this).$slides,W(this).store,W(this).options,function(t){switch(t){case"left":(0,O.default)(W(i).$ref,W(i).$slides,W(i).store,W(i).options,!1);break;case"right":(0,$.default)(W(i).$ref,W(i).$slides,W(i).store,W(i).options,!1);break;default:(0,j.default)(W(i).store,W(i).store.getState().currentSlide)}}),W(this).$ref.addEventListener("slide",function(t){var e=t.detail,n=e.internal,r=e.to;return n?null:i.toSlide(r)}),W(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:i.nextSlide(!0)}),W(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:i.previousSlide(!0)}),W(this).options.autoplay&&(W(this).isIntervalPaused=!1,setInterval(function(){return!W(i).isIntervalPaused&&i.nextSlide()},W(this).options.autoplay),W(this).$ref.addEventListener("mouseenter",function(){W(i).isIntervalPaused=!0}),W(this).$ref.addEventListener("mouseleave",function(){W(i).isIntervalPaused=!1})),W(this).$ref.classList.remove("cloaked")}return s(t,null,[{key:"init",value:function(){var e=document.querySelectorAll("[data-sm-slider]"),n=[];return Array.prototype.forEach.call(e,function(e){var i=e.getAttribute("data-sm-slider");if(i)try{var r=JSON.parse(i);n.push(new t(e,r))}catch(t){throw h.INVALID_OPTIONS}}),n}}]),t}(),t.exports=e.default},function(t,e,n){"use strict";(function(e){function n(t,e,n){function r(e){var n=p,i=b;return p=b=void 0,O=e,m=t.apply(i,n)}function o(t){return O=t,S=setTimeout(d,e),E?r(t):m}function a(t){var n=t-g,i=t-O,r=e-n;return j?$(r,y-i):r}function l(t){var n=t-g,i=t-O;return void 0===g||n>=e||0>n||j&&i>=y}function d(){var t=_();if(l(t))return f(t);S=setTimeout(d,a(t))}function f(t){return S=void 0,x&&p?r(t):(p=b=void 0,m)}function c(){void 0!==S&&clearTimeout(S),O=0,p=g=b=S=void 0}function v(){return void 0===S?m:f(_())}function h(){var t=_(),n=l(t);if(p=arguments,b=this,g=t,n){if(void 0===S)return o(g);if(j)return S=setTimeout(d,e),r(g)}return void 0===S&&(S=setTimeout(d,e)),m}var p,b,y,m,S,g,O=0,E=!1,j=!1,x=!0;if("function"!=typeof t)throw new TypeError(u);return e=s(e)||0,i(n)&&(E=!!n.leading,j="maxWait"in n,y=j?w(s(n.maxWait)||0,e):y,x="trailing"in n?!!n.trailing:x),h.cancel=c,h.flush=v,h}function i(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 o(t){return"symbol"==(void 0===t?"undefined":a(t))||r(t)&&g.call(t)==d}function s(t){if("number"==typeof t)return t;if(o(t))return l;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=t.replace(f,"");var n=v.test(t);return n||h.test(t)?p(t.slice(2),n?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,m=b||y||Function("return this")(),S=Object.prototype,g=S.toString,w=Math.max,$=Math.min,_=function(){return m.Date.now()};t.exports=n}).call(e,n(9))},function(t,e,n){"use strict";var i,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};i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"===("undefined"==typeof window?"undefined":r(window))&&(i=window)}t.exports=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){var t=new WeakMap;return function(e){var n=t.get(e);return n||(n={},t.set(e,n)),n}},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){return new(arguments.length>1&&void 0!==arguments[1]?arguments[1]:Error)("[smSlider] "+t)};e.INVALID_OPTIONS=i("Slider could not be initialized with the provided options. Please check that you provided valid JSON."),e.NO_CHILDREN=i("Slider needs to contain children to be initialized.")},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},o=n(0),s=(i(o),n(3)),a=i(s),u=n(4),l=i(u);e.default=function(t,e,n,i,o){var s=(0,a.default)(t,i,o);e.setState(function(t){return r({innerWidth:s},(0,l.default)(n,window.innerWidth))})},t.exports=e.default},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),o=(i(r),n(2)),s=i(o);e.default=function(t,e,n){var i=n.getState(),r=i.innerWidth,o=i.visibleSlides;i.isSlidingDisabled||(0,s.default)(t,e,n),Array.prototype.forEach.call(e.children,function(t){t.style.width=r/o+"px"})},t.exports=e.default},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),o=(i(r),n(1)),s=i(o);e.default=function(t,e,n,i,r){var o=n.getState(),a=o.currentSlide,u=o.step,l=0!==a?a%u||u:u;r||t.dispatchEvent(new CustomEvent("previous",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(n,a-l)})},t.exports=e.default},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),o=(i(r),n(1)),s=i(o);e.default=function(t,e,n,i,r){var o=n.getState(),a=o.currentSlide,u=o.totalSlides,l=o.step,d=a+l>u?u-a:l;r||t.dispatchEvent(new CustomEvent("next",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(n,a+d)})},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0);e.default=function(t,e,n,i){var r=void 0,o=void 0,s=void 0,a=void 0,u=void 0,l=void 0,d=50;t.addEventListener("touchstart",function(i){var a=i.changedTouches[0];r="none",d=e.getState().innerWidth/n.visibleSlides/5,o=a.pageX,s=a.pageY;var u=t.style.transform.match(/-?\d+/i);u&&u[0]&&(t.classList.remove("animatable"),l=parseInt(u[0],10))},{passive:!0}),t.addEventListener("touchmove",function(e){var n=e.changedTouches[0];a=n.pageX-o,u=n.pageY-s,null!==l&&void 0!==l&&(t.style.transform="translateX("+(l+a)+"px)")},{passive:!0}),t.addEventListener("touchend",function(e){Math.abs(a)<d||Math.abs(u)>100?Math.abs(u)<d||Math.abs(a)>100?(t.classList.add("animatable"),t.style.transform="translateX("+l+"px)"):r=0>u?"up":"down":r=0>a?"left":"right",i(r)},{passive:!0})},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0);e.default=function(t,e,n){var i=n.getState(),r=i.step,o=i.visibleSlides,s=i.isSlidingDisabled;if(Array.prototype.forEach.call(t.children,function(t,e){t.setAttribute("data-sm-slider-index",e)}),e.infinite&&!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;o>f;f++)u.push(t.children[f].cloneNode(!0));Array.prototype.forEach.call(a,function(e,n){e.setAttribute("data-sm-slider-index",l-n),t.insertBefore(e,t.firstElementChild)}),Array.prototype.forEach.call(u,function(e,n){e.setAttribute("data-sm-slider-index",n),t.appendChild(e)})}},t.exports=e.default},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.updateNavigation=void 0;var r=n(0),o=(i(r),n(1)),s=i(o);e.default=function(t,e){for(var n=e.getState(),i=n.totalSlides,r=n.step,o=Math.ceil(i/r),a=[],u=0;o>u;u++)!function(n){var i=document.createElement("div");i.classList.add("dot"),i.addEventListener("click",function(){return(0,s.default)(e,n)}),a.push(i),t.appendChild(i)}(u);return a[0].classList.add("active"),a};e.updateNavigation=function(t,e,n){var i=n.getState(),r=i.step,o=Math.floor(e/r);t.forEach(function(t,e){e===o?t.classList.add("active"):t.classList.remove("active")})}},function(t,e,n){"use strict";try{var i=new window.CustomEvent("test");if(i.preventDefault(),!0!==i.defaultPrevented)throw Error("Could not prevent default")}catch(t){var r=function(t,e){var n,i;return e=e||{bubbles:!1,cancelable:!1,detail:void 0},n=document.createEvent("CustomEvent"),n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i=n.preventDefault,n.preventDefault=function(){i.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(t){this.defaultPrevented=!0}},n};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,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},o=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},s=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 s(t,[{key:"getState",value:function(){return this.state}},{key:"setState",value:function(t){var e=o({},this.state);switch(void 0===t?"undefined":r(t)){case"function":this.state=o({},this.state,t(this.state));break;case"object":this.state=o({},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];t.setState(function(t){return{currentSlide:e,animate:i}})},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=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=i.getState(),o=r.currentSlide,s=r.innerWidth,a=r.totalSlides,u=r.animate,l=r.visibleSlides,d=r.step,f=o;o===a?f=0:0>o&&(f=a-d),u&&!n&&(e.classList.add("animatable"),e.addEventListener("transitionend",function(){e.classList.remove("animatable"),(o===a||0>o)&&i.setState(function(t){return{currentSlide:f,animate:!1}})},{once:!0}),t.dispatchEvent(new CustomEvent("slide",{detail:{to:f,internal:!0}})));var c=s/l;e.style.transform="translateX("+(-c*o-c*d)+"px)"},t.exports=e.default},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=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)},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.breakpoints;return r&&Object.keys(r).length?Object.keys(r).reduce(function(t,o){return e<parseInt(o,10)?t:{visibleSlides:r[o].visibleSlides||i,step:r[o].step||n}},{visibleSlides:i,step:n}):{visibleSlides:i,step:n}},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(21),i(22),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 o=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},s=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(12),m=n(y),S=i(13),g=n(S),w=i(14),$=n(w),_=i(15),O=n(_),j=i(1),x=n(j),E=i(3),L=n(E),P=i(16),M=n(P),C=i(17),k=n(C),N=i(18),D=n(N),A=i(19),I=n(A),W=i(4),T=n(W),R=new c.default,q={infinite:!1,visibleSlides:1,step:1,autoplay:0},X={currentSlide:0,innerWidth:0,totalSlides:0,step:1,visibleSlides:1,isNextDisabled:!1,isPrevDisabled:!1,isSlidingDisabled:!1},B=function(){var t=this;this.nextSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,O.default)(R(t).$ref,R(t).$slides,R(t).store,R(t).options,e)},this.previousSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,$.default)(R(t).$ref,R(t).$slides,R(t).store,R(t).options,e)},this.toSlide=function(e){(0,x.default)(R(t).store,e)},this.addEventListener=function(e,i,n){R(t).$ref.addEventListener(e,i,n)},this.removeEventListener=function(e,i){R(t).$ref.removeEventListener(e,i)},this.handleChange=function(e){var i=R(t),n=i.$slides,r=i.store,o=i.options,s=r.getState(),a=s.currentSlide,u=s.innerWidth,l=s.visibleSlides,d=s.step;u!==e.innerWidth&&(0,g.default)(R(t).$ref,n,r),l===e.visibleSlides&&d===e.step||((0,k.default)(n),(0,D.default)(n,o,r)),(a!==e.currentSlide||o.infinite)&&((0,b.default)(R(t).$ref,n,r),R(t).$navigationDots&&(0,A.updateNavigation)(R(t).$navigationDots,a,R(t).store))}};e.default=function(){function t(e,i){var n=this;if(r(this,t),B.call(this),R(this).$ref=e,R(this).options=o({},q,i),R(this).$slides=R(this).$ref.querySelector(".slides"),R(this).$arrowLeft=R(this).$ref.querySelector(".arrow-left"),R(this).$arrowRight=R(this).$ref.querySelector(".arrow-right"),R(this).$navigation=R(this).$ref.querySelector(".dot-nav"),!R(this).$slides||!R(this).$slides.children.length)throw h.NO_CHILDREN;(0,k.default)(R(this).$slides);var s=(0,L.default)(R(this).$ref,R(this).$arrowLeft,R(this).$arrowRight),a=(0,T.default)(R(this).options,window.innerWidth),l=a.visibleSlides,f=a.step,c=R(this).$slides.children.length,v=l>=c,p=o({},X,{totalSlides:c,innerWidth:s,visibleSlides:l,step:f,isSlidingDisabled:v});R(this).store=new d.default(p,this.handleChange),(0,D.default)(R(this).$slides,R(this).options,R(this).store),(0,g.default)(R(this).$ref,R(this).$slides,R(this).store),R(this).$navigation&&!v&&(R(this).$navigationDots=(0,I.default)(R(this).$navigation,R(this).store)),R(this).$arrowLeft&&(v?R(this).$arrowLeft.style.visibility="hidden":R(this).$arrowLeft.addEventListener("click",$.default.bind(this,R(this).$ref,R(this).$slides,R(this).store,R(this).options,!1))),R(this).$arrowRight&&(v?R(this).$arrowRight.style.visibility="hidden":R(this).$arrowRight.addEventListener("click",O.default.bind(this,R(this).$ref,R(this).$slides,R(this).store,R(this).options,!1))),window.addEventListener("resize",(0,u.default)(m.default.bind(this,R(this).$ref,R(this).store,R(this).options,R(this).$arrowLeft,R(this).$arrowRight),200)),v||(0,M.default)(R(this).$slides,R(this).store,R(this).options,function(t){switch(t){case"left":(0,O.default)(R(n).$ref,R(n).$slides,R(n).store,R(n).options,!1);break;case"right":(0,$.default)(R(n).$ref,R(n).$slides,R(n).store,R(n).options,!1);break;default:(0,x.default)(R(n).store,R(n).store.getState().currentSlide)}}),R(this).$ref.addEventListener("slide",function(t){var e=t.detail,i=e.internal,r=e.to;return i?null:n.toSlide(r)}),R(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:n.nextSlide(!0)}),R(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:n.previousSlide(!0)}),R(this).options.autoplay&&(R(this).isIntervalPaused=!1,setInterval(function(){return!R(n).isIntervalPaused&&n.nextSlide()},R(this).options.autoplay),R(this).$ref.addEventListener("mouseenter",function(){R(n).isIntervalPaused=!0}),R(this).$ref.addEventListener("mouseleave",function(){R(n).isIntervalPaused=!1})),R(this).$ref.classList.remove("cloaked")}return s(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,O=e,m=t.apply(n,i)}function o(t){return O=t,S=setTimeout(d,e),j?r(t):m}function a(t){var i=t-g,n=t-O,r=e-i;return x?$(r,y-n):r}function l(t){var i=t-g,n=t-O;return void 0===g||i>=e||0>i||x&&n>=y}function d(){var t=_();if(l(t))return f(t);S=setTimeout(d,a(t))}function f(t){return S=void 0,E&&p?r(t):(p=b=void 0,m)}function c(){void 0!==S&&clearTimeout(S),O=0,p=g=b=S=void 0}function v(){return void 0===S?m:f(_())}function h(){var t=_(),i=l(t);if(p=arguments,b=this,g=t,i){if(void 0===S)return o(g);if(x)return S=setTimeout(d,e),r(g)}return void 0===S&&(S=setTimeout(d,e)),m}var p,b,y,m,S,g,O=0,j=!1,x=!1,E=!0;if("function"!=typeof t)throw new TypeError(u);return e=s(e)||0,n(i)&&(j=!!i.leading,x="maxWait"in i,y=x?w(s(i.maxWait)||0,e):y,E="trailing"in i?!!i.trailing:E),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 o(t){return"symbol"==(void 0===t?"undefined":a(t))||r(t)&&g.call(t)==d}function s(t){if("number"==typeof t)return t;if(o(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,m=b||y||Function("return this")(),S=Object.prototype,g=S.toString,w=Math.max,$=Math.min,_=function(){return m.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.")},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=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=i(0),s=(n(o),i(3)),a=n(s),u=i(4),l=n(u);e.default=function(t,e,i,n,o){var s=(0,a.default)(t,n,o);e.setState(function(t){return r({innerWidth:s},(0,l.default)(i,window.innerWidth))})},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),o=(n(r),i(2)),s=n(o);e.default=function(t,e,i){var n=i.getState(),r=n.innerWidth,o=n.visibleSlides;n.isSlidingDisabled||(0,s.default)(t,e,i,!0),Array.prototype.forEach.call(e.children,function(t){t.style.width=r/o+"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),o=(n(r),i(1)),s=n(o);e.default=function(t,e,i,n,r){var o=i.getState(),a=o.currentSlide,u=o.step,l=0!==a?a%u||u:u;r||t.dispatchEvent(new CustomEvent("previous",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(i,a-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),o=(n(r),i(1)),s=n(o);e.default=function(t,e,i,n,r){var o=i.getState(),a=o.currentSlide,u=o.totalSlides,l=o.step,d=a+l>u?u-a:l;r||t.dispatchEvent(new CustomEvent("next",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(i,a+d)})},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,n){var r=void 0,o=void 0,s=void 0,a=void 0,u=void 0,l=void 0,d=50;t.addEventListener("touchstart",function(n){var a=n.changedTouches[0];r="none",d=e.getState().innerWidth/i.visibleSlides/5,o=a.pageX,s=a.pageY;var u=t.style.transform.match(/-?\d+/i);u&&u[0]&&(t.classList.remove("animatable"),l=parseInt(u[0],10))},{passive:!0}),t.addEventListener("touchmove",function(e){var i=e.changedTouches[0];a=i.pageX-o,u=i.pageY-s,null!==l&&void 0!==l&&(t.style.transform="translateX("+(l+a)+"px)")},{passive:!0}),t.addEventListener("touchend",function(e){Math.abs(a)<d||Math.abs(u)>100?Math.abs(u)<d||Math.abs(a)>100?(t.classList.add("animatable"),t.style.transform="translateX("+l+"px)"):r=0>u?"up":"down":r=0>a?"left":"right",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-1))},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,o=n.visibleSlides,s=n.isSlidingDisabled;if(e.infinite&&!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;o>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),o=(n(r),i(20)),s=n(o),a=i(1),u=n(a);e.default=function(t,e){var i=e.getState(),n=i.totalSlides,r=i.step,o=Math.ceil(n/r),a=[];(0,s.default)(t);for(var l=0;o>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,o=Math.floor(e/r);t.forEach(function(t,e){e===o?t.classList.add("active"):t.classList.remove("active")})}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){for(;t.firstChild;)t.removeChild(t.firstChild)},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){}])});
{
"name": "sm-slider",
"version": "0.6.5",
"version": "1.0.0",
"description": "A minimalistic, configurable, responsive slider library.",

@@ -5,0 +5,0 @@ "main": "lib/sm-slider.js",

@@ -9,6 +9,2 @@ // @flow

Array.prototype.forEach.call($slides.children, ($slide, index) => {
$slide.setAttribute('data-sm-slider-index', index);
});
if (!options.infinite || isSlidingDisabled) {

@@ -33,2 +29,3 @@ return;

$slide.setAttribute('data-sm-slider-index', lastSlideIndex - index);
$slide.setAttribute('data-sm-slider-duplicate', true);
$slides.insertBefore($slide, $slides.firstElementChild);

@@ -39,4 +36,5 @@ });

$slide.setAttribute('data-sm-slider-index', index);
$slide.setAttribute('data-sm-slider-duplicate', true);
$slides.appendChild($slide);
});
};

@@ -5,2 +5,3 @@ // @flow

import clearChildren from '../utils/clear-children';
import slideTo from './slide-to';

@@ -11,5 +12,6 @@

const dots = Math.ceil(totalSlides / step);
const $dots = [];
clearChildren($navigation);
for (let i = 0; i < dots; i++) {

@@ -16,0 +18,0 @@ const $dot = document.createElement('div');

@@ -14,3 +14,3 @@ // @flow

if (!isSlidingDisabled) {
slide($ref, $slides, store);
slide($ref, $slides, store, true);
}

@@ -17,0 +17,0 @@

@@ -8,3 +8,4 @@ // @flow

$slides: HTMLElement,
store: Store<SliderState>
store: Store<SliderState>,
preventAnimation: boolean = false
) => {

@@ -20,3 +21,3 @@ const { currentSlide, innerWidth, totalSlides, animate, visibleSlides, step } = store.getState();

if (animate) {
if (animate && !preventAnimation) {
$slides.classList.add('animatable');

@@ -23,0 +24,0 @@ $slides.addEventListener('transitionend', () => {

@@ -19,2 +19,3 @@ // @flow

import handleSwipe from './events/swipe-handler';
import clean from './core/clean';
import configure from './core/configure';

@@ -37,2 +38,4 @@ import createNavigation, { updateNavigation } from './core/navigation';

totalSlides: 0,
step: 1,
visibleSlides: 1,
isNextDisabled: false,

@@ -75,2 +78,4 @@ isPrevDisabled: false,

clean(_(this).$slides);
const innerWidth = getInnerWidth(_(this).$ref, _(this).$arrowLeft, _(this).$arrowRight);

@@ -238,3 +243,5 @@ const { visibleSlides, step } = getBreakpointOptions(_(this).options, window.innerWidth);

currentSlide,
innerWidth
innerWidth,
visibleSlides,
step
} = store.getState();

@@ -247,2 +254,8 @@

// Reconfigure slider, if visibleSlides or step changes due to breakpoint hit
if (visibleSlides !== prevState.visibleSlides || step !== prevState.step) {
clean($slides);
configure($slides, options, store);
}
// Trigger the sliding animation, if the slide has changed

@@ -274,8 +287,11 @@ if (currentSlide !== prevState.currentSlide || options.infinite) {

let options: SliderOptions;
try {
const options = JSON.parse(optionString);
$refs.push(new Slider($slider, options));
options = JSON.parse(optionString);
} catch(err) {
throw errors.INVALID_OPTIONS
}
$refs.push(new Slider($slider, options));
});

@@ -282,0 +298,0 @@

@@ -6,2 +6,4 @@ // @flow

innerWidth: number,
visibleSlides: number,
step: number,
isPrevDisabled: boolean,

@@ -8,0 +10,0 @@ isNextDisabled: boolean,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc