UNPKG

vue-dynamic-slider

Version:
2 lines 30.5 kB
(function(t,e){"object"===typeof exports&&"object"===typeof module?module.exports=e():"function"===typeof define&&define.amd?define([],e):"object"===typeof exports?exports["vue-dynamic-slider"]=e():t["vue-dynamic-slider"]=e()})("undefined"!==typeof self?self:this,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s="fae3")}({"24fb":function(t,e,r){"use strict";function n(t,e){var r=t[1]||"",n=t[3];if(!n)return r;if(e&&"function"===typeof btoa){var o=i(n),s=n.sources.map((function(t){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(t," */")}));return[r].concat(s).concat([o]).join("\n")}return[r].join("\n")}function i(t){var e=btoa(unescape(encodeURIComponent(JSON.stringify(t)))),r="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(e);return"/*# ".concat(r," */")}t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var r=n(e,t);return e[2]?"@media ".concat(e[2]," {").concat(r,"}"):r})).join("")},e.i=function(t,r,n){"string"===typeof t&&(t=[[null,t,""]]);var i={};if(n)for(var o=0;o<this.length;o++){var s=this[o][0];null!=s&&(i[s]=!0)}for(var c=0;c<t.length;c++){var a=[].concat(t[c]);n&&i[a[0]]||(r&&(a[2]?a[2]="".concat(r," and ").concat(a[2]):a[2]=r),e.push(a))}},e}},"3dba":function(t,e,r){var n=r("24fb");e=n(!1),e.push([t.i,".dynamic-slider{white-space:nowrap;overflow:hidden}.dynamic-slider .dynamic-slider-slide{display:inline-block;white-space:normal}.dynamic-slider .dynamic-slider-slides{position:relative}",""]),t.exports=e},"499e":function(t,e,r){"use strict";function n(t,e){for(var r=[],n={},i=0;i<e.length;i++){var o=e[i],s=o[0],c=o[1],a=o[2],u=o[3],l={id:t+":"+i,css:c,media:a,sourceMap:u};n[s]?n[s].parts.push(l):r.push(n[s]={id:s,parts:[l]})}return r}r.r(e),r.d(e,"default",(function(){return p}));var i="undefined"!==typeof document;if("undefined"!==typeof DEBUG&&DEBUG&&!i)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var o={},s=i&&(document.head||document.getElementsByTagName("head")[0]),c=null,a=0,u=!1,l=function(){},f=null,d="data-vue-ssr-id",h="undefined"!==typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function p(t,e,r,i){u=r,f=i||{};var s=n(t,e);return v(s),function(e){for(var r=[],i=0;i<s.length;i++){var c=s[i],a=o[c.id];a.refs--,r.push(a)}e?(s=n(t,e),v(s)):s=[];for(i=0;i<r.length;i++){a=r[i];if(0===a.refs){for(var u=0;u<a.parts.length;u++)a.parts[u]();delete o[a.id]}}}}function v(t){for(var e=0;e<t.length;e++){var r=t[e],n=o[r.id];if(n){n.refs++;for(var i=0;i<n.parts.length;i++)n.parts[i](r.parts[i]);for(;i<r.parts.length;i++)n.parts.push(y(r.parts[i]));n.parts.length>r.parts.length&&(n.parts.length=r.parts.length)}else{var s=[];for(i=0;i<r.parts.length;i++)s.push(y(r.parts[i]));o[r.id]={id:r.id,refs:1,parts:s}}}}function m(){var t=document.createElement("style");return t.type="text/css",s.appendChild(t),t}function y(t){var e,r,n=document.querySelector("style["+d+'~="'+t.id+'"]');if(n){if(u)return l;n.parentNode.removeChild(n)}if(h){var i=a++;n=c||(c=m()),e=S.bind(null,n,i,!1),r=S.bind(null,n,i,!0)}else n=m(),e=w.bind(null,n),r=function(){n.parentNode.removeChild(n)};return e(t),function(n){if(n){if(n.css===t.css&&n.media===t.media&&n.sourceMap===t.sourceMap)return;e(t=n)}else r()}}var g=function(){var t=[];return function(e,r){return t[e]=r,t.filter(Boolean).join("\n")}}();function S(t,e,r,n){var i=r?"":n.css;if(t.styleSheet)t.styleSheet.cssText=g(e,i);else{var o=document.createTextNode(i),s=t.childNodes;s[e]&&t.removeChild(s[e]),s.length?t.insertBefore(o,s[e]):t.appendChild(o)}}function w(t,e){var r=e.css,n=e.media,i=e.sourceMap;if(n&&t.setAttribute("media",n),f.ssrId&&t.setAttribute(d,e.id),i&&(r+="\n/*# sourceURL="+i.sources[0]+" */",r+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),t.styleSheet)t.styleSheet.cssText=r;else{while(t.firstChild)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(r))}}},8245:function(t,e,r){var n=r("3dba");"string"===typeof n&&(n=[[t.i,n,""]]),n.locals&&(t.exports=n.locals);var i=r("499e").default;i("386e3476",n,!0,{sourceMap:!1,shadowMode:!1})},8875:function(t,e,r){var n,i,o;(function(r,s){i=[],n=s,o="function"===typeof n?n.apply(e,i):n,void 0===o||(t.exports=o)})("undefined"!==typeof self&&self,(function(){function t(){var e=Object.getOwnPropertyDescriptor(document,"currentScript");if(!e&&"currentScript"in document&&document.currentScript)return document.currentScript;if(e&&e.get!==t&&document.currentScript)return document.currentScript;try{throw new Error}catch(h){var r,n,i,o=/.*at [^(]*\((.*):(.+):(.+)\)$/gi,s=/@([^@]*):(\d+):(\d+)\s*$/gi,c=o.exec(h.stack)||s.exec(h.stack),a=c&&c[1]||!1,u=c&&c[2]||!1,l=document.location.href.replace(document.location.hash,""),f=document.getElementsByTagName("script");a===l&&(r=document.documentElement.outerHTML,n=new RegExp("(?:[^\\n]+?\\n){0,"+(u-2)+"}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*","i"),i=r.replace(n,"$1").trim());for(var d=0;d<f.length;d++){if("interactive"===f[d].readyState)return f[d];if(f[d].src===a)return f[d];if(a===l&&f[d].innerHTML&&f[d].innerHTML.trim()===i)return f[d]}return null}}return t}))},"96cf":function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,i="function"===typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(_){a=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof m?e:m,o=Object.create(i.prototype),s=new k(n||[]);return o._invoke=P(t,r,s),o}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(_){return{type:"throw",arg:_}}}t.wrap=u;var f="suspendedStart",d="suspendedYield",h="executing",p="completed",v={};function m(){}function y(){}function g(){}var S={};S[o]=function(){return this};var w=Object.getPrototypeOf,b=w&&w(w(L([])));b&&b!==r&&n.call(b,o)&&(S=b);var x=g.prototype=m.prototype=Object.create(S);function I(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(i,o,s,c){var a=l(t[i],t,o);if("throw"!==a.type){var u=a.arg,f=u.value;return f&&"object"===typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,s,c)}),(function(t){r("throw",t,s,c)})):e.resolve(f).then((function(t){u.value=t,s(u)}),(function(t){return r("throw",t,s,c)}))}c(a.arg)}var i;function o(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}this._invoke=o}function P(t,e,r){var n=f;return function(i,o){if(n===h)throw new Error("Generator is already running");if(n===p){if("throw"===i)throw o;return A()}r.method=i,r.arg=o;while(1){var s=r.delegate;if(s){var c=E(s,r);if(c){if(c===v)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var a=l(t,e,r);if("normal"===a.type){if(n=r.done?p:d,a.arg===v)continue;return{value:a.arg,done:r.done}}"throw"===a.type&&(n=p,r.method="throw",r.arg=a.arg)}}}function E(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator["return"]&&(r.method="return",r.arg=e,E(t,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var i=l(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function T(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"===typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function r(){while(++i<t.length)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return s.next=s}}return{next:A}}function A(){return{value:e,done:!0}}return y.prototype=x.constructor=g,g.constructor=y,y.displayName=a(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"===typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,a(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},I(O.prototype),O.prototype[s]=function(){return this},t.AsyncIterator=O,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var s=new O(u(e,r,n,i),o);return t.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},I(x),a(x,c,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){while(e.length){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(j),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0],e=t.completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],c=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var a=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(a&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;j(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}(t.exports);try{regeneratorRuntime=n}catch(i){Function("r","regeneratorRuntime = r")(n)}},a34a:function(t,e,r){t.exports=r("96cf")},fae3:function(t,e,r){"use strict";if(r.r(e),r.d(e,"SliderFrame",(function(){return p})),r.d(e,"SliderSlide",(function(){return w})),r.d(e,"SliderSlides",(function(){return Q})),"undefined"!==typeof window){var n=window.document.currentScript,i=r("8875");n=i(),"currentScript"in document||Object.defineProperty(document,"currentScript",{get:i});var o=n&&n.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);o&&(r.p=o[1])}r("8245");function s(t,e,r){return t<e?e:t>r?r:t}function c(t,e,r,n){var i=r-e;return t/=n,t--,i*(t*t*t+1)+e}var a,u,l={props:{slidesPerView:{type:Number,default:5},scrollIncrement:{type:Number,default:1},infiniteScroll:{type:Boolean,default:!1},breakpoints:{type:Object,default:null},breakpointElement:{type:Function,default:null},scrollingFunction:{type:Function,default:c},autoplay:{type:Boolean,default:!1},autoplayInterval:{type:Number,default:5e3}},data:function(){return{activeIndex:0,totalSlides:0,currentSlidesPerView:this.slidesPerView,currentScrollIncrement:this.scrollIncrement,scrollDir:!1,autoplayId:-1}},provide:function(){var t=this,e={};return Object.defineProperty(e,"slidesPerView",{enumerable:!0,get:function(){return t.slidesPerView},set:function(e){t.slidesPerView=e}}),Object.defineProperty(e,"currentSlidesPerView",{enumerable:!0,get:function(){return t.currentSlidesPerView},set:function(e){t.currentSlidesPerView=Math.min(e,t.totalSlides)}}),Object.defineProperty(e,"scrollIncrement",{enumerable:!0,get:function(){return t.scrollIncrement},set:function(e){t.scrollIncrement=e}}),Object.defineProperty(e,"currentScrollIncrement",{enumerable:!0,get:function(){return t.currentScrollIncrement},set:function(e){t.currentScrollIncrement=e}}),Object.defineProperty(e,"activeIndex",{enumerable:!0,get:function(){return t.activeIndex},set:this.setActiveIndex}),Object.defineProperty(e,"totalSlides",{enumerable:!0,get:function(){return t.totalSlides},set:function(e){t.totalSlides=e}}),Object.defineProperty(e,"scrollDir",{enumerable:!0,get:function(){return t.scrollDir},set:function(e){t.scrollDir=!!["next","prev"].includes(e)&&e}}),Object.defineProperty(e,"infiniteScroll",{enumerable:!0,get:function(){return t.shouldInfiniteScroll}}),Object.defineProperty(e,"breakpoints",{enumerable:!0,get:function(){return t.breakpoints}}),Object.defineProperty(e,"breakpointElement",{enumerable:!0,get:function(){return t.breakpointElement}}),Object.defineProperty(e,"scrollingFunction",{enumerable:!0,get:function(){return t.scrollingFunction}}),{props:e}},computed:{canScrollNext:function(){return this.shouldInfiniteScroll||this.activeIndex<this.lastAllowedSlide},canScrollPrev:function(){return this.shouldInfiniteScroll||this.activeIndex>0},shouldInfiniteScroll:function(){return this.infiniteScroll&&this.totalSlides>this.currentSlidesPerView},singleScroll:function(){return 1===this.currentScrollIncrement},slidesInView:function(){for(var t=[],e=this.activeIndex;e<this.activeIndex+this.currentSlidesPerView;e++)this.infiniteScroll?t.push(e>=this.totalSlides?e-this.totalSlides:e):e<this.totalSlides&&t.push(e);return t},currentPage:function(){return Math.floor(this.activeIndex/this.totalSlides*this.numPages)},numPages:function(){return Math.ceil(this.totalSlides/this.currentScrollIncrement)},lastAllowedSlide:function(){return this.shouldInfiniteScroll?this.totalSlides-1:Math.max(this.totalSlides-this.currentSlidesPerView,0)}},watch:{activeIndex:function(t){this.$emit("change",t)},autoplay:function(t){clearTimeout(this.autoplayId),t&&this.startAutoplay()}},mounted:function(){this.autoplay&&this.startAutoplay()},methods:{startAutoplay:function(){var t=this;this.autoplayId=setTimeout((function(){t.next()}),this.autoplayInterval)},goToIndex:function(t){this.requestScrollToSlide(this.getNearestAllowedIndex(t))},goToPage:function(t){this.requestScrollToSlide(this.getNearestAllowedIndex(this.currentScrollIncrement*t))},next:function(){this.scrollDir="next",this.requestScrollToSlide(this.getNearestAllowedIndex(this.activeIndex+1))},prev:function(){this.scrollDir="prev",this.requestScrollToSlide(this.getNearestAllowedIndex(this.activeIndex-1))},setActiveIndex:function(t){this.requestScrollToSlide(this.getNearestAllowedIndex(t))},requestScrollToSlide:function(t){this.autoplay&&(clearTimeout(this.autoplayId),this.startAutoplay()),this.shouldInfiniteScroll?this.activeIndex=t<0?t+this.totalSlides:t%this.totalSlides:this.activeIndex=s(t,0,this.lastAllowedSlide)},getNearestAllowedIndex:function(t){if(this.singleScroll)return t;var e=this.scrollDir||(t>this.activeIndex?"next":"prev"),r="next"===e?"ceil":"floor",n=Math[r](t/this.currentScrollIncrement)*this.currentScrollIncrement;return this.shouldInfiniteScroll&&n>=this.totalSlides?0:n}},beforeDestroy:function(){clearTimeout(this.autoplayId)},render:function(){return this.$scopedSlots.default({activeIndex:this.activeIndex,canScrollNext:this.canScrollNext,canScrollPrev:this.canScrollPrev,slidesInView:this.slidesInView,pagination:{numPages:this.numPages,currentPage:this.currentPage},scrollToSlide:this.goToIndex,scrollToPage:this.goToPage,next:this.next,prev:this.prev})}},f=l;function d(t,e,r,n,i,o,s,c){var a,u="function"===typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=r,u._compiled=!0),n&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(a=function(t){t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,t||"undefined"===typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),i&&i.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=a):i&&(a=c?function(){i.call(this,(u.functional?this.parent:this).$root.$options.shadowRoot)}:i),a)if(u.functional){u._injectStyles=a;var l=u.render;u.render=function(t,e){return a.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,a):[a]}return{exports:t,options:u}}var h=d(f,a,u,!1,null,null,null),p=h.exports,v=function(){var t=this,e=t.$createElement,r=t._self._c||e;return r("div",{directives:[{name:"show",rawName:"v-show",value:t.active,expression:"active"}],class:t.slideClass,style:{width:t.widthPercent}},[t._t("default")],2)},m=[],y={name:"SliderSlide",props:{slideClass:{type:[String,Object,Array],default:"dynamic-slider-slide"}},data:function(){return{active:!0}},inject:["props"],computed:{widthPercent:function(){return 100/this.props.currentSlidesPerView+"%"}}},g=y,S=d(g,v,m,!1,null,null,null),w=S.exports,b=r("a34a"),x=r.n(b);function I(t,e,r){function n(t){var i=t.children&&t.children.map((function(t){return n(t)})),o=e(t.tag,t.data,i);return o.text=t.text,o.isComment=t.isComment,o.componentOptions=t.componentOptions,o.elm=t.elm,o.context=t.context,o.ns=t.ns,o.isStatic=t.isStatic,null!==t.key&&void 0!==t.key&&""!==t.key&&(o.key="".concat(t.key,"-").concat(r)),o}return t.map((function(t){return n(t)}))}function O(t,e,r,n,i,o,s){try{var c=t[o](s),a=c.value}catch(u){return void r(u)}c.done?e(a):Promise.resolve(a).then(n,i)}function P(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){O(o,n,i,s,c,"next",t)}function c(t){O(o,n,i,s,c,"throw",t)}s(void 0)}))}}var E={data:function(){return{currentOffset:0,scrollStartTime:0,animationId:-1,promiseResolve:null,dragging:!1}},methods:{jumpToSlide:function(t){var e=this;return P(x.a.mark((function r(){return x.a.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return e.props.activeIndex=t,e.currentOffset=e.getSlideOffset(t),r.next=4,e.$nextTick();case 4:case"end":return r.stop()}}),r)})))()},scrollToSlide:function(t){var e=this;return P(x.a.mark((function r(){var n;return x.a.wrap((function(r){while(1)switch(r.prev=r.next){case 0:if(cancelAnimationFrame(e.animationId),e.promiseResolve&&e.promiseResolve(),n=e.getSlideOffset(t),e.updateOffsetToBeAbsolute(),n!==e.currentOffset){r.next=6;break}return r.abrupt("return");case 6:return e.dragging&&!e.props.infiniteScroll&&(e.dragging=!1,e.props.scrollDir=e.currentOffset>n?"next":"prev"),e.currentOffset<=n&&"next"===e.props.scrollDir?e.currentOffset=e.currentOffset+e.totalWidth:e.currentOffset>n&&"prev"===e.props.scrollDir&&(e.currentOffset=e.currentOffset-e.totalWidth),r.prev=8,r.next=11,new Promise((function(t){e.promiseResolve=t,e.scrollStartTime=performance.now(),e.scroll(e.currentOffset,n,e.scrollStartTime,500,t)}));case 11:r.next=15;break;case 13:r.prev=13,r.t0=r["catch"](8);case 15:e.props.scrollDir=!1;case 16:case"end":return r.stop()}}),r,null,[[8,13]])})))()},scroll:function(t,e,r,n,i){var o=this;o.currentOffset=this.props.scrollingFunction(r-o.scrollStartTime,t,e,n),this.animationId=requestAnimationFrame((function(s){r<o.scrollStartTime+n?o.scroll(t,e,s,n,i):(o.currentOffset=e,i())}))}}};function T(t,e,r,n,i,o,s){try{var c=t[o](s),a=c.value}catch(u){return void r(u)}c.done?e(a):Promise.resolve(a).then(n,i)}function j(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){T(o,n,i,s,c,"next",t)}function c(t){T(o,n,i,s,c,"throw",t)}s(void 0)}))}}var k=.1,L=2,A={data:function(){return{currentOffset:0,previousClientX:0,previousClientY:0,startClientX:0,velocity:0,previousTime:Date.now(),dragging:!1}},mounted:function(){this.$el.addEventListener("touchstart",this.dragStart,{passive:!1}),this.$el.addEventListener("touchend",this.dragEnd,{passive:!1}),this.$el.addEventListener("touchmove",this.dragAction,{passive:!1}),this.$el.addEventListener("mousedown",this.dragStart,{passive:!1})},beforeDestroy:function(){this.$el.removeEventListener("touchstart",this.dragStart),this.$el.removeEventListener("touchend",this.dragEnd),this.$el.removeEventListener("touchmove",this.dragAction),this.$el.removeEventListener("mousedown",this.dragStart),document.removeEventListener("mousemove",this.dragAction),document.removeEventListener("mouseup",this.dragEnd)},methods:{closestSlideIndex:function(){var t="round";this.velocity>=k?(t="floor",this.props.scrollDir="prev"):this.velocity<=-k&&(t="ceil",this.props.scrollDir="next");var e=Math[t](this.scrollPercentage*this.props.totalSlides);return this.props.infiniteScroll||(e=s(e,0,this.props.totalSlides-1)),e},dragStart:function(t){cancelAnimationFrame(this.animationId||-1),this.dragging=!0,"touchstart"===t.type?(this.previousClientX=t.touches[0].clientX,this.previousClientY=t.touches[0].clientY):(t.preventDefault(),this.previousClientX=t.clientX,document.addEventListener("mousemove",this.dragAction,{passive:!1}),document.addEventListener("mouseup",this.dragEnd,{passive:!1})),this.startClientX=this.previousClientX},dragAction:function(t){var e=this.currentPosition(t),r=Date.now();this.velocity=(e-this.previousClientX)/(r-this.previousTime),this.previousTime=r,this.currentOffset-=this.previousClientX-e,this.previousClientX=e,this.props.infiniteScroll&&(this.currentOffset>=0?this.currentOffset-=this.totalWidth:this.currentOffset<=this.duplicateRightStart&&(this.currentOffset+=this.totalWidth))},dragEnd:function(t){var e=this;return j(x.a.mark((function r(){var n,i;return x.a.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return document.removeEventListener("mousemove",e.dragAction),document.removeEventListener("mouseup",e.dragEnd),i=n=e.props.activeIndex,e.didDrag(e.currentPosition(t))&&(t.preventDefault(),t.stopPropagation(),i=e.closestSlideIndex()),e.velocity=0,e.props.activeIndex=i,r.next=8,e.$nextTick();case 8:if(e.props.activeIndex!==n){r.next=12;break}return e.props.scrollDir="next"===e.props.scrollDir?"prev":"next",r.next=12,e.scrollToSlide(e.props.activeIndex);case 12:e.props.scrollDir=!1;case 13:case"end":return r.stop()}}),r)})))()},cancelClicks:function(t){this.didDrag(this.currentPosition(t))&&(t.stopPropagation(),t.preventDefault())},didDrag:function(t){return Math.abs(t-this.startClientX)>L},currentPosition:function(t){switch(t.type){case"touchmove":return t.touches[0].clientX;case"touchend":return t.changedTouches[0].clientX;default:return t.clientX}}}};function _(t,e){if("function"!==typeof t)throw new TypeError("Expected a function");var r;return function(){r||(r=!0,setTimeout((function(){t(),r=!1}),e))}}function C(t,e){var r;if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=V(t))||e&&t&&"number"===typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,c=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw o}}}}function V(t,e){if(t){if("string"===typeof t)return D(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?D(t,e):void 0}}function D(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var N={sm:640,md:768,lg:1024,xl:1280},$={data:function(){return{breakpointWidth:window.innerWidth}},mounted:function(){var t=this;function e(){t.props.breakpointElement?t.breakpointWidth=t.props.breakpointElement().offsetWidth:t.breakpointWidth=window.innerWidth}window.addEventListener("resize",_(e,100),!1),e(),this.props.breakpoints&&(this.props.currentSlidesPerView=this.getBreakpointValue(this.props.breakpoints,this.props.slidesPerView,"slidesPerView"),this.props.currentScrollIncrement=this.getBreakpointValue(this.props.breakpoints,this.props.scrollIncrement,"scrollIncrement"))},watch:{breakpointWidth:function(){this.props.breakpoints&&(this.props.currentSlidesPerView=this.getBreakpointValue(this.props.breakpoints,this.props.slidesPerView,"slidesPerView"),this.props.currentScrollIncrement=this.getBreakpointValue(this.props.breakpoints,this.props.scrollIncrement,"scrollIncrement"))},"props.slidesPerView":function(t){this.props.currentSlidesPerView=this.getBreakpointValue(this.props.breakpoints,t,"slidesPerView")},"props.scrollIncrement":function(t){this.props.currentSlidesPerView=this.getBreakpointValue(this.props.breakpoints,t,"scrollIncrement")}},methods:{getBreakpointValue:function(t,e,r){if(!t)return e;var n={};Object.keys(t).forEach((function(e){var r=N[e];r?n[r]=t[e]:n[e]=t[e]}));var i,o=C(Object.keys(n).sort(W));try{for(o.s();!(i=o.n()).done;){var s=i.value;if(this.breakpointWidth<=s)return n[s][r]||e}}catch(c){o.e(c)}finally{o.f()}return e}}};function W(t,e){return t-e}function M(t,e,r,n,i,o,s){try{var c=t[o](s),a=c.value}catch(u){return void r(u)}c.done?e(a):Promise.resolve(a).then(n,i)}function R(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){M(o,n,i,s,c,"next",t)}function c(t){M(o,n,i,s,c,"throw",t)}s(void 0)}))}}function B(t){return G(t)||U(t)||X(t)||F()}function F(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function X(t,e){if(t){if("string"===typeof t)return q(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?q(t,e):void 0}}function U(t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}function G(t){if(Array.isArray(t))return q(t)}function q(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var z,Y,H={name:"SliderSlides",mixins:[E,A,$],props:{classes:{type:[Array,Object,String],default:""}},data:function(){return{elementWidth:-1,currentOffset:0,scrollPercentage:0,resizeObserver:null}},inject:["props"],computed:{duplicateRightStart:function(){return-2*this.totalWidth},slideWidth:function(){return this.elementWidth/this.props.currentSlidesPerView},totalWidth:function(){return this.slideWidth*this.props.totalSlides},slideOffsetModifier:function(){return this.props.infiniteScroll?-this.totalWidth:0}},render:function(t){var e=[this.$slots.default];return this.props.totalSlides=this.$slots.default.length,this.props.infiniteScroll&&(e.unshift.apply(e,B(I(this.$slots.default,t,"prevDup"))),e.push.apply(e,B(I(this.$slots.default,t,"nextDup")))),t("div",{class:"dynamic-slider"},[t("div",{class:["dynamic-slider-slides",this.classes],style:"left: ".concat(this.currentOffset,"px"),on:{"!click":this.cancelClicks}},e)])},mounted:function(){this.resizeObserver=new ResizeObserver(this.updateWidth),this.resizeObserver.observe(this.$el)},watch:{currentOffset:function(t){var e=this.props.infiniteScroll?-t%this.totalWidth:-t;this.scrollPercentage=e/this.totalWidth},"props.currentSlidesPerView":function(){this.jumpToSlide(this.props.activeIndex),this.props.activeIndex=this.props.activeIndex},"props.totalSlides":function(){this.jumpToSlide(this.props.activeIndex)},"props.activeIndex":function(){var t=R(x.a.mark((function t(e){return x.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,this.scrollToSlide(e);case 2:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}(),elementWidth:function(){this.jumpToSlide(this.props.activeIndex),this.props.activeIndex=this.props.activeIndex}},beforeDestroy:function(){this.resizeObserver.disconnect()},methods:{updateWidth:function(){this.elementWidth=this.$el.offsetWidth,this.updateOffsetToBeAbsolute()},updateOffsetToBeAbsolute:function(){this.currentOffset=-this.scrollPercentage*this.totalWidth+this.slideOffsetModifier},getSlideOffset:function(t){return-t*this.slideWidth+this.slideOffsetModifier}}},J=H,K=d(J,z,Y,!1,null,null,null),Q=K.exports}})})); //# sourceMappingURL=vue-dynamic-slider.umd.min.js.map