UNPKG

@gyenno/nutui-taro

Version:

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

68 lines (67 loc) 2.01 kB
import { toRefs, reactive, computed, openBlock, createElementBlock, createElementVNode, normalizeClass, normalizeStyle, renderSlot } from "vue"; import { c as createComponent } from "./component-25dcca32.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 }, duration: { type: [String, Number] } }, emits: ["click"], setup(props, { emit }) { const { type, loop, action } = toRefs(props); const state = reactive({ clicked: false }); let classes = computed(() => { const prefixCls = componentName; return { "nut-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: "nut-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)), style: normalizeStyle({ animationDuration: _ctx.duration ? `${_ctx.duration}ms` : void 0 }) }, [ renderSlot(_ctx.$slots, "default") ], 6) ]); } const index_taro = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { index_taro as default };