UNPKG

winbox-ui-next

Version:

We Design Vue 2.0: A Vue.js 3 UI Library

67 lines (66 loc) 2.49 kB
"use strict"; var vue = require("vue"); var globalConfig = require("../_utils/global-config.js"); var context = require("./context.js"); var pluginVue_exportHelper = require("../_virtual/plugin-vue_export-helper"); const _sfc_main = vue.defineComponent({ name: "CarouselItem", setup() { const prefixCls = globalConfig.getPrefixCls("carousel-item"); const instance = vue.getCurrentInstance(); const instanceId = instance.uid; const context$1 = vue.inject(context.carouselInjectionKey); vue.onMounted(() => { if (context$1 == null ? void 0 : context$1.addItem) { context$1.addItem({ uid: instanceId }); } }); vue.onUnmounted(() => { if (context$1 == null ? void 0 : context$1.removeItem) { context$1.removeItem(instanceId); } }); const myIndexRef = vue.computed(() => { const items = (context$1 == null ? void 0 : context$1.items) || []; const index = items.findIndex((it) => it.uid === instanceId); return index; }); const cls = vue.computed(() => { const { previousIndex, animationName, slideDirection, mergedIndexes } = context$1; const index = myIndexRef.value; const { mergedPrevIndex, mergedNextIndex, mergedIndex } = mergedIndexes; return { [`${prefixCls}-prev`]: index === mergedPrevIndex, [`${prefixCls}-next`]: index === mergedNextIndex, [`${prefixCls}-current`]: index === mergedIndex, [`${prefixCls}-slide-in`]: animationName === "slide" && slideDirection && index === mergedIndex, [`${prefixCls}-slide-out`]: animationName === "slide" && slideDirection && index === previousIndex }; }); const animationStyle = vue.computed(() => { const { transitionTimingFunction, moveSpeed } = context$1; return { transitionTimingFunction, transitionDuration: `${moveSpeed}ms`, animationTimingFunction: transitionTimingFunction, animationDuration: `${moveSpeed}ms` }; }); return { cls, animationStyle }; } }); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createElementBlock("div", { class: vue.normalizeClass(_ctx.cls), style: vue.normalizeStyle(_ctx.animationStyle) }, [ vue.renderSlot(_ctx.$slots, "default") ], 6); } var CarouselItem = /* @__PURE__ */ pluginVue_exportHelper(_sfc_main, [["render", _sfc_render]]); module.exports = CarouselItem;