UseLazyLoaderInit
katanakit-js / useLazyLoaderInit
Function: useLazyLoaderInit()
Section titled “Function: useLazyLoaderInit()”function useLazyLoaderInit(key?, selector?, rootMargin?): void;Defined in: infrastructure/observer/observer.service.ts:227
Initializes lazy loading for images using IntersectionObserver.
Elements matching the selector must have a data-src attribute with the real image URL.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
key? |
string |
"default" |
A unique identifier for this lazy-loader instance (default: "default"). |
selector? |
string |
"img[data-src]" |
CSS selector for lazy-loadable images (default: "img[data-src]"). |
rootMargin? |
string |
"200px" |
IntersectionObserver root margin (default: "200px"). |
Returns
Section titled “Returns”void
Example
Section titled “Example”useLazyLoaderInit("gallery", "img[data-src]", "300px");