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

vue-carousel-card

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-carousel-card - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.npmignore

4

CHANGELOG.md
# 更新日志
## 1.0.2 (2019-9-25)
* 解决card item垂直居中的问题
## 1.0.1 (2019-3-14)

@@ -4,0 +8,0 @@

2

lib/vue-carousel-card.js

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

module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=function(t,e,n,i){var r,o=0;return"boolean"!=typeof e&&(i=n,n=e,e=void 0),function(){var s=this,a=Number(new Date)-o,c=arguments;function u(){o=Number(new Date),n.apply(s,c)}i&&!r&&u(),r&&clearTimeout(r),void 0===i&&a>t?u():!0!==e&&(r=setTimeout(i?function(){r=void 0}:u,void 0===i?t-a:t))}}},function(t,e,n){"use strict";(function(t){var n=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some(function(t,i){return t[0]===e&&(n=i,!0)}),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),i=this.__entries__[n];return i&&i[1]},e.prototype.set=function(e,n){var i=t(this.__entries__,e);~i?this.__entries__[i][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,i=t(n,e);~i&&n.splice(i,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,i=this.__entries__;n<i.length;n++){var r=i[n];t.call(e,r[1],r[0])}},e}()}(),i="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,r=void 0!==t&&t.Math===Math?t:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),o="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(r):function(t){return setTimeout(function(){return t(Date.now())},1e3/60)},s=2;var a=20,c=["top","right","bottom","left","width","height","size","weight"],u="undefined"!=typeof MutationObserver,h=function(){function t(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t,e){var n=!1,i=!1,r=0;function a(){n&&(n=!1,t()),i&&u()}function c(){o(a)}function u(){var t=Date.now();if(n){if(t-r<s)return;i=!0}else n=!0,i=!1,setTimeout(c,e);r=t}return u}(this.refresh.bind(this),a)}return t.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},t.prototype.removeObserver=function(t){var e=this.observers_,n=e.indexOf(t);~n&&e.splice(n,1),!e.length&&this.connected_&&this.disconnect_()},t.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},t.prototype.updateObservers_=function(){var t=this.observers_.filter(function(t){return t.gatherActive(),t.hasActive()});return t.forEach(function(t){return t.broadcastActive()}),t.length>0},t.prototype.connect_=function(){i&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),u?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){i&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;c.some(function(t){return!!~n.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),l=function(t,e){for(var n=0,i=Object.keys(e);n<i.length;n++){var r=i[n];Object.defineProperty(t,r,{value:e[r],enumerable:!1,writable:!1,configurable:!0})}return t},d=function(t){return t&&t.ownerDocument&&t.ownerDocument.defaultView||r},f=y(0,0,0,0);function v(t){return parseFloat(t)||0}function p(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return e.reduce(function(e,n){return e+v(t["border-"+n+"-width"])},0)}function m(t){var e=t.clientWidth,n=t.clientHeight;if(!e&&!n)return f;var i=d(t).getComputedStyle(t),r=function(t){for(var e={},n=0,i=["top","right","bottom","left"];n<i.length;n++){var r=i[n],o=t["padding-"+r];e[r]=v(o)}return e}(i),o=r.left+r.right,s=r.top+r.bottom,a=v(i.width),c=v(i.height);if("border-box"===i.boxSizing&&(Math.round(a+o)!==e&&(a-=p(i,"left","right")+o),Math.round(c+s)!==n&&(c-=p(i,"top","bottom")+s)),!function(t){return t===d(t).document.documentElement}(t)){var u=Math.round(a+o)-e,h=Math.round(c+s)-n;1!==Math.abs(u)&&(a-=u),1!==Math.abs(h)&&(c-=h)}return y(r.left,r.top,a,c)}var _="undefined"!=typeof SVGGraphicsElement?function(t){return t instanceof d(t).SVGGraphicsElement}:function(t){return t instanceof d(t).SVGElement&&"function"==typeof t.getBBox};function b(t){return i?_(t)?function(t){var e=t.getBBox();return y(0,0,e.width,e.height)}(t):m(t):f}function y(t,e,n,i){return{x:t,y:e,width:n,height:i}}var g=function(){function t(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=y(0,0,0,0),this.target=t}return t.prototype.isActive=function(){var t=b(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},t.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},t}(),w=function(){return function(t,e){var n=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,s=Object.create(o.prototype);return l(s,{x:e,y:n,width:i,height:r,top:n,right:e+i,bottom:r+n,left:e}),s}(e);l(this,{target:t,contentRect:n})}}(),x=function(){function t(t,e,i){if(this.activeObservations_=[],this.observations_=new n,"function"!=typeof t)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=e,this.callbackCtx_=i}return t.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)||(e.set(t,new g(t)),this.controller_.addObserver(this),this.controller_.refresh())}},t.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)&&(e.delete(t),e.size||this.controller_.removeObserver(this))}},t.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},t.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(e){e.isActive()&&t.activeObservations_.push(e)})},t.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,e=this.activeObservations_.map(function(t){return new w(t.target,t.broadcastRect())});this.callback_.call(t,e,t),this.clearActive()}},t.prototype.clearActive=function(){this.activeObservations_.splice(0)},t.prototype.hasActive=function(){return this.activeObservations_.length>0},t}(),I="undefined"!=typeof WeakMap?new WeakMap:new n,E=function(){return function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=h.getInstance(),i=new x(e,n,this);I.set(this,i)}}();["observe","unobserve","disconnect"].forEach(function(t){E.prototype[t]=function(){var e;return(e=I.get(this))[t].apply(e,arguments)}});var O=void 0!==r.ResizeObserver?r.ResizeObserver:E;e.a=O}).call(this,n(3))},function(t,e,n){t.exports=n(4)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"carousel-card",on:{mouseenter:function(e){return e.stopPropagation(),t.handleMouseEnter(e)},mouseleave:function(e){return e.stopPropagation(),t.handleMouseLeave(e)}}},[n("div",{staticClass:"carousel-card-container",style:{height:t.height}},[n("transition",{attrs:{name:"carousel-card-arrow-left"}},["never"!==t.arrow?n("button",{directives:[{name:"show",rawName:"v-show",value:"always"===t.arrow||t.hover,expression:"arrow === 'always' || hover"}],staticClass:"carousel-card-arrow carousel-card-arrow-left",attrs:{type:"button"},on:{mouseenter:function(e){t.handleButtonEnter("left")},mouseleave:t.handleButtonLeave,click:function(e){e.stopPropagation(),t.throttledArrowClick(t.activeIndex-1)}}},[n("i")]):t._e()]),t._v(" "),n("transition",{attrs:{name:"carousel-card-arrow-right"}},["never"!==t.arrow?n("button",{directives:[{name:"show",rawName:"v-show",value:"always"===t.arrow||t.hover,expression:"arrow === 'always' || hover"}],staticClass:"carousel-card-arrow carousel-card-arrow-right",attrs:{type:"button"},on:{mouseenter:function(e){t.handleButtonEnter("right")},mouseleave:t.handleButtonLeave,click:function(e){e.stopPropagation(),t.throttledArrowClick(t.activeIndex+1)}}},[n("i")]):t._e()]),t._v(" "),t._t("default")],2),t._v(" "),"none"!==t.indicatorPosition?n("ul",{staticClass:"carousel-card-indicators",class:{"carousel-card-indicators-labels":t.hasLabel,"carousel-card-indicators-outside":"outside"===t.indicatorPosition||"card"===t.type}},t._l(t.items,function(e,i){return n("li",{key:i,staticClass:"carousel-card-indicator",class:{"is-active":i===t.activeIndex},on:{mouseenter:function(e){t.throttledIndicatorHover(i)},click:function(e){e.stopPropagation(),t.handleIndicatorClick(i)}}},[n("button",{staticClass:"carousel-card-button"},[t.hasLabel?n("span",{domProps:{textContent:t._s(e.label)}}):t._e()])])}),0):t._e()])};i._withStripped=!0;var r=n(0),o=n.n(r),s=n(1),a="undefined"==typeof window,c=function(t){var e=!0,n=!1,i=void 0;try{for(var r,o=t[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){var s=r.value.target._resizeListeners_||[];s.length&&s.forEach(function(t){return t()})}}catch(t){n=!0,i=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw i}}};function u(t,e,n,i,r,o,s,a){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,this.$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var h=u.render;u.render=function(t,e){return c.call(e),h(t,e)}}else{var l=u.beforeCreate;u.beforeCreate=l?[].concat(l,c):[c]}return{exports:t,options:u}}var h=u({name:"CarouselCard",props:{initialIndex:{type:Number,default:0},height:{type:String,default:"200"},trigger:{type:String,default:"hover"},autoplay:{type:Boolean,default:!0},interval:{type:Number,default:3e3},indicatorPosition:{type:String,default:"outside"},indicator:{type:Boolean,default:!0},arrow:{type:String,default:"hover"},type:String},data:function(){return{items:[],activeIndex:-1,containerWidth:0,timer:null,hover:!1}},computed:{hasLabel:function(){return this.items.some(function(t){return t.label.toString().length>0})}},watch:{items:function(t){t.length>0&&this.setActiveItem(this.initialIndex)},activeIndex:function(t,e){this.resetItemPosition(e),this.$emit("change",t,e)},autoplay:function(t){t?this.startTimer():this.pauseTimer()}},created:function(){var t=this;this.throttledArrowClick=o()(300,!0,function(e){t.setActiveItem(e)}),this.throttledIndicatorHover=o()(300,function(e){t.handleIndicatorHover(e)})},mounted:function(){var t=this;this.updateItems(),this.$nextTick(function(){!function(t,e){a||(t._resizeListeners_||(t._resizeListeners_=[],t.__ro__=new s.a(c),t.__ro__.observe(t)),t._resizeListeners_.push(e))}(t.$el,t.resetItemPosition),t.initialIndex<t.items.length&&t.initialIndex>=0&&(t.activeIndex=t.initialIndex),t.startTimer()})},beforeDestroy:function(){this.$el&&function(t,e){t&&t._resizeListeners_&&(t._resizeListeners_.splice(t._resizeListeners_.indexOf(e),1),t._resizeListeners_.length||t.__ro__.disconnect())}(this.$el,this.resetItemPosition)},methods:{handleMouseEnter:function(){this.hover=!0,this.pauseTimer()},handleMouseLeave:function(){this.hover=!1,this.startTimer()},itemInStage:function(t,e){var n=this.items.length;return e===n-1&&t.inStage&&this.items[0].active||t.inStage&&this.items[e+1]&&this.items[e+1].active?"left":!!(0===e&&t.inStage&&this.items[n-1].active||t.inStage&&this.items[e-1]&&this.items[e-1].active)&&"right"},handleButtonEnter:function(t){var e=this;this.items.forEach(function(n,i){t===e.itemInStage(n,i)&&(n.hover=!0)})},handleButtonLeave:function(){this.items.forEach(function(t){t.hover=!1})},updateItems:function(){this.items=this.$children.filter(function(t){return"CarouselCardItem"===t.$options.name})},resetItemPosition:function(t){var e=this;this.items.forEach(function(n,i){n.translateItem(i,e.activeIndex,t)})},playSlides:function(){this.activeIndex<this.items.length-1?this.activeIndex++:this.activeIndex=0},pauseTimer:function(){clearInterval(this.timer)},startTimer:function(){this.interval<=0||!this.autoplay||(this.timer=setInterval(this.playSlides,this.interval))},setActiveItem:function(t){if("string"==typeof t){var e=this.items.filter(function(e){return e.name===t});e.length>0&&(t=this.items.indexOf(e[0]))}if(t=Number(t),!isNaN(t)&&t===Math.floor(t)){var n=this.items.length,i=this.activeIndex;this.activeIndex=t<0?n-1:t>=n?0:t,i===this.activeIndex&&this.resetItemPosition(i)}},prev:function(){this.setActiveItem(this.activeIndex-1)},next:function(){this.setActiveItem(this.activeIndex+1)},handleIndicatorClick:function(t){this.activeIndex=t},handleIndicatorHover:function(t){"hover"===this.trigger&&t!==this.activeIndex&&(this.activeIndex=t)}}},i,[],!1,null,null,null);h.options.__file="src/carousel-card/src/main.vue";var l=h.exports;l.install=function(t){t.component(l.name,l)};var d=l,f=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"show",rawName:"v-show",value:t.ready,expression:"ready"}],staticClass:"carousel-card-item",class:{"is-active":t.active,"carousel-card-item-card":"card"===t.$parent.type,"is-in-stage":t.inStage,"is-hover":t.hover,"is-animating":t.animating},style:{msTransform:"translateX("+t.translate+"px) scale("+t.scale+")",webkitTransform:"translateX("+t.translate+"px) scale("+t.scale+")",transform:"translateX("+t.translate+"px) scale("+t.scale+")"},on:{click:t.handleItemClick}},["card"===t.$parent.type?n("div",{directives:[{name:"show",rawName:"v-show",value:!t.active,expression:"!active"}],staticClass:"carousel-card-mask"}):t._e(),t._v(" "),t._t("default")],2)};f._withStripped=!0;var v=u({name:"CarouselCardItem",props:{label:{type:[String,Number],default:""}},data:function(){return{hover:!1,translate:0,scale:1,active:!1,ready:!1,inStage:!1,animating:!1}},created:function(){this.updateItems()},destroyed:function(){this.updateItems()},methods:{processIndex:function(t,e,n){return 0===e&&t===n-1?-1:e===n-1&&0===t?n:t<e-1&&e-t>=n/2?n+1:t>e+1&&t-e>=n/2?-2:t},calculateTranslate:function(t,e,n){return this.inStage?n*(1.17*(t-e)+1)/4:t<e?-1.83*n/4:3.83*n/4},translateItem:function(t,e,n){var i=this.$parent.$el.offsetWidth,r=this.$parent.items.length;"card"!==this.$parent.type&&void 0!==n&&(this.animating=t===e||t===n),t!==e&&r>2&&(t=this.processIndex(t,e,r)),"card"===this.$parent.type?(this.inStage=Math.round(Math.abs(t-e))<=1,this.active=t===e,this.translate=this.calculateTranslate(t,e,i),this.scale=this.active?1:.83):(this.active=t===e,this.translate=i*(t-e)),this.ready=!0},handleItemClick:function(){var t=this.$parent;if(t&&"card"===t.type){var e=t.items.indexOf(this);t.setActiveItem(e)}},updateItems:function(){this.$parent&&this.$parent.updateItems()}}},f,[],!1,null,null,null);v.options.__file="src/carousel-card/src/item.vue";var p=v.exports;p.install=function(t){t.component(p.name,p)};var m=p;n.d(e,"CarouselCard",function(){return d}),n.d(e,"CarouselCardItem",function(){return m});var _=function(t){t.component(d.name,d),t.component(m.name,m)};"undefined"!=typeof window&&window.Vue&&_(window.Vue);e.default={install:_,CarouselCard:d,CarouselCardItem:m}}]).default;
module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=function(t,e,n,i){var r,o=0;return"boolean"!=typeof e&&(i=n,n=e,e=void 0),function(){var s=this,a=Number(new Date)-o,c=arguments;function u(){o=Number(new Date),n.apply(s,c)}i&&!r&&u(),r&&clearTimeout(r),void 0===i&&a>t?u():!0!==e&&(r=setTimeout(i?function(){r=void 0}:u,void 0===i?t-a:t))}}},function(t,e,n){"use strict";(function(t){var n=function(){if("undefined"!=typeof Map)return Map;function t(t,e){var n=-1;return t.some(function(t,i){return t[0]===e&&(n=i,!0)}),n}return function(){function e(){this.__entries__=[]}return Object.defineProperty(e.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),e.prototype.get=function(e){var n=t(this.__entries__,e),i=this.__entries__[n];return i&&i[1]},e.prototype.set=function(e,n){var i=t(this.__entries__,e);~i?this.__entries__[i][1]=n:this.__entries__.push([e,n])},e.prototype.delete=function(e){var n=this.__entries__,i=t(n,e);~i&&n.splice(i,1)},e.prototype.has=function(e){return!!~t(this.__entries__,e)},e.prototype.clear=function(){this.__entries__.splice(0)},e.prototype.forEach=function(t,e){void 0===e&&(e=null);for(var n=0,i=this.__entries__;n<i.length;n++){var r=i[n];t.call(e,r[1],r[0])}},e}()}(),i="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,r=void 0!==t&&t.Math===Math?t:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")(),o="function"==typeof requestAnimationFrame?requestAnimationFrame.bind(r):function(t){return setTimeout(function(){return t(Date.now())},1e3/60)},s=2;var a=20,c=["top","right","bottom","left","width","height","size","weight"],u="undefined"!=typeof MutationObserver,h=function(){function t(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=function(t,e){var n=!1,i=!1,r=0;function a(){n&&(n=!1,t()),i&&u()}function c(){o(a)}function u(){var t=Date.now();if(n){if(t-r<s)return;i=!0}else n=!0,i=!1,setTimeout(c,e);r=t}return u}(this.refresh.bind(this),a)}return t.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},t.prototype.removeObserver=function(t){var e=this.observers_,n=e.indexOf(t);~n&&e.splice(n,1),!e.length&&this.connected_&&this.disconnect_()},t.prototype.refresh=function(){this.updateObservers_()&&this.refresh()},t.prototype.updateObservers_=function(){var t=this.observers_.filter(function(t){return t.gatherActive(),t.hasActive()});return t.forEach(function(t){return t.broadcastActive()}),t.length>0},t.prototype.connect_=function(){i&&!this.connected_&&(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),u?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){i&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(t){var e=t.propertyName,n=void 0===e?"":e;c.some(function(t){return!!~n.indexOf(t)})&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t}(),l=function(t,e){for(var n=0,i=Object.keys(e);n<i.length;n++){var r=i[n];Object.defineProperty(t,r,{value:e[r],enumerable:!1,writable:!1,configurable:!0})}return t},d=function(t){return t&&t.ownerDocument&&t.ownerDocument.defaultView||r},f=y(0,0,0,0);function v(t){return parseFloat(t)||0}function p(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return e.reduce(function(e,n){return e+v(t["border-"+n+"-width"])},0)}function m(t){var e=t.clientWidth,n=t.clientHeight;if(!e&&!n)return f;var i=d(t).getComputedStyle(t),r=function(t){for(var e={},n=0,i=["top","right","bottom","left"];n<i.length;n++){var r=i[n],o=t["padding-"+r];e[r]=v(o)}return e}(i),o=r.left+r.right,s=r.top+r.bottom,a=v(i.width),c=v(i.height);if("border-box"===i.boxSizing&&(Math.round(a+o)!==e&&(a-=p(i,"left","right")+o),Math.round(c+s)!==n&&(c-=p(i,"top","bottom")+s)),!function(t){return t===d(t).document.documentElement}(t)){var u=Math.round(a+o)-e,h=Math.round(c+s)-n;1!==Math.abs(u)&&(a-=u),1!==Math.abs(h)&&(c-=h)}return y(r.left,r.top,a,c)}var _="undefined"!=typeof SVGGraphicsElement?function(t){return t instanceof d(t).SVGGraphicsElement}:function(t){return t instanceof d(t).SVGElement&&"function"==typeof t.getBBox};function b(t){return i?_(t)?function(t){var e=t.getBBox();return y(0,0,e.width,e.height)}(t):m(t):f}function y(t,e,n,i){return{x:t,y:e,width:n,height:i}}var g=function(){function t(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=y(0,0,0,0),this.target=t}return t.prototype.isActive=function(){var t=b(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},t.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},t}(),w=function(){return function(t,e){var n=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o="undefined"!=typeof DOMRectReadOnly?DOMRectReadOnly:Object,s=Object.create(o.prototype);return l(s,{x:e,y:n,width:i,height:r,top:n,right:e+i,bottom:r+n,left:e}),s}(e);l(this,{target:t,contentRect:n})}}(),x=function(){function t(t,e,i){if(this.activeObservations_=[],this.observations_=new n,"function"!=typeof t)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=e,this.callbackCtx_=i}return t.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)||(e.set(t,new g(t)),this.controller_.addObserver(this),this.controller_.refresh())}},t.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if("undefined"!=typeof Element&&Element instanceof Object){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var e=this.observations_;e.has(t)&&(e.delete(t),e.size||this.controller_.removeObserver(this))}},t.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},t.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(e){e.isActive()&&t.activeObservations_.push(e)})},t.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,e=this.activeObservations_.map(function(t){return new w(t.target,t.broadcastRect())});this.callback_.call(t,e,t),this.clearActive()}},t.prototype.clearActive=function(){this.activeObservations_.splice(0)},t.prototype.hasActive=function(){return this.activeObservations_.length>0},t}(),I="undefined"!=typeof WeakMap?new WeakMap:new n,E=function(){return function t(e){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=h.getInstance(),i=new x(e,n,this);I.set(this,i)}}();["observe","unobserve","disconnect"].forEach(function(t){E.prototype[t]=function(){var e;return(e=I.get(this))[t].apply(e,arguments)}});var O=void 0!==r.ResizeObserver?r.ResizeObserver:E;e.a=O}).call(this,n(3))},function(t,e,n){t.exports=n(4)},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"carousel-card",on:{mouseenter:function(e){return e.stopPropagation(),t.handleMouseEnter(e)},mouseleave:function(e){return e.stopPropagation(),t.handleMouseLeave(e)}}},[n("div",{staticClass:"carousel-card-container",style:{height:t.height}},[n("transition",{attrs:{name:"carousel-card-arrow-left"}},["never"!==t.arrow?n("button",{directives:[{name:"show",rawName:"v-show",value:"always"===t.arrow||t.hover,expression:"arrow === 'always' || hover"}],staticClass:"carousel-card-arrow carousel-card-arrow-left",attrs:{type:"button"},on:{mouseenter:function(e){t.handleButtonEnter("left")},mouseleave:t.handleButtonLeave,click:function(e){e.stopPropagation(),t.throttledArrowClick(t.activeIndex-1)}}},[n("i")]):t._e()]),t._v(" "),n("transition",{attrs:{name:"carousel-card-arrow-right"}},["never"!==t.arrow?n("button",{directives:[{name:"show",rawName:"v-show",value:"always"===t.arrow||t.hover,expression:"arrow === 'always' || hover"}],staticClass:"carousel-card-arrow carousel-card-arrow-right",attrs:{type:"button"},on:{mouseenter:function(e){t.handleButtonEnter("right")},mouseleave:t.handleButtonLeave,click:function(e){e.stopPropagation(),t.throttledArrowClick(t.activeIndex+1)}}},[n("i")]):t._e()]),t._v(" "),t._t("default")],2),t._v(" "),"none"!==t.indicatorPosition?n("ul",{staticClass:"carousel-card-indicators",class:{"carousel-card-indicators-labels":t.hasLabel,"carousel-card-indicators-outside":"outside"===t.indicatorPosition||"card"===t.type}},t._l(t.items,function(e,i){return n("li",{key:i,staticClass:"carousel-card-indicator",class:{"is-active":i===t.activeIndex},on:{mouseenter:function(e){t.throttledIndicatorHover(i)},click:function(e){e.stopPropagation(),t.handleIndicatorClick(i)}}},[n("button",{staticClass:"carousel-card-button"},[t.hasLabel?n("span",{domProps:{textContent:t._s(e.label)}}):t._e()])])}),0):t._e()])};i._withStripped=!0;var r=n(0),o=n.n(r),s=n(1),a="undefined"==typeof window,c=function(t){var e=!0,n=!1,i=void 0;try{for(var r,o=t[Symbol.iterator]();!(e=(r=o.next()).done);e=!0){var s=r.value.target._resizeListeners_||[];s.length&&s.forEach(function(t){return t()})}}catch(t){n=!0,i=t}finally{try{!e&&o.return&&o.return()}finally{if(n)throw i}}};function u(t,e,n,i,r,o,s,a){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),o&&(u._scopeId="data-v-"+o),s?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(s)},u._ssrRegister=c):r&&(c=a?function(){r.call(this,this.$root.$options.shadowRoot)}:r),c)if(u.functional){u._injectStyles=c;var h=u.render;u.render=function(t,e){return c.call(e),h(t,e)}}else{var l=u.beforeCreate;u.beforeCreate=l?[].concat(l,c):[c]}return{exports:t,options:u}}var h=u({name:"CarouselCard",props:{initialIndex:{type:Number,default:0},height:{type:String,default:"200"},trigger:{type:String,default:"hover"},autoplay:{type:Boolean,default:!0},interval:{type:Number,default:3e3},indicatorPosition:{type:String,default:"outside"},indicator:{type:Boolean,default:!0},arrow:{type:String,default:"hover"},type:String},data:function(){return{items:[],activeIndex:-1,containerWidth:0,timer:null,hover:!1}},computed:{hasLabel:function(){return this.items.some(function(t){return t.label.toString().length>0})}},watch:{items:function(t){t.length>0&&this.setActiveItem(this.initialIndex)},activeIndex:function(t,e){this.resetItemPosition(e),this.$emit("change",t,e)},autoplay:function(t){t?this.startTimer():this.pauseTimer()}},created:function(){var t=this;this.throttledArrowClick=o()(300,!0,function(e){t.setActiveItem(e)}),this.throttledIndicatorHover=o()(300,function(e){t.handleIndicatorHover(e)})},mounted:function(){var t=this;this.updateItems(),this.$nextTick(function(){!function(t,e){a||(t._resizeListeners_||(t._resizeListeners_=[],t.__ro__=new s.a(c),t.__ro__.observe(t)),t._resizeListeners_.push(e))}(t.$el,t.resetItemPosition),t.initialIndex<t.items.length&&t.initialIndex>=0&&(t.activeIndex=t.initialIndex),t.startTimer()})},beforeDestroy:function(){this.$el&&function(t,e){t&&t._resizeListeners_&&(t._resizeListeners_.splice(t._resizeListeners_.indexOf(e),1),t._resizeListeners_.length||t.__ro__.disconnect())}(this.$el,this.resetItemPosition)},methods:{handleMouseEnter:function(){this.hover=!0,this.pauseTimer()},handleMouseLeave:function(){this.hover=!1,this.startTimer()},itemInStage:function(t,e){var n=this.items.length;return e===n-1&&t.inStage&&this.items[0].active||t.inStage&&this.items[e+1]&&this.items[e+1].active?"left":!!(0===e&&t.inStage&&this.items[n-1].active||t.inStage&&this.items[e-1]&&this.items[e-1].active)&&"right"},handleButtonEnter:function(t){var e=this;this.items.forEach(function(n,i){t===e.itemInStage(n,i)&&(n.hover=!0)})},handleButtonLeave:function(){this.items.forEach(function(t){t.hover=!1})},updateItems:function(){this.items=this.$children.filter(function(t){return"CarouselCardItem"===t.$options.name})},resetItemPosition:function(t){var e=this;this.items.forEach(function(n,i){n.translateItem(i,e.activeIndex,t)})},playSlides:function(){this.activeIndex<this.items.length-1?this.activeIndex++:this.activeIndex=0},pauseTimer:function(){clearInterval(this.timer)},startTimer:function(){this.interval<=0||!this.autoplay||(this.timer=setInterval(this.playSlides,this.interval))},setActiveItem:function(t){if("string"==typeof t){var e=this.items.filter(function(e){return e.name===t});e.length>0&&(t=this.items.indexOf(e[0]))}if(t=Number(t),!isNaN(t)&&t===Math.floor(t)){var n=this.items.length,i=this.activeIndex;this.activeIndex=t<0?n-1:t>=n?0:t,i===this.activeIndex&&this.resetItemPosition(i)}},prev:function(){this.setActiveItem(this.activeIndex-1)},next:function(){this.setActiveItem(this.activeIndex+1)},handleIndicatorClick:function(t){this.activeIndex=t},handleIndicatorHover:function(t){"hover"===this.trigger&&t!==this.activeIndex&&(this.activeIndex=t)}}},i,[],!1,null,null,null);h.options.__file="src/carousel-card/src/main.vue";var l=h.exports;l.install=function(t){t.component(l.name,l)};var d=l,f=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"show",rawName:"v-show",value:t.ready,expression:"ready"}],staticClass:"carousel-card-item",class:{"is-active":t.active,"carousel-card-item-card":"card"===t.$parent.type,"is-in-stage":t.inStage,"is-hover":t.hover,"is-animating":t.animating},style:{msTransform:"translateX("+t.translate+"px) translateY(-50%) scale("+t.scale+")",webkitTransform:"translateX("+t.translate+"px) translateY(-50%) scale("+t.scale+")",transform:"translateX("+t.translate+"px) translateY(-50%) scale("+t.scale+")",top:"50%"},on:{click:t.handleItemClick}},["card"===t.$parent.type?n("div",{directives:[{name:"show",rawName:"v-show",value:!t.active,expression:"!active"}],staticClass:"carousel-card-mask"}):t._e(),t._v(" "),t._t("default")],2)};f._withStripped=!0;var v=u({name:"CarouselCardItem",props:{label:{type:[String,Number],default:""}},data:function(){return{hover:!1,translate:0,scale:1,active:!1,ready:!1,inStage:!1,animating:!1}},created:function(){this.updateItems()},destroyed:function(){this.updateItems()},methods:{processIndex:function(t,e,n){return 0===e&&t===n-1?-1:e===n-1&&0===t?n:t<e-1&&e-t>=n/2?n+1:t>e+1&&t-e>=n/2?-2:t},calculateTranslate:function(t,e,n){return this.inStage?n*(1.17*(t-e)+1)/4:t<e?-1.83*n/4:3.83*n/4},translateItem:function(t,e,n){var i=this.$parent.$el.offsetWidth,r=this.$parent.items.length;"card"!==this.$parent.type&&void 0!==n&&(this.animating=t===e||t===n),t!==e&&r>2&&(t=this.processIndex(t,e,r)),"card"===this.$parent.type?(this.inStage=Math.round(Math.abs(t-e))<=1,this.active=t===e,this.translate=this.calculateTranslate(t,e,i),this.scale=this.active?1:.83):(this.active=t===e,this.translate=i*(t-e)),this.ready=!0},handleItemClick:function(){var t=this.$parent;if(t&&"card"===t.type){var e=t.items.indexOf(this);t.setActiveItem(e)}},updateItems:function(){this.$parent&&this.$parent.updateItems()}}},f,[],!1,null,null,null);v.options.__file="src/carousel-card/src/item.vue";var p=v.exports;p.install=function(t){t.component(p.name,p)};var m=p;n.d(e,"CarouselCard",function(){return d}),n.d(e,"CarouselCardItem",function(){return m});var _=function(t){t.component(d.name,d),t.component(m.name,m)};"undefined"!=typeof window&&window.Vue&&_(window.Vue);e.default={install:_,CarouselCard:d,CarouselCardItem:m}}]).default;
{
"name": "vue-carousel-card",
"version": "1.0.1",
"version": "1.0.2",
"description": "vue轮播卡片组件(vue carousel card component)",

@@ -5,0 +5,0 @@ "author": "jekorx",

# vue-carousel-card
[![npm package](screenshot/version.svg)](https://www.npmjs.com/package/vue-carousel-card)
> vue轮播卡片组件(vue carousel card component)

@@ -4,0 +4,0 @@ ### 示例

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