50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
|
import {
|
||
|
IN_BROWSER,
|
||
|
refElement
|
||
|
} from "./chunk-I4KGD5X4.js";
|
||
|
import {
|
||
|
onBeforeUnmount,
|
||
|
readonly,
|
||
|
ref,
|
||
|
watch
|
||
|
} from "./chunk-PD2AWGJV.js";
|
||
|
|
||
|
// node_modules/vuetify/lib/composables/resizeObserver.mjs
|
||
|
function useResizeObserver(callback) {
|
||
|
let box = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "content";
|
||
|
const resizeRef = ref();
|
||
|
const contentRect = ref();
|
||
|
if (IN_BROWSER) {
|
||
|
const observer = new ResizeObserver((entries) => {
|
||
|
callback == null ? void 0 : callback(entries, observer);
|
||
|
if (!entries.length) return;
|
||
|
if (box === "content") {
|
||
|
contentRect.value = entries[0].contentRect;
|
||
|
} else {
|
||
|
contentRect.value = entries[0].target.getBoundingClientRect();
|
||
|
}
|
||
|
});
|
||
|
onBeforeUnmount(() => {
|
||
|
observer.disconnect();
|
||
|
});
|
||
|
watch(resizeRef, (newValue, oldValue) => {
|
||
|
if (oldValue) {
|
||
|
observer.unobserve(refElement(oldValue));
|
||
|
contentRect.value = void 0;
|
||
|
}
|
||
|
if (newValue) observer.observe(refElement(newValue));
|
||
|
}, {
|
||
|
flush: "post"
|
||
|
});
|
||
|
}
|
||
|
return {
|
||
|
resizeRef,
|
||
|
contentRect: readonly(contentRect)
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export {
|
||
|
useResizeObserver
|
||
|
};
|
||
|
//# sourceMappingURL=chunk-6MYZNPKW.js.map
|