fix: Fix issues with lazy loading and overridden configuration (#2012)

- Closes #2011
This commit is contained in:
Dermot Duffy
2025-04-15 17:10:18 +01:00
committed by GitHub
parent 54ee1e1cf3
commit 168b9b0c90
4 changed files with 62 additions and 48 deletions
+10 -7
View File
@@ -7,22 +7,25 @@ export class LazyLoadController implements ReactiveController {
private _host: ReactiveControllerHost & HTMLElement;
private _documentVisible = true;
private _intersects = false;
private _loaded: boolean;
private _loaded = false;
private _unloadConditions: LazyUnloadCondition[] | null = null;
private _intersectionObserver = new IntersectionObserver(
this._intersectionHandler.bind(this),
);
private _listeners: LazyLoadListener[] = [];
constructor(
host: ReactiveControllerHost & HTMLElement,
constructor(host: ReactiveControllerHost & HTMLElement) {
this._host = host;
this._host.addController(this);
}
public setConfiguration(
lazyLoad?: boolean,
lazyUnloadConditions?: LazyUnloadCondition[],
) {
this._host = host;
this._host.addController(this);
this._loaded = !lazyLoad;
if (!lazyLoad && !this._loaded) {
this._setLoaded(true);
}
this._unloadConditions = lazyUnloadConditions ?? null;
}