UNPKG

vuux

Version:

Vue3 Nuxt3 Nuxt4 组件库

43 lines (42 loc) 1.03 kB
const s = `data:image/svg+xml;utf8,${encodeURIComponent(` <svg xmlns="http://www.w3.org/2000/svg" width="400" height="400"> <rect width="100%" height="100%" fill="rgba(245, 247, 250, 1)"/> </svg> `)}`, n = /* @__PURE__ */ new WeakMap(), v = typeof window < "u" && typeof IntersectionObserver < "u", d = { mounted(e, t) { if (!v) { e.src = t.value; return; } e.src = s; const c = () => { const o = new Image(); o.onload = () => { e.src = t.value; }, o.onerror = () => { e.src = s; }, o.src = t.value; }, r = new IntersectionObserver( (o, a) => { for (const i of o) if (i.isIntersecting) { c(), a.unobserve(e); break; } }, { root: null, rootMargin: "0px", threshold: 0.1 } ); r.observe(e), n.set(e, r); }, unmounted(e) { const t = n.get(e); t && (t.unobserve(e), t.disconnect(), n.delete(e)); } }; export { d as default };