diff --git a/README.md b/README.md index e4cfcce9c..e58df4edb 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ You may install Vue Carousel globally: import Vue from 'vue'; import VueCarousel from '@ssense/vue-carousel'; -Vue.use(VueCarousel.default); +Vue.use(VueCarousel); ``` This will make **<carousel>** and **<slide>** available to all components within your Vue app. diff --git a/dist/vue-carousel.min.js b/dist/vue-carousel.min.js index 25985de98..58af928ac 100644 --- a/dist/vue-carousel.min.js +++ b/dist/vue-carousel.min.js @@ -3,4 +3,4 @@ * (c) 2017 todd.beauchamp@ssense.com * https://github.com/ssense/vue-carousel#readme */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueCarousel=t():e.VueCarousel=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var i=n(1),r=n(19),a=function(e){e.component("carousel",i),e.component("slide",r)};e.exports={default:a,Carousel:i,Slide:r}},function(e,t,n){var i,r;n(2),i=n(6);var a=n(18);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-3e9da494",e.exports=i},function(e,t,n){var i=n(3);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".carousel[data-v-3e9da494]{width:100%;position:relative;overflow:hidden}.carousel-inner[data-v-3e9da494]{backface-visibility:hidden}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&m.splice(t,1)}function s(e){var t=document.createElement("style");return t.type="text/css",a(e,t),t}function d(e,t){var n,i,r;if(t.singleton){var a=g++;n=v||(v=s(t)),i=u.bind(null,n,a,!1),r=u.bind(null,n,a,!0)}else n=s(t),i=c.bind(null,n),r=function(){o(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}function u(e,t,n,i){var r=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=C(t,r);else{var a=document.createTextNode(r),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(a,o[t]):e.appendChild(a)}}function c(e,t){var n=t.css,i=t.media,r=t.sourceMap;if(i&&e.setAttribute("media",i),r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var l={},f=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},h=f(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),p=f(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,g=0,m=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=r(e);return i(n,t),function(e){for(var a=[],o=0;o0},carouselInnerWidth:function(){var e=this.slideWidth*this.slideCount;return e},currentPerPage:function(){return!this.perPageCustom||this.$isServer?this.perPage:this.getBreakpointSlidesPerPage(this.perPageCustom,this.browserWidth)},currentOffset:function(){var e=this.currentPage,t=this.slideWidth,n=this.dragOffset,i=this.scrollPerPage?e*t*this.currentPerPage:e*t;return(i+n)*-1},isHidden:function(){return this.carouselWidth<=0},pageCount:function(){var e=this.slideCount,t=this.currentPerPage;if(this.scrollPerPage){var n=Math.ceil(e/t);return n<1?1:n}return e-(this.currentPerPage-1)},transitionStyle:function(){return this.speed/1e3+"s "+this.easing+" transform"}},methods:{advancePage:function(e){e&&"backward"===e&&this.canAdvanceBackward?this.goToPage(this.currentPage-1):(!e||e&&"backward"!==e)&&this.canAdvanceForward&&this.goToPage(this.currentPage+1)},calculateSlideWidth:function(){var e=this.carouselWidth,t=this.currentPerPage;return this.slideWidth=e/t,this.setChildSlideWidth(this.slideWidth),this.slideWidth},getBreakpointSlidesPerPage:function(e,t){var n=e.sort(function(e,t){var n=e[0]>t[0]?-1:1;return n}),i=n.filter(function(e){var n=t>=e[0];return n}),r=i[0]&&i[0][1];return r||this.perPage},getBrowserWidth:function(){return this.browserWidth=window.innerWidth,this.browserWidth},getCarouselWidth:function(){return this.carouselWidth=this.$el&&this.$el.clientWidth||0,this.carouselWidth},getSlideCount:function(){return this.$slots&&this.$slots.default&&this.$slots.default.length||0},goToPage:function(e){e>=0&&e<=this.pageCount&&(this.currentPage=e)},handleMousedown:function(e){e.touches||e.preventDefault(),this.mousedown=!0,this.dragStartX="ontouchstart"in window?e.touches[0].clientX:e.clientX,"ontouchstart"in window?this.$el.addEventListener("touchmove",this.handleMousemove):this.$el.addEventListener("mousemove",this.handleMousemove)},handleMouseup:function(){this.mousedown=!1,this.dragOffset=0,"ontouchstart"in window?this.$el.removeEventListener("touchmove",this.handleMousemove):this.$el.removeEventListener("mousemove",this.handleMousemove)},handleMousemove:function(e){if(this.mousedown){var t="ontouchstart"in window?e.touches[0].clientX:e.clientX,n=this.dragStartX-t;this.dragOffset=n,this.dragOffset>=this.slideWidth/2?(this.handleMouseup(),this.advancePage()):this.dragOffset<=this.slideWidth/2*-1&&(this.mousedown=!1,this.handleMouseup(),this.advancePage("backward"))}},handleResize:function(){this.getBrowserWidth(),this.recomputeCarouselWidth()},pollForWidth:function(){var e=this;this.pollInterval||(this.pollInterval=setInterval(function(){e.getCarouselWidth()>0&&(e.recomputeCarouselWidth(),clearInterval(e.pollInterval))},100))},recomputeCarouselWidth:function(){this.getCarouselWidth(),this.calculateSlideWidth(),this.setCurrentPageInBounds()},setChildSlideWidth:function(e){this.$slots.default&&this.$slots.default.forEach(function(t){var n=t;n.child.width=e})},setCurrentPageInBounds:function(){if(!this.canAdvanceForward){var e=this.pageCount-1;this.currentPage=e>=0?e:0}}},mounted:function(){this.$isServer||(this.getBrowserWidth(),window.addEventListener("resize",(0,a.default)(this.handleResize,16)),"ontouchstart"in window?(this.$el.addEventListener("touchstart",this.handleMousedown),this.$el.addEventListener("touchend",this.handleMouseup)):(this.$el.addEventListener("mousedown",this.handleMousedown),this.$el.addEventListener("mouseup",this.handleMouseup))),this.slideCount=this.getSlideCount(),this.recomputeCarouselWidth(),this.isHidden&&this.pollForWidth()},destroyed:function(){this.$isServer||window.removeEventListener("resize",this.getBrowserWidth)}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,n){var i=void 0;return function(){var r=void 0,a=function(){i=null,n||e.apply(r)},o=n&&!i;clearTimeout(i),i=setTimeout(a,t),o&&e.apply(r)}};t.default=n},function(e,t,n){var i,r;n(9),i=n(11);var a=n(12);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-fe83c770",e.exports=i},function(e,t,n){var i=n(10);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".disabled[data-v-fe83c770]{opacity:.5;cursor:default}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"navigation",data:function(){return{parentContainer:this.$parent}},computed:{canAdvanceForward:function(){return this.parentContainer.canAdvanceForward||!1},canAdvanceBackward:function(){return this.parentContainer.canAdvanceBackward||!1}},methods:{triggerPageAdvance:function(e){e?this.$parent.advancePage(e):this.$parent.advancePage()}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navigation"},[n("a",{staticClass:"next",class:{disabled:!e.canAdvanceBackward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance()}}},[e._v("Prev")]),e._v(" "),n("a",{staticClass:"prev",class:{disabled:!e.canAdvanceForward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance("backward")}}},[e._v("Next")])])},staticRenderFns:[]}},function(e,t,n){var i,r;n(14),i=n(16);var a=n(17);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-7f1316ce",e.exports=i},function(e,t,n){var i=n(15);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".pagination[data-v-7f1316ce]{width:100%;float:left;text-align:center}.dot-container[data-v-7f1316ce]{display:inline-block;margin:0 auto}.dot[data-v-7f1316ce]{float:left;cursor:pointer}.dot-inner[data-v-7f1316ce]{border-radius:100%}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"pagination",data:function(){return{parentContainer:this.$parent}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"pagination"},[n("div",{staticClass:"dot-container"},e._l(e.parentContainer.pageCount,function(t,i){return n("div",{staticClass:"dot",style:"\n margin-top: "+2*e.parentContainer.paginationPadding+"px;\n padding: "+e.parentContainer.paginationPadding+"px;\n ",on:{click:function(t){e.parentContainer.goToPage(i)}}},[n("div",{staticClass:"dot-inner",style:"\n width: "+e.parentContainer.paginationSize+"px;\n height: "+e.parentContainer.paginationSize+"px;\n background: "+(i===e.parentContainer.currentPage?e.parentContainer.paginationActiveColor:e.parentContainer.paginationColor)+";\n "})])}))])},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"carousel"},[n("div",{staticClass:"carousel-inner",style:"\n width: "+e.carouselInnerWidth+"px;\n transform: translateX("+e.currentOffset+"px);\n transition: "+(!e.mousedown||e.isAnimating?e.transitionStyle:"none")+";\n "},[e._t("default")],2),e._v(" "),e.navigationEnabled?n("navigation"):e._e(),e._v(" "),e.paginationEnabled&&e.pageCount>0?n("pagination"):e._e()],1)},staticRenderFns:[]}},function(e,t,n){var i,r;n(20),i=n(22);var a=n(23);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-f5ced6a6",e.exports=i},function(e,t,n){var i=n(21);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".slide[data-v-f5ced6a6]{float:left;user-select:none;pointer-events:none}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"slide",data:function(){return{width:null}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"slide",style:"width: "+e.width+"px"},[e._t("default")],2)},staticRenderFns:[]}}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueCarousel=t():e.VueCarousel=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Slide=t.Carousel=void 0;var r=n(1),a=i(r),o=n(19),s=i(o),d=function(e){e.component("carousel",a.default),e.component("slide",s.default)};t.default={install:d},t.Carousel=a.default,t.Slide=s.default},function(e,t,n){var i,r;n(2),i=n(6);var a=n(18);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-3e9da494",e.exports=i},function(e,t,n){var i=n(3);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".carousel[data-v-3e9da494]{width:100%;position:relative;overflow:hidden}.carousel-inner[data-v-3e9da494]{backface-visibility:hidden}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&m.splice(t,1)}function s(e){var t=document.createElement("style");return t.type="text/css",a(e,t),t}function d(e,t){var n,i,r;if(t.singleton){var a=g++;n=v||(v=s(t)),i=u.bind(null,n,a,!1),r=u.bind(null,n,a,!0)}else n=s(t),i=l.bind(null,n),r=function(){o(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}function u(e,t,n,i){var r=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=C(t,r);else{var a=document.createTextNode(r),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(a,o[t]):e.appendChild(a)}}function l(e,t){var n=t.css,i=t.media,r=t.sourceMap;if(i&&e.setAttribute("media",i),r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var c={},f=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},h=f(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),p=f(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,g=0,m=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=r(e);return i(n,t),function(e){for(var a=[],o=0;o0},carouselInnerWidth:function(){var e=this.slideWidth*this.slideCount;return e},currentPerPage:function(){return!this.perPageCustom||this.$isServer?this.perPage:this.getBreakpointSlidesPerPage(this.perPageCustom,this.browserWidth)},currentOffset:function(){var e=this.currentPage,t=this.slideWidth,n=this.dragOffset,i=this.scrollPerPage?e*t*this.currentPerPage:e*t;return(i+n)*-1},isHidden:function(){return this.carouselWidth<=0},pageCount:function(){var e=this.slideCount,t=this.currentPerPage;if(this.scrollPerPage){var n=Math.ceil(e/t);return n<1?1:n}return e-(this.currentPerPage-1)},transitionStyle:function(){return this.speed/1e3+"s "+this.easing+" transform"}},methods:{advancePage:function(e){e&&"backward"===e&&this.canAdvanceBackward?this.goToPage(this.currentPage-1):(!e||e&&"backward"!==e)&&this.canAdvanceForward&&this.goToPage(this.currentPage+1)},calculateSlideWidth:function(){var e=this.carouselWidth,t=this.currentPerPage;return this.slideWidth=e/t,this.setChildSlideWidth(this.slideWidth),this.slideWidth},getBreakpointSlidesPerPage:function(e,t){var n=e.sort(function(e,t){var n=e[0]>t[0]?-1:1;return n}),i=n.filter(function(e){var n=t>=e[0];return n}),r=i[0]&&i[0][1];return r||this.perPage},getBrowserWidth:function(){return this.browserWidth=window.innerWidth,this.browserWidth},getCarouselWidth:function(){return this.carouselWidth=this.$el&&this.$el.clientWidth||0,this.carouselWidth},getSlideCount:function(){return this.$slots&&this.$slots.default&&this.$slots.default.length||0},goToPage:function(e){e>=0&&e<=this.pageCount&&(this.currentPage=e)},handleMousedown:function(e){e.touches||e.preventDefault(),this.mousedown=!0,this.dragStartX="ontouchstart"in window?e.touches[0].clientX:e.clientX,"ontouchstart"in window?this.$el.addEventListener("touchmove",this.handleMousemove):this.$el.addEventListener("mousemove",this.handleMousemove)},handleMouseup:function(){this.mousedown=!1,this.dragOffset=0,"ontouchstart"in window?this.$el.removeEventListener("touchmove",this.handleMousemove):this.$el.removeEventListener("mousemove",this.handleMousemove)},handleMousemove:function(e){if(this.mousedown){var t="ontouchstart"in window?e.touches[0].clientX:e.clientX,n=this.dragStartX-t;this.dragOffset=n,this.dragOffset>=this.slideWidth/2?(this.handleMouseup(),this.advancePage()):this.dragOffset<=this.slideWidth/2*-1&&(this.mousedown=!1,this.handleMouseup(),this.advancePage("backward"))}},handleResize:function(){this.getBrowserWidth(),this.recomputeCarouselWidth()},pollForWidth:function(){var e=this;this.pollInterval||(this.pollInterval=setInterval(function(){e.getCarouselWidth()>0&&(e.recomputeCarouselWidth(),clearInterval(e.pollInterval))},100))},recomputeCarouselWidth:function(){this.getCarouselWidth(),this.calculateSlideWidth(),this.setCurrentPageInBounds()},setChildSlideWidth:function(e){this.$slots.default&&this.$slots.default.forEach(function(t){var n=t;n&&n.child&&(n.child.width=e)})},setCurrentPageInBounds:function(){if(!this.canAdvanceForward){var e=this.pageCount-1;this.currentPage=e>=0?e:0}}},mounted:function(){this.$isServer||(this.getBrowserWidth(),window.addEventListener("resize",(0,a.default)(this.handleResize,16)),"ontouchstart"in window?(this.$el.addEventListener("touchstart",this.handleMousedown),this.$el.addEventListener("touchend",this.handleMouseup)):(this.$el.addEventListener("mousedown",this.handleMousedown),this.$el.addEventListener("mouseup",this.handleMouseup))),this.slideCount=this.getSlideCount(),this.recomputeCarouselWidth(),this.isHidden&&this.pollForWidth()},destroyed:function(){this.$isServer||window.removeEventListener("resize",this.getBrowserWidth)}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,n){var i=void 0;return function(){var r=void 0,a=function(){i=null,n||e.apply(r)},o=n&&!i;clearTimeout(i),i=setTimeout(a,t),o&&e.apply(r)}};t.default=n},function(e,t,n){var i,r;n(9),i=n(11);var a=n(12);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-fe83c770",e.exports=i},function(e,t,n){var i=n(10);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".disabled[data-v-fe83c770]{opacity:.5;cursor:default}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"navigation",data:function(){return{parentContainer:this.$parent}},computed:{canAdvanceForward:function(){return this.parentContainer.canAdvanceForward||!1},canAdvanceBackward:function(){return this.parentContainer.canAdvanceBackward||!1}},methods:{triggerPageAdvance:function(e){e?this.$parent.advancePage(e):this.$parent.advancePage()}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navigation"},[n("a",{staticClass:"next",class:{disabled:!e.canAdvanceBackward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance()}}},[e._v("Prev")]),e._v(" "),n("a",{staticClass:"prev",class:{disabled:!e.canAdvanceForward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance("backward")}}},[e._v("Next")])])},staticRenderFns:[]}},function(e,t,n){var i,r;n(14),i=n(16);var a=n(17);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-7f1316ce",e.exports=i},function(e,t,n){var i=n(15);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".pagination[data-v-7f1316ce]{width:100%;float:left;text-align:center}.dot-container[data-v-7f1316ce]{display:inline-block;margin:0 auto}.dot[data-v-7f1316ce]{float:left;cursor:pointer}.dot-inner[data-v-7f1316ce]{border-radius:100%}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"pagination",data:function(){return{parentContainer:this.$parent}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"pagination"},[n("div",{staticClass:"dot-container"},e._l(e.parentContainer.pageCount,function(t,i){return n("div",{staticClass:"dot",style:"\n margin-top: "+2*e.parentContainer.paginationPadding+"px;\n padding: "+e.parentContainer.paginationPadding+"px;\n ",on:{click:function(t){e.parentContainer.goToPage(i)}}},[n("div",{staticClass:"dot-inner",style:"\n width: "+e.parentContainer.paginationSize+"px;\n height: "+e.parentContainer.paginationSize+"px;\n background: "+(i===e.parentContainer.currentPage?e.parentContainer.paginationActiveColor:e.parentContainer.paginationColor)+";\n "})])}))])},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"carousel"},[n("div",{staticClass:"carousel-inner",style:"\n width: "+e.carouselInnerWidth+"px;\n transform: translateX("+e.currentOffset+"px);\n transition: "+(!e.mousedown||e.isAnimating?e.transitionStyle:"none")+";\n "},[e._t("default")],2),e._v(" "),e.navigationEnabled?n("navigation"):e._e(),e._v(" "),e.paginationEnabled&&e.pageCount>0?n("pagination"):e._e()],1)},staticRenderFns:[]}},function(e,t,n){var i,r;n(20),i=n(22);var a=n(23);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-f5ced6a6",e.exports=i},function(e,t,n){var i=n(21);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".slide[data-v-f5ced6a6]{float:left;user-select:none;pointer-events:none}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"slide",data:function(){return{width:null}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"slide",style:"width: "+e.width+"px"},[e._t("default")],2)},staticRenderFns:[]}}])}); \ No newline at end of file diff --git a/docs/source/guide/index.md b/docs/source/guide/index.md index 95245f141..2954e06f6 100644 --- a/docs/source/guide/index.md +++ b/docs/source/guide/index.md @@ -16,7 +16,7 @@ You may install Vue Carousel globally: import Vue from 'vue'; import VueCarousel from '@ssense/vue-carousel'; -Vue.use(VueCarousel.default); +Vue.use(VueCarousel); ``` This will make **<carousel>** and **<slide>** available to all components within your Vue app. diff --git a/docs/themes/vue/source/js/vue-carousel.min.js b/docs/themes/vue/source/js/vue-carousel.min.js index 25985de98..58af928ac 100644 --- a/docs/themes/vue/source/js/vue-carousel.min.js +++ b/docs/themes/vue/source/js/vue-carousel.min.js @@ -3,4 +3,4 @@ * (c) 2017 todd.beauchamp@ssense.com * https://github.com/ssense/vue-carousel#readme */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueCarousel=t():e.VueCarousel=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";var i=n(1),r=n(19),a=function(e){e.component("carousel",i),e.component("slide",r)};e.exports={default:a,Carousel:i,Slide:r}},function(e,t,n){var i,r;n(2),i=n(6);var a=n(18);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-3e9da494",e.exports=i},function(e,t,n){var i=n(3);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".carousel[data-v-3e9da494]{width:100%;position:relative;overflow:hidden}.carousel-inner[data-v-3e9da494]{backface-visibility:hidden}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&m.splice(t,1)}function s(e){var t=document.createElement("style");return t.type="text/css",a(e,t),t}function d(e,t){var n,i,r;if(t.singleton){var a=g++;n=v||(v=s(t)),i=u.bind(null,n,a,!1),r=u.bind(null,n,a,!0)}else n=s(t),i=c.bind(null,n),r=function(){o(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}function u(e,t,n,i){var r=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=C(t,r);else{var a=document.createTextNode(r),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(a,o[t]):e.appendChild(a)}}function c(e,t){var n=t.css,i=t.media,r=t.sourceMap;if(i&&e.setAttribute("media",i),r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var l={},f=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},h=f(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),p=f(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,g=0,m=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=r(e);return i(n,t),function(e){for(var a=[],o=0;o0},carouselInnerWidth:function(){var e=this.slideWidth*this.slideCount;return e},currentPerPage:function(){return!this.perPageCustom||this.$isServer?this.perPage:this.getBreakpointSlidesPerPage(this.perPageCustom,this.browserWidth)},currentOffset:function(){var e=this.currentPage,t=this.slideWidth,n=this.dragOffset,i=this.scrollPerPage?e*t*this.currentPerPage:e*t;return(i+n)*-1},isHidden:function(){return this.carouselWidth<=0},pageCount:function(){var e=this.slideCount,t=this.currentPerPage;if(this.scrollPerPage){var n=Math.ceil(e/t);return n<1?1:n}return e-(this.currentPerPage-1)},transitionStyle:function(){return this.speed/1e3+"s "+this.easing+" transform"}},methods:{advancePage:function(e){e&&"backward"===e&&this.canAdvanceBackward?this.goToPage(this.currentPage-1):(!e||e&&"backward"!==e)&&this.canAdvanceForward&&this.goToPage(this.currentPage+1)},calculateSlideWidth:function(){var e=this.carouselWidth,t=this.currentPerPage;return this.slideWidth=e/t,this.setChildSlideWidth(this.slideWidth),this.slideWidth},getBreakpointSlidesPerPage:function(e,t){var n=e.sort(function(e,t){var n=e[0]>t[0]?-1:1;return n}),i=n.filter(function(e){var n=t>=e[0];return n}),r=i[0]&&i[0][1];return r||this.perPage},getBrowserWidth:function(){return this.browserWidth=window.innerWidth,this.browserWidth},getCarouselWidth:function(){return this.carouselWidth=this.$el&&this.$el.clientWidth||0,this.carouselWidth},getSlideCount:function(){return this.$slots&&this.$slots.default&&this.$slots.default.length||0},goToPage:function(e){e>=0&&e<=this.pageCount&&(this.currentPage=e)},handleMousedown:function(e){e.touches||e.preventDefault(),this.mousedown=!0,this.dragStartX="ontouchstart"in window?e.touches[0].clientX:e.clientX,"ontouchstart"in window?this.$el.addEventListener("touchmove",this.handleMousemove):this.$el.addEventListener("mousemove",this.handleMousemove)},handleMouseup:function(){this.mousedown=!1,this.dragOffset=0,"ontouchstart"in window?this.$el.removeEventListener("touchmove",this.handleMousemove):this.$el.removeEventListener("mousemove",this.handleMousemove)},handleMousemove:function(e){if(this.mousedown){var t="ontouchstart"in window?e.touches[0].clientX:e.clientX,n=this.dragStartX-t;this.dragOffset=n,this.dragOffset>=this.slideWidth/2?(this.handleMouseup(),this.advancePage()):this.dragOffset<=this.slideWidth/2*-1&&(this.mousedown=!1,this.handleMouseup(),this.advancePage("backward"))}},handleResize:function(){this.getBrowserWidth(),this.recomputeCarouselWidth()},pollForWidth:function(){var e=this;this.pollInterval||(this.pollInterval=setInterval(function(){e.getCarouselWidth()>0&&(e.recomputeCarouselWidth(),clearInterval(e.pollInterval))},100))},recomputeCarouselWidth:function(){this.getCarouselWidth(),this.calculateSlideWidth(),this.setCurrentPageInBounds()},setChildSlideWidth:function(e){this.$slots.default&&this.$slots.default.forEach(function(t){var n=t;n.child.width=e})},setCurrentPageInBounds:function(){if(!this.canAdvanceForward){var e=this.pageCount-1;this.currentPage=e>=0?e:0}}},mounted:function(){this.$isServer||(this.getBrowserWidth(),window.addEventListener("resize",(0,a.default)(this.handleResize,16)),"ontouchstart"in window?(this.$el.addEventListener("touchstart",this.handleMousedown),this.$el.addEventListener("touchend",this.handleMouseup)):(this.$el.addEventListener("mousedown",this.handleMousedown),this.$el.addEventListener("mouseup",this.handleMouseup))),this.slideCount=this.getSlideCount(),this.recomputeCarouselWidth(),this.isHidden&&this.pollForWidth()},destroyed:function(){this.$isServer||window.removeEventListener("resize",this.getBrowserWidth)}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,n){var i=void 0;return function(){var r=void 0,a=function(){i=null,n||e.apply(r)},o=n&&!i;clearTimeout(i),i=setTimeout(a,t),o&&e.apply(r)}};t.default=n},function(e,t,n){var i,r;n(9),i=n(11);var a=n(12);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-fe83c770",e.exports=i},function(e,t,n){var i=n(10);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".disabled[data-v-fe83c770]{opacity:.5;cursor:default}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"navigation",data:function(){return{parentContainer:this.$parent}},computed:{canAdvanceForward:function(){return this.parentContainer.canAdvanceForward||!1},canAdvanceBackward:function(){return this.parentContainer.canAdvanceBackward||!1}},methods:{triggerPageAdvance:function(e){e?this.$parent.advancePage(e):this.$parent.advancePage()}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navigation"},[n("a",{staticClass:"next",class:{disabled:!e.canAdvanceBackward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance()}}},[e._v("Prev")]),e._v(" "),n("a",{staticClass:"prev",class:{disabled:!e.canAdvanceForward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance("backward")}}},[e._v("Next")])])},staticRenderFns:[]}},function(e,t,n){var i,r;n(14),i=n(16);var a=n(17);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-7f1316ce",e.exports=i},function(e,t,n){var i=n(15);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".pagination[data-v-7f1316ce]{width:100%;float:left;text-align:center}.dot-container[data-v-7f1316ce]{display:inline-block;margin:0 auto}.dot[data-v-7f1316ce]{float:left;cursor:pointer}.dot-inner[data-v-7f1316ce]{border-radius:100%}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"pagination",data:function(){return{parentContainer:this.$parent}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"pagination"},[n("div",{staticClass:"dot-container"},e._l(e.parentContainer.pageCount,function(t,i){return n("div",{staticClass:"dot",style:"\n margin-top: "+2*e.parentContainer.paginationPadding+"px;\n padding: "+e.parentContainer.paginationPadding+"px;\n ",on:{click:function(t){e.parentContainer.goToPage(i)}}},[n("div",{staticClass:"dot-inner",style:"\n width: "+e.parentContainer.paginationSize+"px;\n height: "+e.parentContainer.paginationSize+"px;\n background: "+(i===e.parentContainer.currentPage?e.parentContainer.paginationActiveColor:e.parentContainer.paginationColor)+";\n "})])}))])},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"carousel"},[n("div",{staticClass:"carousel-inner",style:"\n width: "+e.carouselInnerWidth+"px;\n transform: translateX("+e.currentOffset+"px);\n transition: "+(!e.mousedown||e.isAnimating?e.transitionStyle:"none")+";\n "},[e._t("default")],2),e._v(" "),e.navigationEnabled?n("navigation"):e._e(),e._v(" "),e.paginationEnabled&&e.pageCount>0?n("pagination"):e._e()],1)},staticRenderFns:[]}},function(e,t,n){var i,r;n(20),i=n(22);var a=n(23);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-f5ced6a6",e.exports=i},function(e,t,n){var i=n(21);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".slide[data-v-f5ced6a6]{float:left;user-select:none;pointer-events:none}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"slide",data:function(){return{width:null}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"slide",style:"width: "+e.width+"px"},[e._t("default")],2)},staticRenderFns:[]}}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueCarousel=t():e.VueCarousel=t()}(this,function(){return function(e){function t(i){if(n[i])return n[i].exports;var r=n[i]={exports:{},id:i,loaded:!1};return e[i].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Slide=t.Carousel=void 0;var r=n(1),a=i(r),o=n(19),s=i(o),d=function(e){e.component("carousel",a.default),e.component("slide",s.default)};t.default={install:d},t.Carousel=a.default,t.Slide=s.default},function(e,t,n){var i,r;n(2),i=n(6);var a=n(18);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-3e9da494",e.exports=i},function(e,t,n){var i=n(3);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".carousel[data-v-3e9da494]{width:100%;position:relative;overflow:hidden}.carousel-inner[data-v-3e9da494]{backface-visibility:hidden}",""])},function(e,t){e.exports=function(){var e=[];return e.toString=function(){for(var e=[],t=0;t=0&&m.splice(t,1)}function s(e){var t=document.createElement("style");return t.type="text/css",a(e,t),t}function d(e,t){var n,i,r;if(t.singleton){var a=g++;n=v||(v=s(t)),i=u.bind(null,n,a,!1),r=u.bind(null,n,a,!0)}else n=s(t),i=l.bind(null,n),r=function(){o(n)};return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}function u(e,t,n,i){var r=n?"":i.css;if(e.styleSheet)e.styleSheet.cssText=C(t,r);else{var a=document.createTextNode(r),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(a,o[t]):e.appendChild(a)}}function l(e,t){var n=t.css,i=t.media,r=t.sourceMap;if(i&&e.setAttribute("media",i),r&&(n+="\n/*# sourceURL="+r.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */"),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}var c={},f=function(e){var t;return function(){return"undefined"==typeof t&&(t=e.apply(this,arguments)),t}},h=f(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),p=f(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,g=0,m=[];e.exports=function(e,t){t=t||{},"undefined"==typeof t.singleton&&(t.singleton=h()),"undefined"==typeof t.insertAt&&(t.insertAt="bottom");var n=r(e);return i(n,t),function(e){for(var a=[],o=0;o0},carouselInnerWidth:function(){var e=this.slideWidth*this.slideCount;return e},currentPerPage:function(){return!this.perPageCustom||this.$isServer?this.perPage:this.getBreakpointSlidesPerPage(this.perPageCustom,this.browserWidth)},currentOffset:function(){var e=this.currentPage,t=this.slideWidth,n=this.dragOffset,i=this.scrollPerPage?e*t*this.currentPerPage:e*t;return(i+n)*-1},isHidden:function(){return this.carouselWidth<=0},pageCount:function(){var e=this.slideCount,t=this.currentPerPage;if(this.scrollPerPage){var n=Math.ceil(e/t);return n<1?1:n}return e-(this.currentPerPage-1)},transitionStyle:function(){return this.speed/1e3+"s "+this.easing+" transform"}},methods:{advancePage:function(e){e&&"backward"===e&&this.canAdvanceBackward?this.goToPage(this.currentPage-1):(!e||e&&"backward"!==e)&&this.canAdvanceForward&&this.goToPage(this.currentPage+1)},calculateSlideWidth:function(){var e=this.carouselWidth,t=this.currentPerPage;return this.slideWidth=e/t,this.setChildSlideWidth(this.slideWidth),this.slideWidth},getBreakpointSlidesPerPage:function(e,t){var n=e.sort(function(e,t){var n=e[0]>t[0]?-1:1;return n}),i=n.filter(function(e){var n=t>=e[0];return n}),r=i[0]&&i[0][1];return r||this.perPage},getBrowserWidth:function(){return this.browserWidth=window.innerWidth,this.browserWidth},getCarouselWidth:function(){return this.carouselWidth=this.$el&&this.$el.clientWidth||0,this.carouselWidth},getSlideCount:function(){return this.$slots&&this.$slots.default&&this.$slots.default.length||0},goToPage:function(e){e>=0&&e<=this.pageCount&&(this.currentPage=e)},handleMousedown:function(e){e.touches||e.preventDefault(),this.mousedown=!0,this.dragStartX="ontouchstart"in window?e.touches[0].clientX:e.clientX,"ontouchstart"in window?this.$el.addEventListener("touchmove",this.handleMousemove):this.$el.addEventListener("mousemove",this.handleMousemove)},handleMouseup:function(){this.mousedown=!1,this.dragOffset=0,"ontouchstart"in window?this.$el.removeEventListener("touchmove",this.handleMousemove):this.$el.removeEventListener("mousemove",this.handleMousemove)},handleMousemove:function(e){if(this.mousedown){var t="ontouchstart"in window?e.touches[0].clientX:e.clientX,n=this.dragStartX-t;this.dragOffset=n,this.dragOffset>=this.slideWidth/2?(this.handleMouseup(),this.advancePage()):this.dragOffset<=this.slideWidth/2*-1&&(this.mousedown=!1,this.handleMouseup(),this.advancePage("backward"))}},handleResize:function(){this.getBrowserWidth(),this.recomputeCarouselWidth()},pollForWidth:function(){var e=this;this.pollInterval||(this.pollInterval=setInterval(function(){e.getCarouselWidth()>0&&(e.recomputeCarouselWidth(),clearInterval(e.pollInterval))},100))},recomputeCarouselWidth:function(){this.getCarouselWidth(),this.calculateSlideWidth(),this.setCurrentPageInBounds()},setChildSlideWidth:function(e){this.$slots.default&&this.$slots.default.forEach(function(t){var n=t;n&&n.child&&(n.child.width=e)})},setCurrentPageInBounds:function(){if(!this.canAdvanceForward){var e=this.pageCount-1;this.currentPage=e>=0?e:0}}},mounted:function(){this.$isServer||(this.getBrowserWidth(),window.addEventListener("resize",(0,a.default)(this.handleResize,16)),"ontouchstart"in window?(this.$el.addEventListener("touchstart",this.handleMousedown),this.$el.addEventListener("touchend",this.handleMouseup)):(this.$el.addEventListener("mousedown",this.handleMousedown),this.$el.addEventListener("mouseup",this.handleMouseup))),this.slideCount=this.getSlideCount(),this.recomputeCarouselWidth(),this.isHidden&&this.pollForWidth()},destroyed:function(){this.$isServer||window.removeEventListener("resize",this.getBrowserWidth)}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t,n){var i=void 0;return function(){var r=void 0,a=function(){i=null,n||e.apply(r)},o=n&&!i;clearTimeout(i),i=setTimeout(a,t),o&&e.apply(r)}};t.default=n},function(e,t,n){var i,r;n(9),i=n(11);var a=n(12);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-fe83c770",e.exports=i},function(e,t,n){var i=n(10);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".disabled[data-v-fe83c770]{opacity:.5;cursor:default}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"navigation",data:function(){return{parentContainer:this.$parent}},computed:{canAdvanceForward:function(){return this.parentContainer.canAdvanceForward||!1},canAdvanceBackward:function(){return this.parentContainer.canAdvanceBackward||!1}},methods:{triggerPageAdvance:function(e){e?this.$parent.advancePage(e):this.$parent.advancePage()}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"navigation"},[n("a",{staticClass:"next",class:{disabled:!e.canAdvanceBackward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance()}}},[e._v("Prev")]),e._v(" "),n("a",{staticClass:"prev",class:{disabled:!e.canAdvanceForward},attrs:{href:"#"},on:{click:function(t){t.preventDefault(),e.triggerPageAdvance("backward")}}},[e._v("Next")])])},staticRenderFns:[]}},function(e,t,n){var i,r;n(14),i=n(16);var a=n(17);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-7f1316ce",e.exports=i},function(e,t,n){var i=n(15);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".pagination[data-v-7f1316ce]{width:100%;float:left;text-align:center}.dot-container[data-v-7f1316ce]{display:inline-block;margin:0 auto}.dot[data-v-7f1316ce]{float:left;cursor:pointer}.dot-inner[data-v-7f1316ce]{border-radius:100%}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"pagination",data:function(){return{parentContainer:this.$parent}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"pagination"},[n("div",{staticClass:"dot-container"},e._l(e.parentContainer.pageCount,function(t,i){return n("div",{staticClass:"dot",style:"\n margin-top: "+2*e.parentContainer.paginationPadding+"px;\n padding: "+e.parentContainer.paginationPadding+"px;\n ",on:{click:function(t){e.parentContainer.goToPage(i)}}},[n("div",{staticClass:"dot-inner",style:"\n width: "+e.parentContainer.paginationSize+"px;\n height: "+e.parentContainer.paginationSize+"px;\n background: "+(i===e.parentContainer.currentPage?e.parentContainer.paginationActiveColor:e.parentContainer.paginationColor)+";\n "})])}))])},staticRenderFns:[]}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"carousel"},[n("div",{staticClass:"carousel-inner",style:"\n width: "+e.carouselInnerWidth+"px;\n transform: translateX("+e.currentOffset+"px);\n transition: "+(!e.mousedown||e.isAnimating?e.transitionStyle:"none")+";\n "},[e._t("default")],2),e._v(" "),e.navigationEnabled?n("navigation"):e._e(),e._v(" "),e.paginationEnabled&&e.pageCount>0?n("pagination"):e._e()],1)},staticRenderFns:[]}},function(e,t,n){var i,r;n(20),i=n(22);var a=n(23);r=i=i||{},"object"!=typeof i.default&&"function"!=typeof i.default||(r=i=i.default),"function"==typeof r&&(r=r.options),r.render=a.render,r.staticRenderFns=a.staticRenderFns,r._scopeId="data-v-f5ced6a6",e.exports=i},function(e,t,n){var i=n(21);"string"==typeof i&&(i=[[e.id,i,""]]);n(5)(i,{});i.locals&&(e.exports=i.locals)},function(e,t,n){t=e.exports=n(4)(),t.push([e.id,".slide[data-v-f5ced6a6]{float:left;user-select:none;pointer-events:none}",""])},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={name:"slide",data:function(){return{width:null}}}},function(e,t){e.exports={render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"slide",style:"width: "+e.width+"px"},[e._t("default")],2)},staticRenderFns:[]}}])}); \ No newline at end of file diff --git a/package.json b/package.json index 00fd69849..346375890 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "@ssense/vue-carousel", - "version": "0.4.2", + "version": "0.4.3", "description": "A flexible, responsive, touch-friendly carousel for Vue.js", - "main": "src/index.js", + "main": "dist/vue-carousel.min.js", "scripts": { "build": "webpack --config config/webpack.min.conf.js && npm run updateDocAssets", "coveralls": "cat coverage/client/lcov.info | ./node_modules/.bin/coveralls", diff --git a/src/Carousel.vue b/src/Carousel.vue index 6fdc8e56e..98caf0bc1 100644 --- a/src/Carousel.vue +++ b/src/Carousel.vue @@ -380,7 +380,9 @@ if (this.$slots.default) { this.$slots.default.forEach((child) => { const slotChild = child - slotChild.child.width = width + if (slotChild && slotChild.child) { + slotChild.child.width = width + } }) } }, diff --git a/src/index.js b/src/index.js index 47eda10b0..cf73dc5f1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,16 @@ -/* eslint-disable */ +import Carousel from "./Carousel.vue" +import Slide from "./Slide.vue" -var Carousel = require("./Carousel.vue") -var Slide = require("./Slide.vue") - -var install = function(Vue) { +const install = (Vue) => { Vue.component("carousel", Carousel) Vue.component("slide", Slide) } -module.exports = { - 'default': install, - 'Carousel': Carousel, - 'Slide': Slide -}; +export default { + install, +} + +export { + Carousel, + Slide +}