@aplus-frontend/ui
Version:
44 lines (43 loc) • 1.23 kB
JavaScript
import { defineComponent as b, getCurrentInstance as v, ref as d, onMounted as p, onBeforeUnmount as x, computed as h, unref as z, renderSlot as g } from "vue";
import { useThrottleFn as R } from "@vueuse/core";
import "../hooks/index.mjs";
import { useResize as S } from "../hooks/useResize.mjs";
const B = /* @__PURE__ */ b({
name: "ResizeObserver",
__name: "index",
props: {
onResize: { type: Function },
throttle: { type: [Boolean, Number], default: 16 }
},
setup(n, { expose: l }) {
const i = n.throttle == !0 ? 16 : n.throttle, u = R(m, i), { observe: f, unobserve: a } = S(), r = v();
let t = d(!1);
function s() {
if (t.value)
return;
const e = r?.proxy?.$el;
e?.nextElementSibling && (f(e.nextElementSibling, u), t.value = !0);
}
function o() {
if (t.value) {
const e = r?.proxy?.$el;
e?.nextElementSibling && (a(e.nextElementSibling), t.value = !1);
}
}
function m(e) {
n.onResize(e) === !1 && o();
}
return p(() => {
s();
}), x(() => {
o();
}), l({
visible: h(() => z(t)),
cancel: o,
resume: s
}), (e, c) => g(e.$slots, "default");
}
});
export {
B as default
};