dk-plus
Version:
38 lines (37 loc) • 1.23 kB
JavaScript
import { createApp as c } from "vue";
import u from "../../../dkloading/src/index2.js";
const g = () => {
const a = (o, t) => {
const e = (i) => t.value[i], n = (i) => e(i) || o.getAttribute(`dk-loading-${i}`) || "";
return {
visible: !!t.value,
text: n("text"),
textSize: n("textSize"),
color: n("color"),
background: n("background"),
spinner: n("spinner"),
spinnerSize: n("spinnerSize"),
flexDirection: n("flexDirection")
};
}, r = (o, t) => {
o.originalPosition !== "absolute" && o.originalPosition !== "fixed" && (o.style.position = "relative");
const e = a(o, t), n = c(u, e), i = n.mount(
document.createElement("div")
);
o.vm = i, o.loadingInstance = n, o.appendChild(i.$el);
}, s = (o) => {
!o.loadingInstance || (o.style.position = o.originalPosition, o.removeChild(o.vm.$el), o.loadingInstance.unmount(), o.loadingInstance = null);
};
return {
mounted: (o, t) => {
const e = getComputedStyle(o).position || "static";
o.originalPosition = e, t.value && r(o, t);
},
updated: (o, t) => {
t.value !== t.oldValue && (t.value ? r(o, t) : s(o));
}
};
};
export {
g as DirectiveLoading
};