UNPKG

xdesign-vue-next

Version:

XDesign Component for vue-next

34 lines (30 loc) 898 B
/** * xdesign v1.0.6 * (c) 2023 xdesign * @license MIT */ import { ref, onMounted, watch, onBeforeUnmount } from 'vue'; import observe from '../../_common/js/utils/observe.js'; function useCheckboxLazyLoad(labelRef, lazyLoad) { var ioObserver = ref(); var showCheckbox = ref(true); var handleLazyLoad = function handleLazyLoad() { if (!lazyLoad.value) return; showCheckbox.value = false; var io = observe(labelRef.value, null, function () { showCheckbox.value = true; }, 0); ioObserver.value = io; }; onMounted(handleLazyLoad); watch([lazyLoad, labelRef], handleLazyLoad); onBeforeUnmount(function () { if (!lazyLoad.value) return; ioObserver.value.unobserve(labelRef.value); }); return { showCheckbox: showCheckbox }; } export { useCheckboxLazyLoad as default, useCheckboxLazyLoad }; //# sourceMappingURL=useCheckboxLazyLoad.js.map