vexip-ui
Version:
A Vue 3 UI library, Highly customizability, full TypeScript, performance pretty good
3 lines (2 loc) • 1.29 kB
JavaScript
;const n=require("vue"),f=require("@vexip-ui/config"),x=require("@vexip-ui/hooks"),g=require("@vexip-ui/utils"),v=require("./props.cjs"),h=n.defineComponent({name:"ResizeObserver",props:v.resizeObserverProps,setup(b,{slots:c}){const r=f.useProps("resizeObserver",b,{throttle:{default:!1,validator:e=>typeof e=="boolean"||e>0},disabled:!1}),{observeResize:p,unobserveResize:l}=x.useResize();let s=!1;function u(e){f.emitEvent(r.onResize,e)}const a=r.throttle?g.throttle(u,typeof r.throttle=="boolean"?16:r.throttle):u,o=n.getCurrentInstance();n.onMounted(()=>{n.watch(()=>r.disabled,e=>{e?m():d()},{immediate:!0,flush:"post"})}),n.onBeforeUnmount(()=>{var e,t;if(s){const i=(t=(e=n.getCurrentInstance())==null?void 0:e.proxy)==null?void 0:t.$el;i!=null&&i.nextElementSibling&&l(i.nextElementSibling)}});function d(){var t;if(s)return;const e=(t=o==null?void 0:o.proxy)==null?void 0:t.$el;if(e!=null&&e.nextElementSibling){if(e.nextElementSibling!==e.nextSibling&&e.nodeType===3&&e.nodeValue!=="")return;p(e.nextElementSibling,a),s=!0}}function m(){var e;if(s){const t=(e=o==null?void 0:o.proxy)==null?void 0:e.$el;t!=null&&t.nextElementSibling&&l(t.nextElementSibling),s=!1}}return()=>n.renderSlot(c,"default")}});module.exports=h;
//# sourceMappingURL=resize-observer.cjs.map