UNPKG

@aplus-frontend/ui

Version:

24 lines (23 loc) 457 B
import { isClient as t } from "@vueuse/core"; import { isFunction as i } from "lodash-unified"; const s = /* @__PURE__ */ new WeakMap(); let r; t && (r = new ResizeObserver((e) => { e.forEach((o) => { const n = s.get(o.target); i(n) && n(o); }); })); function a(e, o) { s.set(e, o), r?.observe(e); } function f(e) { s.has(e) && s.delete(e), r?.unobserve(e); } const u = () => ({ observe: a, unobserve: f }); export { u as useResize };