mine-h5-ui
Version:
一款轻量级、模块化基于 Vue3.x 的 H5 前端 UI 组件库 👍
25 lines (24 loc) • 682 B
JavaScript
import { ref as s, computed as m, watch as v } from "vue";
const w = ({ props: t, emit: l, modelValue: n }) => {
const a = s(t.startValue), o = m(() => t.thousand ? a.value.toLocaleString() : a.value), c = () => {
let e;
const u = (i) => {
e === void 0 && (e = i);
const r = i - e, d = ~~((t.endValue - t.startValue) * r / t.duration + t.startValue);
a.value = Math.min(d, t.endValue), r < t.duration ? window.requestAnimationFrame(u) : (n.value = !1, l("end"));
};
window.requestAnimationFrame(u);
};
return v(
n,
(e) => {
e && c();
},
{
immediate: !0
}
), { comValue: o };
};
export {
w as useHandler
};