@scalar/api-client
Version:
the open source API testing client
25 lines (24 loc) • 651 B
JavaScript
import { ref as n } from "vue";
const l = 20, s = 100, I = 0, i = 15, r = 60, c = 400, A = c / l, M = () => {
const e = n(s), o = n(0), t = n(!1), a = n(), u = () => {
clearInterval(a.value), a.value = void 0, e.value = s, t.value = !1;
}, v = () => {
t.value ? e.value -= (e.value - i) / r : e.value -= o.value / A, e.value <= I && u();
};
return {
startLoading: () => {
if (a.value) {
t.value = !0;
return;
}
t.value = !0, a.value = setInterval(v, l);
},
stopLoading: () => {
o.value = e.value, t.value = !1;
},
percentage: e
};
};
export {
M as useLoadingAnimation
};