export class ImageIntersectionObserver {
    /**
     * @param containerElement - The element containing images to observe.
     */
    constructor(containerElement) {
        this.handleIntersection = (entries) => {
            for (const entry of entries) {
                if (entry.isIntersecting) {
                    const img = entry.target;
                    const dataSrc = img.dataset.src;
                    if (dataSrc) {
                        img.setAttribute('src', dataSrc);
                        delete img.dataset.src;
                    }
                    this.observer.unobserve(img);
                }
            }
        };
        this.observer = new IntersectionObserver(this.handleIntersection);
        const images = containerElement.querySelectorAll('img');
        for (const img of images) {
            this.observer.observe(img);
        }
    }
    disconnect() {
        this.observer.disconnect();
    }
}
