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
2
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.1.0 to 0.2.0

2

lib/sm-slider.js

@@ -1,1 +0,1 @@

!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={};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=6)}([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}()},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}})}},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});var i=n(0);e.default=function(t,e,n){var i=n.getState(),r=i.currentSlide,o=i.innerWidth,s=i.totalSlides,u=i.animate,a=i.visibleSlides,l=i.step,f=r;r===s?f=0:0>r&&(f=s-l),u&&(e.classList.add("animatable"),e.addEventListener("transitionend",function(){e.classList.remove("animatable"),(r===s||0>r)&&n.setState(function(t){return{currentSlide:f,animate:!1}})},{once:!0}),t.dispatchEvent(new CustomEvent("slide",{detail:{to:f,internal:!0}})));var d=o/a;e.style.transform="translateX("+(-d*r-d*l)+"px)"}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n){return t.getBoundingClientRect().width-(e?e.getBoundingClientRect().width:0)-(n?n.getBoundingClientRect().width:0)}},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}}},function(t,e,n){t.exports=n(7)},function(t,e,n){"use strict";(function(i){var r,o,s,u=("function"==typeof Symbol&&Symbol,n(8)),a=function(t){return t&&t.__esModule?t:{default:t}}(u);n(18),n(19),i.smSlider=function(n,i){return o=[],r=i,void 0!==(s="function"==typeof r?r.apply(e,o):r)&&(t.exports=s),i()}(window,function(){return a.default})}).call(e,n(2))},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}}(),u=n(9),a=i(u),l=n(0),f=i(l),d=n(10),c=i(d),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(3),y=i(p),b=n(12),m=i(b),S=n(13),w=i(S),g=n(14),$=i(g),O=n(15),_=i(O),E=n(1),j=i(E),P=n(4),L=i(P),M=n(16),x=i(M),C=n(17),k=i(C),I=n(5),N=i(I),A=new c.default,D={infinite:!1,visibleSlides:1,step:1,autoplay:0},T={currentSlide:0,innerWidth:0,totalSlides:0,isNextDisabled:!1,isPrevDisabled:!1},W=function(){var t=this;this.nextSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,_.default)(A(t).$ref,A(t).$slides,A(t).store,A(t).options,e)},this.previousSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,$.default)(A(t).$ref,A(t).$slides,A(t).store,A(t).options,e)},this.toSlide=function(e){(0,j.default)(A(t).store,e)},this.addEventListener=function(e,n,i){A(t).$ref.addEventListener(e,n,i)},this.removeEventListener=function(e,n){A(t).$ref.removeEventListener(e,n)},this.handleChange=function(e){var n=A(t),i=n.$slides,r=n.store,o=n.options,s=r.getState(),u=s.currentSlide;s.innerWidth!==e.innerWidth&&(0,w.default)(A(t).$ref,i,r),(u!==e.currentSlide||o.infinite)&&(0,y.default)(A(t).$ref,i,r)}};e.default=function(){function t(e,n){var i=this;if(r(this,t),W.call(this),A(this).$ref=e,A(this).options=o({},D,n),A(this).$slides=A(this).$ref.querySelector(".slides"),A(this).$arrowLeft=A(this).$ref.querySelector(".arrow-left"),A(this).$arrowRight=A(this).$ref.querySelector(".arrow-right"),!A(this).$slides||!A(this).$slides.children.length)throw h.NO_CHILDREN;var s=(0,L.default)(A(this).$ref,A(this).$arrowLeft,A(this).$arrowRight),u=(0,N.default)(A(this).options,s),l=u.visibleSlides,d=u.step,c=o({},T,{totalSlides:A(this).$slides.children.length,innerWidth:s,visibleSlides:l,step:d});A(this).store=new f.default(c,this.handleChange),(0,k.default)(A(this).$slides,A(this).options),(0,w.default)(A(this).$ref,A(this).$slides,A(this).store),A(this).$arrowLeft&&A(this).$arrowLeft.addEventListener("click",$.default.bind(this,A(this).$ref,A(this).$slides,A(this).store,A(this).options,!1)),A(this).$arrowRight&&A(this).$arrowRight.addEventListener("click",_.default.bind(this,A(this).$ref,A(this).$slides,A(this).store,A(this).options,!1)),window.addEventListener("resize",(0,a.default)(m.default.bind(this,A(this).$ref,A(this).store,A(this).options,A(this).$arrowLeft,A(this).$arrowRight),200)),(0,x.default)(A(this).$slides,A(this).store,A(this).options,function(t){switch(t){case"left":(0,_.default)(A(i).$ref,A(i).$slides,A(i).store,A(i).options,!1);break;case"right":(0,$.default)(A(i).$ref,A(i).$slides,A(i).store,A(i).options,!1)}}),A(this).$ref.addEventListener("slide",function(t){var e=t.detail,n=e.internal,r=e.to;return n?null:i.toSlide(r)}),A(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:i.nextSlide(!0)}),A(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:i.previousSlide(!0)}),A(this).options.autoplay&&(A(this).isIntervalPaused=!1,setInterval(function(){return!A(i).isIntervalPaused&&i.nextSlide()},A(this).options.autoplay),A(this).$ref.addEventListener("mouseenter",function(){A(i).isIntervalPaused=!0}),A(this).$ref.addEventListener("mouseleave",function(){A(i).isIntervalPaused=!1})),A(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}()},function(t,e,n){"use strict";(function(e){function n(t,e,n){function r(e){var n=p,i=y;return p=y=void 0,_=e,m=t.apply(i,n)}function o(t){return _=t,S=setTimeout(f,e),E?r(t):m}function u(t){var n=t-w,i=t-_,r=e-n;return j?$(r,b-i):r}function l(t){var n=t-w,i=t-_;return void 0===w||n>=e||0>n||j&&i>=b}function f(){var t=O();if(l(t))return d(t);S=setTimeout(f,u(t))}function d(t){return S=void 0,P&&p?r(t):(p=y=void 0,m)}function c(){void 0!==S&&clearTimeout(S),_=0,p=w=y=S=void 0}function v(){return void 0===S?m:d(O())}function h(){var t=O(),n=l(t);if(p=arguments,y=this,w=t,n){if(void 0===S)return o(w);if(j)return S=setTimeout(f,e),r(w)}return void 0===S&&(S=setTimeout(f,e)),m}var p,y,b,m,S,w,_=0,E=!1,j=!1,P=!0;if("function"!=typeof t)throw new TypeError(a);return e=s(e)||0,i(n)&&(E=!!n.leading,j="maxWait"in n,b=j?g(s(n.maxWait)||0,e):b,P="trailing"in n?!!n.trailing:P),h.cancel=c,h.flush=v,h}function i(t){var e=void 0===t?"undefined":u(t);return!!t&&("object"==e||"function"==e)}function r(t){return!!t&&"object"==(void 0===t?"undefined":u(t))}function o(t){return"symbol"==(void 0===t?"undefined":u(t))||r(t)&&w.call(t)==f}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(d,"");var n=v.test(t);return n||h.test(t)?p(t.slice(2),n?2:8):c.test(t)?l:+t}var u="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},a="Expected a function",l=NaN,f="[object Symbol]",d=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,v=/^0b[01]+$/i,h=/^0o[0-7]+$/i,p=parseInt,y="object"==(void 0===e?"undefined":u(e))&&e&&e.Object===Object&&e,b="object"==("undefined"==typeof self?"undefined":u(self))&&self&&self.Object===Object&&self,m=y||b||Function("return this")(),S=Object.prototype,w=S.toString,g=Math.max,$=Math.min,O=function(){return m.Date.now()};t.exports=n}).call(e,n(2))},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}}},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(4)),u=i(s),a=n(5),l=i(a);e.default=function(t,e,n,i,o){var s=(0,u.default)(t,i,o);e.setState(function(t){return r({innerWidth:s},(0,l.default)(n,s))})}},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(3)),s=i(o);e.default=function(t,e,n){var i=n.getState(),r=i.innerWidth,o=i.visibleSlides;(0,s.default)(t,e,n),Array.prototype.forEach.call(e.children,function(t){t.style.width=r/o+"px"})}},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(),u=o.currentSlide,a=i.step,l=0!==u?u%a||a:a;r||t.dispatchEvent(new CustomEvent("previous",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(n,u-l)})}},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(),u=o.currentSlide,a=o.totalSlides,l=i.step,f=u+l>a?a-u:l;r||t.dispatchEvent(new CustomEvent("next",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(n,u+f)})}},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,u=void 0,a=void 0,l=void 0,f=50;t.addEventListener("touchstart",function(i){i.preventDefault();var u=i.changedTouches[0];r="none",f=e.getState().innerWidth/n.visibleSlides/3,o=u.pageX,s=u.pageY;var a=t.style.transform.match(/-?\d+/i);a&&a[0]&&(t.classList.remove("animatable"),l=parseInt(a[0],10))}),t.addEventListener("touchmove",function(e){e.preventDefault();var n=e.changedTouches[0];u=n.pageX-o,a=n.pageY-s,null!==l&&void 0!==l&&(t.style.transform="translateX("+(l+u)+"px)")}),t.addEventListener("touchend",function(e){e.preventDefault(),Math.abs(u)<f||Math.abs(a)>100?Math.abs(a)<f||Math.abs(u)>100?(t.classList.add("animatable"),t.style.transform="translateX("+l+"px)"):r=0>a?"up":"down":r=0>u?"left":"right",i(r)})}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(Array.prototype.forEach.call(t.children,function(t,e){t.setAttribute("data-sm-slider-index",e)}),e.infinite){for(var n=[],i=[],r=t.children.length-1,o=0;e.step>o;o++)n.push(t.children[r-o].cloneNode(!0));for(var s=0;e.visibleSlides>s;s++)i.push(t.children[s].cloneNode(!0));Array.prototype.forEach.call(n,function(e,n){e.setAttribute("data-sm-slider-index",r-n),t.insertBefore(e,t.firstElementChild)}),Array.prototype.forEach.call(i,function(e,n){e.setAttribute("data-sm-slider-index",n),t.appendChild(e)})}}},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(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,u=i.animate,a=i.visibleSlides,l=i.step,f=r;r===s?f=0:0>r&&(f=s-l),u&&(e.classList.add("animatable"),e.addEventListener("transitionend",function(){e.classList.remove("animatable"),(r===s||0>r)&&n.setState(function(t){return{currentSlide:f,animate:!1}})},{once:!0}),t.dispatchEvent(new CustomEvent("slide",{detail:{to:f,internal:!0}})));var d=o/a;e.style.transform="translateX("+(-d*r-d*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.getBoundingClientRect().width:0)-(n?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(18),n(19),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}}(),u=n(8),a=i(u),l=n(0),f=i(l),d=n(10),c=i(d),v=n(11),p=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),h=n(2),y=i(h),b=n(12),m=i(b),S=n(13),w=i(S),g=n(14),$=i(g),_=n(15),O=i(_),j=n(1),x=i(j),E=n(3),P=i(E),L=n(16),M=i(L),C=n(17),k=i(C),I=n(4),N=i(I),A=new c.default,D={infinite:!1,visibleSlides:1,step:1,autoplay:0},T={currentSlide:0,innerWidth:0,totalSlides:0,isNextDisabled:!1,isPrevDisabled:!1},W=function(){var t=this;this.nextSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,O.default)(A(t).$ref,A(t).$slides,A(t).store,A(t).options,e)},this.previousSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,$.default)(A(t).$ref,A(t).$slides,A(t).store,A(t).options,e)},this.toSlide=function(e){(0,x.default)(A(t).store,e)},this.addEventListener=function(e,n,i){A(t).$ref.addEventListener(e,n,i)},this.removeEventListener=function(e,n){A(t).$ref.removeEventListener(e,n)},this.handleChange=function(e){var n=A(t),i=n.$slides,r=n.store,o=n.options,s=r.getState(),u=s.currentSlide;s.innerWidth!==e.innerWidth&&(0,w.default)(A(t).$ref,i,r),(u!==e.currentSlide||o.infinite)&&(0,y.default)(A(t).$ref,i,r)}};e.default=function(){function t(e,n){var i=this;if(r(this,t),W.call(this),A(this).$ref=e,A(this).options=o({},D,n),A(this).$slides=A(this).$ref.querySelector(".slides"),A(this).$arrowLeft=A(this).$ref.querySelector(".arrow-left"),A(this).$arrowRight=A(this).$ref.querySelector(".arrow-right"),!A(this).$slides||!A(this).$slides.children.length)throw p.NO_CHILDREN;var s=(0,P.default)(A(this).$ref,A(this).$arrowLeft,A(this).$arrowRight),u=(0,N.default)(A(this).options,s),l=u.visibleSlides,d=u.step,c=o({},T,{totalSlides:A(this).$slides.children.length,innerWidth:s,visibleSlides:l,step:d});A(this).store=new f.default(c,this.handleChange),(0,k.default)(A(this).$slides,A(this).options),(0,w.default)(A(this).$ref,A(this).$slides,A(this).store),A(this).$arrowLeft&&A(this).$arrowLeft.addEventListener("click",$.default.bind(this,A(this).$ref,A(this).$slides,A(this).store,A(this).options,!1)),A(this).$arrowRight&&A(this).$arrowRight.addEventListener("click",O.default.bind(this,A(this).$ref,A(this).$slides,A(this).store,A(this).options,!1)),window.addEventListener("resize",(0,a.default)(m.default.bind(this,A(this).$ref,A(this).store,A(this).options,A(this).$arrowLeft,A(this).$arrowRight),200)),(0,M.default)(A(this).$slides,A(this).store,A(this).options,function(t){switch(t){case"left":(0,O.default)(A(i).$ref,A(i).$slides,A(i).store,A(i).options,!1);break;case"right":(0,$.default)(A(i).$ref,A(i).$slides,A(i).store,A(i).options,!1)}}),A(this).$ref.addEventListener("slide",function(t){var e=t.detail,n=e.internal,r=e.to;return n?null:i.toSlide(r)}),A(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:i.nextSlide(!0)}),A(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:i.previousSlide(!0)}),A(this).options.autoplay&&(A(this).isIntervalPaused=!1,setInterval(function(){return!A(i).isIntervalPaused&&i.nextSlide()},A(this).options.autoplay),A(this).$ref.addEventListener("mouseenter",function(){A(i).isIntervalPaused=!0}),A(this).$ref.addEventListener("mouseleave",function(){A(i).isIntervalPaused=!1})),A(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 p.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=h,i=y;return h=y=void 0,O=e,m=t.apply(i,n)}function o(t){return O=t,S=setTimeout(f,e),j?r(t):m}function u(t){var n=t-w,i=t-O,r=e-n;return x?$(r,b-i):r}function l(t){var n=t-w,i=t-O;return void 0===w||n>=e||0>n||x&&i>=b}function f(){var t=_();if(l(t))return d(t);S=setTimeout(f,u(t))}function d(t){return S=void 0,E&&h?r(t):(h=y=void 0,m)}function c(){void 0!==S&&clearTimeout(S),O=0,h=w=y=S=void 0}function v(){return void 0===S?m:d(_())}function p(){var t=_(),n=l(t);if(h=arguments,y=this,w=t,n){if(void 0===S)return o(w);if(x)return S=setTimeout(f,e),r(w)}return void 0===S&&(S=setTimeout(f,e)),m}var h,y,b,m,S,w,O=0,j=!1,x=!1,E=!0;if("function"!=typeof t)throw new TypeError(a);return e=s(e)||0,i(n)&&(j=!!n.leading,x="maxWait"in n,b=x?g(s(n.maxWait)||0,e):b,E="trailing"in n?!!n.trailing:E),p.cancel=c,p.flush=v,p}function i(t){var e=void 0===t?"undefined":u(t);return!!t&&("object"==e||"function"==e)}function r(t){return!!t&&"object"==(void 0===t?"undefined":u(t))}function o(t){return"symbol"==(void 0===t?"undefined":u(t))||r(t)&&w.call(t)==f}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(d,"");var n=v.test(t);return n||p.test(t)?h(t.slice(2),n?2:8):c.test(t)?l:+t}var u="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},a="Expected a function",l=NaN,f="[object Symbol]",d=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,v=/^0b[01]+$/i,p=/^0o[0-7]+$/i,h=parseInt,y="object"==(void 0===e?"undefined":u(e))&&e&&e.Object===Object&&e,b="object"==("undefined"==typeof self?"undefined":u(self))&&self&&self.Object===Object&&self,m=y||b||Function("return this")(),S=Object.prototype,w=S.toString,g=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)),u=i(s),a=n(4),l=i(a);e.default=function(t,e,n,i,o){var s=(0,u.default)(t,i,o);e.setState(function(t){return r({innerWidth:s},(0,l.default)(n,s))})},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;(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(),u=o.currentSlide,a=i.step,l=0!==u?u%a||a:a;r||t.dispatchEvent(new CustomEvent("previous",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(n,u-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(),u=o.currentSlide,a=o.totalSlides,l=i.step,f=u+l>a?a-u:l;r||t.dispatchEvent(new CustomEvent("next",{detail:{internal:!0}})),requestAnimationFrame(function(){return(0,s.default)(n,u+f)})},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,u=void 0,a=void 0,l=void 0,f=50;t.addEventListener("touchstart",function(i){i.preventDefault();var u=i.changedTouches[0];r="none",f=e.getState().innerWidth/n.visibleSlides/3,o=u.pageX,s=u.pageY;var a=t.style.transform.match(/-?\d+/i);a&&a[0]&&(t.classList.remove("animatable"),l=parseInt(a[0],10))}),t.addEventListener("touchmove",function(e){e.preventDefault();var n=e.changedTouches[0];u=n.pageX-o,a=n.pageY-s,null!==l&&void 0!==l&&(t.style.transform="translateX("+(l+u)+"px)")}),t.addEventListener("touchend",function(e){e.preventDefault(),Math.abs(u)<f||Math.abs(a)>100?Math.abs(a)<f||Math.abs(u)>100?(t.classList.add("animatable"),t.style.transform="translateX("+l+"px)"):r=0>a?"up":"down":r=0>u?"left":"right",i(r)})},t.exports=e.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(Array.prototype.forEach.call(t.children,function(t,e){t.setAttribute("data-sm-slider-index",e)}),e.infinite){for(var n=[],i=[],r=t.children.length-1,o=0;e.step>o;o++)n.push(t.children[r-o].cloneNode(!0));for(var s=0;e.visibleSlides>s;s++)i.push(t.children[s].cloneNode(!0));Array.prototype.forEach.call(n,function(e,n){e.setAttribute("data-sm-slider-index",r-n),t.insertBefore(e,t.firstElementChild)}),Array.prototype.forEach.call(i,function(e,n){e.setAttribute("data-sm-slider-index",n),t.appendChild(e)})}},t.exports=e.default},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){}])});
{
"name": "sm-slider",
"version": "0.1.0",
"description": "Slider library",
"version": "0.2.0",
"description": "A minimalistic, configurable, responsive slider library.",
"main": "lib/sm-slider.js",
"jsnext:main": "src/index.js",
"module": "src/index.js",
"jsnext:main": "lib/sm-slider.js",
"module": "lib/sm-slider.js",
"scripts": {

@@ -42,2 +42,3 @@ "start": "cross-env NODE_ENV=development webpack-dev-server --config webpack/dev.js",

"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-class-properties": "^6.24.1",

@@ -44,0 +45,0 @@ "babel-preset-env": "^1.6.0",

@@ -43,5 +43,7 @@ # smSlider

```javascript
paths: {
smSlider: 'node_modules/sm-slider/sm-slider'
}
packages: [{
name: 'smSlider',
location: 'node_modules/sm-slider/lib',
main: 'sm-slider'
}]
```

@@ -48,0 +50,0 @@

@@ -15,12 +15,2 @@ // @flow

global.smSlider = (function(context, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory();
} else {
context.returnExports = factory();
}
return factory();
})(window, () => Slider);
export default Slider;

@@ -12,2 +12,4 @@ const join = require('path').join;

filename: 'sm-slider.js',
library: 'sm-slider',
libraryTarget: 'umd',
path: join(__dirname, '../lib')

@@ -14,0 +16,0 @@ },

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