diff --git a/package.json b/package.json index 746ae0a..f31c85e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oc-client-browser", - "version": "2.1.5", + "version": "2.1.6", "description": "OC browser client", "main": "index.js", "types": "index.d.ts", diff --git a/src/oc-client.js b/src/oc-client.js index a47bd73..42e5474 100644 --- a/src/oc-client.js +++ b/src/oc-client.js @@ -723,7 +723,20 @@ export function createOc(oc) { } if (this.#manageLifecycle) { - oc.renderNestedComponent(this, () => {}); + if (this.getAttribute("loading") === "lazy") { + const observer = new IntersectionObserver((entries) => { + for (const entry of entries) { + if (entry.isIntersecting) { + observer.disconnect(); + oc.renderNestedComponent(this, () => {}); + break; + } + } + }); + observer.observe(this); + } else { + oc.renderNestedComponent(this, () => {}); + } } }