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 1.1.0 to 1.2.0

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(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=a>l?"translateX("+(-c*o-c*d)+"px)":"translateX(0)"},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(_),x=i(1),j=n(x),E=i(3),L=n(E),P=i(16),M=n(P),C=i(17),D=n(C),k=i(18),N=n(k),A=i(19),I=n(A),R=i(4),W=n(R),T=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)(T(t).$ref,T(t).$slides,T(t).store,T(t).options,e)},this.previousSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,$.default)(T(t).$ref,T(t).$slides,T(t).store,T(t).options,e)},this.toSlide=function(e){(0,j.default)(T(t).store,e)},this.addEventListener=function(e,i,n){T(t).$ref.addEventListener(e,i,n)},this.removeEventListener=function(e,i){T(t).$ref.removeEventListener(e,i)},this.handleChange=function(e){var i=T(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,f=s.isSlidingDisabled;u!==e.innerWidth&&(0,g.default)(T(t).$ref,n,r),l===e.visibleSlides&&d===e.step||((0,D.default)(n),(0,N.default)(n,o,r),T(t).$navigationDots=(0,I.default)(T(t).$navigation,T(t).store)),f!==e.isSlidingDisabled&&(T(t).$arrowLeft&&(T(t).$arrowLeft.style.visibility=f?"hidden":"visible"),T(t).$arrowRight&&(T(t).$arrowRight.style.visibility=f?"hidden":"visible")),(a!==e.currentSlide||o.infinite)&&((0,b.default)(T(t).$ref,n,r),T(t).$navigationDots&&(0,A.updateNavigation)(T(t).$navigationDots,a,T(t).store))}};e.default=function(){function t(e,i){var n=this;if(r(this,t),B.call(this),T(this).$ref=e,T(this).options=o({},q,i),T(this).$slides=T(this).$ref.querySelector(".slides"),T(this).$arrowLeft=T(this).$ref.querySelector(".arrow-left"),T(this).$arrowRight=T(this).$ref.querySelector(".arrow-right"),T(this).$navigation=T(this).$ref.querySelector(".dot-nav"),!T(this).$slides||!T(this).$slides.children.length)throw h.NO_CHILDREN;(0,D.default)(T(this).$slides);var s=(0,L.default)(T(this).$ref,T(this).$arrowLeft,T(this).$arrowRight),a=(0,W.default)(T(this).options,window.innerWidth),l=a.visibleSlides,f=a.step,c=T(this).$slides.children.length,v=l>=c,p=o({},X,{totalSlides:c,innerWidth:s,visibleSlides:l,step:f,isSlidingDisabled:v});T(this).store=new d.default(p,this.handleChange),(0,N.default)(T(this).$slides,T(this).options,T(this).store),(0,g.default)(T(this).$ref,T(this).$slides,T(this).store),T(this).$navigationDots=(0,I.default)(T(this).$navigation,T(this).store),T(this).$arrowLeft&&(T(this).$arrowLeft.addEventListener("click",$.default.bind(this,T(this).$ref,T(this).$slides,T(this).store,T(this).options,!1)),v&&(T(this).$arrowLeft.style.visibility="hidden")),T(this).$arrowRight&&(T(this).$arrowRight.addEventListener("click",O.default.bind(this,T(this).$ref,T(this).$slides,T(this).store,T(this).options,!1)),v&&(T(this).$arrowRight.style.visibility="hidden")),window.addEventListener("resize",(0,u.default)(m.default.bind(this,T(this).$ref,T(this).store,T(this).options,T(this).$arrowLeft,T(this).$arrowRight),200)),v||(0,M.default)(T(this).$slides,T(this).store,T(this).options,function(t){switch(t){case"left":(0,O.default)(T(n).$ref,T(n).$slides,T(n).store,T(n).options,!1);break;case"right":(0,$.default)(T(n).$ref,T(n).$slides,T(n).store,T(n).options,!1);break;default:(0,j.default)(T(n).store,T(n).store.getState().currentSlide)}}),T(this).$ref.addEventListener("slide",function(t){var e=t.detail,i=e.internal,r=e.to;return i?null:n.toSlide(r)}),T(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:n.nextSlide(!0)}),T(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:n.previousSlide(!0)}),T(this).options.autoplay&&(T(this).isIntervalPaused=!1,setInterval(function(){return!T(n).isIntervalPaused&&n.nextSlide()},T(this).options.autoplay),T(this).$ref.addEventListener("mouseenter",function(){T(n).isIntervalPaused=!0}),T(this).$ref.addEventListener("mouseleave",function(){T(n).isIntervalPaused=!1})),T(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),x?r(t):m}function a(t){var i=t-g,n=t-O,r=e-i;return j?$(r,y-n):r}function l(t){var i=t-g,n=t-O;return void 0===g||i>=e||0>i||j&&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(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,x=!1,j=!1,E=!0;if("function"!=typeof t)throw new TypeError(u);return e=s(e)||0,n(i)&&(x=!!i.leading,j="maxWait"in i,y=j?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=i(0),o=(n(r),i(3)),s=n(o),a=i(4),u=n(a);e.default=function(t,e,i,n,r){var o=(0,s.default)(t,n,r),a=e.getState(),l=a.totalSlides,d=(0,u.default)(i,window.innerWidth),f=d.visibleSlides,c=d.step;e.setState(function(t){return{innerWidth:o,visibleSlides:f,step:c,isSlidingDisabled:f>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(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=i.isSlidingDisabled;if(!(0,s.default)(t)||o)return null;for(var a=Math.ceil(n/r),l=[],d=0;a>d;d++)!function(i){var n=document.createElement("div");n.classList.add("dot"),n.addEventListener("click",function(){return(0,u.default)(e,i)}),l.push(n),t.appendChild(n)}(d);return l[0].classList.add("active"),l};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){if(!t)return!1;for(;t.firstChild;)t.removeChild(t.firstChild);return!0},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,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.offsetLeft,f=r.step,c=o;o===a?c=0:0>o&&(c=a-f),u&&!n&&(e.classList.add("animatable"),e.addEventListener("transitionend",function(){e.classList.remove("animatable"),(o===a||0>o)&&i.setState(function(t){return{currentSlide:c,animate:!1}})},{once:!0}),t.dispatchEvent(new CustomEvent("slide",{detail:{to:c,internal:!0}})));var v=s/l;e.style.transform=a>l?"translateX("+(-v*o-v*f+d*v)+"px)":"translateX(0)"},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.offsetLeft,o=t.breakpoints;return o&&Object.keys(o).length?Object.keys(o).reduce(function(t,s){return e<parseInt(s,10)?t:{visibleSlides:o[s].visibleSlides||i,step:o[s].step||n,offsetLeft:o[s].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(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),S=n(y),m=i(13),g=n(m),w=i(14),$=n(w),_=i(15),L=n(_),O=i(1),E=n(O),x=i(3),j=n(x),P=i(16),M=n(P),C=i(17),D=n(C),I=i(18),N=n(I),k=i(19),A=n(k),T=i(4),R=n(T),W=new c.default,F={infinite:!1,visibleSlides:1,step:1,offsetLeft:0,autoplay:0},q={currentSlide:0,innerWidth:0,totalSlides:0,step:1,visibleSlides:1,offsetLeft:0,isNextDisabled:!1,isPrevDisabled:!1,isSlidingDisabled:!1},X=function(){var t=this;this.nextSlide=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];(0,L.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,E.default)(W(t).store,e)},this.addEventListener=function(e,i,n){W(t).$ref.addEventListener(e,i,n)},this.removeEventListener=function(e,i){W(t).$ref.removeEventListener(e,i)},this.handleChange=function(e){var i=W(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,f=s.isSlidingDisabled;u!==e.innerWidth&&(0,g.default)(W(t).$ref,n,r),l===e.visibleSlides&&d===e.step||((0,D.default)(n),(0,N.default)(n,o,r),W(t).$navigationDots=(0,A.default)(W(t).$navigation,W(t).store)),f!==e.isSlidingDisabled&&(W(t).$arrowLeft&&(W(t).$arrowLeft.style.visibility=f?"hidden":"visible"),W(t).$arrowRight&&(W(t).$arrowRight.style.visibility=f?"hidden":"visible")),(a!==e.currentSlide||o.infinite)&&((0,b.default)(W(t).$ref,n,r),W(t).$navigationDots&&(0,k.updateNavigation)(W(t).$navigationDots,a,W(t).store))}};e.default=function(){function t(e,i){var n=this;if(r(this,t),X.call(this),W(this).$ref=e,W(this).options=o({},F,i),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;(0,D.default)(W(this).$slides);var s=(0,j.default)(W(this).$ref,W(this).$arrowLeft,W(this).$arrowRight),a=(0,R.default)(W(this).options,window.innerWidth),l=a.visibleSlides,f=a.step,c=a.offsetLeft;if(0>c||c>1)throw h.INVALID_OFFSET_LEFT;var v=W(this).$slides.children.length,p=l>=v,b=o({},q,{totalSlides:v,innerWidth:s,visibleSlides:l,step:f,offsetLeft:c,isSlidingDisabled:p});W(this).store=new d.default(b,this.handleChange),(0,N.default)(W(this).$slides,W(this).options,W(this).store),(0,g.default)(W(this).$ref,W(this).$slides,W(this).store),W(this).$navigationDots=(0,A.default)(W(this).$navigation,W(this).store),W(this).$arrowLeft&&(W(this).$arrowLeft.addEventListener("click",$.default.bind(this,W(this).$ref,W(this).$slides,W(this).store,W(this).options,!1)),p&&(W(this).$arrowLeft.style.visibility="hidden")),W(this).$arrowRight&&(W(this).$arrowRight.addEventListener("click",L.default.bind(this,W(this).$ref,W(this).$slides,W(this).store,W(this).options,!1)),p&&(W(this).$arrowRight.style.visibility="hidden")),window.addEventListener("resize",(0,u.default)(S.default.bind(this,W(this).$ref,W(this).store,W(this).options,W(this).$arrowLeft,W(this).$arrowRight),200)),p||(0,M.default)(W(this).$slides,W(this).store,W(this).options,function(t){switch(t){case"left":(0,L.default)(W(n).$ref,W(n).$slides,W(n).store,W(n).options,!1);break;case"right":(0,$.default)(W(n).$ref,W(n).$slides,W(n).store,W(n).options,!1);break;default:(0,E.default)(W(n).store,W(n).store.getState().currentSlide)}}),W(this).$ref.addEventListener("slide",function(t){var e=t.detail,i=e.internal,r=e.to;return i?null:n.toSlide(r)}),W(this).$ref.addEventListener("next",function(t){return t.detail&&t.detail.internal?null:n.nextSlide(!0)}),W(this).$ref.addEventListener("previous",function(t){return t.detail&&t.detail.internal?null:n.previousSlide(!0)}),W(this).options.autoplay&&(W(this).isIntervalPaused=!1,setInterval(function(){return!W(n).isIntervalPaused&&n.nextSlide()},W(this).options.autoplay),W(this).$ref.addEventListener("mouseenter",function(){W(n).isIntervalPaused=!0}),W(this).$ref.addEventListener("mouseleave",function(){W(n).isIntervalPaused=!1})),W(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,L=e,S=t.apply(n,i)}function o(t){return L=t,m=setTimeout(d,e),O?r(t):S}function a(t){var i=t-g,n=t-L,r=e-i;return E?$(r,y-n):r}function l(t){var i=t-g,n=t-L;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,x&&p?r(t):(p=b=void 0,S)}function c(){void 0!==m&&clearTimeout(m),L=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 o(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,L=0,O=!1,E=!1,x=!0;if("function"!=typeof t)throw new TypeError(u);return e=s(e)||0,n(i)&&(O=!!i.leading,E="maxWait"in i,y=E?w(s(i.maxWait)||0,e):y,x="trailing"in i?!!i.trailing:x),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,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";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var r=i(0),o=(n(r),i(3)),s=n(o),a=i(4),u=n(a);e.default=function(t,e,i,n,r){var o=(0,s.default)(t,n,r),a=e.getState(),l=a.totalSlides,d=(0,u.default)(i,window.innerWidth),f=d.visibleSlides,c=d.step;e.setState(function(t){return{innerWidth:o,visibleSlides:f,step:c,isSlidingDisabled:f>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(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=i.isSlidingDisabled;if(!(0,s.default)(t)||o)return null;for(var a=Math.ceil(n/r),l=[],d=0;a>d;d++)!function(i){var n=document.createElement("div");n.classList.add("dot"),n.addEventListener("click",function(){return(0,u.default)(e,i)}),l.push(n),t.appendChild(n)}(d);return l[0].classList.add("active"),l};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){if(!t)return!1;for(;t.firstChild;)t.removeChild(t.firstChild);return!0},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": "1.1.0",
"version": "1.2.0",
"description": "A minimalistic, configurable, responsive slider library.",

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

@@ -183,3 +183,4 @@ # smSlider

| autoplay | Time in milliseconds for the slides to switch automatically | number | 0 | |
| breakpoints | See [Responsiveness](#responsiveness) | Object | undefined | |
| breakpoints | See [Responsiveness](#responsiveness) | Object | undefined | |
| offsetLet | Value between 0 and 1 that controls, how much of the last slide is visible on the left. | number | 0 | yes |

@@ -186,0 +187,0 @@ ### Responsiveness

@@ -11,3 +11,11 @@ // @flow

) => {
const { currentSlide, innerWidth, totalSlides, animate, visibleSlides, step } = store.getState();
const {
currentSlide,
innerWidth,
totalSlides,
animate,
visibleSlides,
offsetLeft,
step
} = store.getState();

@@ -43,4 +51,4 @@ let targetSlide = currentSlide;

$slides.style.transform = totalSlides > visibleSlides
? `translateX(${-(slideWidth * currentSlide) - slideWidth * step}px)`
? `translateX(${(-(slideWidth * currentSlide) - slideWidth * step) + (offsetLeft * slideWidth)}px)`
: `translateX(0)`;
};

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

step: 1,
offsetLeft: 0,
autoplay: 0

@@ -40,2 +41,3 @@ };

visibleSlides: 1,
offsetLeft: 0,
isNextDisabled: false,

@@ -81,4 +83,8 @@ isPrevDisabled: false,

const innerWidth = getInnerWidth(_(this).$ref, _(this).$arrowLeft, _(this).$arrowRight);
const { visibleSlides, step } = getBreakpointOptions(_(this).options, window.innerWidth);
const { visibleSlides, step, offsetLeft } = getBreakpointOptions(_(this).options, window.innerWidth);
if (offsetLeft < 0 || offsetLeft > 1) {
throw errors.INVALID_OFFSET_LEFT;
}
const totalSlides = _(this).$slides.children.length;

@@ -93,2 +99,3 @@ const isSlidingDisabled = totalSlides <= visibleSlides;

step,
offsetLeft,
isSlidingDisabled

@@ -95,0 +102,0 @@ };

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

step: number,
offsetLeft: number,
autoplay?: number,

@@ -13,3 +14,4 @@ breakpoints?: {[key: string]: BreakpointOptions}

visibleSlides?: number,
step?: number
step?: number,
offsetLeft: number
};

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

step: number,
offsetLeft: number,
isPrevDisabled: boolean,

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

@@ -19,1 +19,5 @@ // @flow

);
export const INVALID_OFFSET_LEFT = createErrorMessage(
'The property `offsetLeft` has an invalid value. Please only provide values >= 0 and <= 1.'
);

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

export default (options: SliderOptions, innerWidth: number): BreakpointOptions => {
let { visibleSlides, step } = options;
let { visibleSlides, step, offsetLeft } = options;

@@ -12,3 +12,4 @@ const breakpoints = options.breakpoints;

visibleSlides,
step
step,
offsetLeft
};

@@ -20,8 +21,10 @@ }

visibleSlides: breakpoints[breakpoint].visibleSlides || visibleSlides,
step: breakpoints[breakpoint].step || step
step: breakpoints[breakpoint].step || step,
offsetLeft: breakpoints[breakpoint].offsetLeft || offsetLeft
} : result;
}, {
visibleSlides,
step
step,
offsetLeft
});
};

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