@fifteen/design-system-vue
Version:
Vue 3 (Composition API + Typescript) implementation of the Fifteen Design System
23 lines (22 loc) • 519 B
JavaScript
import { useIntersectionObserver as a } from "@vueuse/core";
import { ref as n } from "vue";
const u = "400px";
function c(o, i) {
const r = n(!1), e = n(!1);
if (typeof window > "u") return { isInit: r, isLoaded: e };
const t = new Image();
return t.addEventListener("load", () => {
e.value = !0;
}), a(
o,
([{ isIntersecting: s }]) => {
s && (r.value = !0, e.value = !0, t.src = i);
},
{
rootMargin: u
}
), { isInit: r, isLoaded: e };
}
export {
c as useLazyImage
};