UNPKG

@cqmcui/cqmcui

Version:

轻量级移动端 Vue2、Vue3 组件库(支持小程序开发)

62 lines (61 loc) 1.82 kB
import { toRefs, reactive, computed, openBlock, createElementBlock, createElementVNode, normalizeClass, renderSlot } from "vue"; import { c as createComponent } from "./component-81a4c1d0.js"; import { _ as _export_sfc } from "./_plugin-vue_export-helper-cc2b3d55.js"; import "../locale/lang"; const { componentName, create } = createComponent("animate"); const _sfc_main = create({ props: { type: { type: String, default: "" }, action: { type: String, default: "initial" }, loop: { type: Boolean, default: false } }, emits: ["click"], setup(props, { emit }) { const { type, loop, action } = toRefs(props); const state = reactive({ clicked: false }); let classes = computed(() => { const prefixCls = componentName; return { "cqmc-animate__container": true, [`${prefixCls}-${type.value}`]: action.value === "initial" || state.clicked ? type.value : false, loop: loop.value }; }); const handleClick = (event) => { state.clicked = true; if (!loop.value) { setTimeout(() => { state.clicked = false; }, 1e3); } emit("click", event); }; return { ...toRefs(state), classes, handleClick }; } }); const _hoisted_1 = { class: "cqmc-animate" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("view", _hoisted_1, [ createElementVNode("view", { class: normalizeClass(_ctx.classes), onClick: _cache[0] || (_cache[0] = (...args) => _ctx.handleClick && _ctx.handleClick(...args)) }, [ renderSlot(_ctx.$slots, "default") ], 2) ]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index as default };