
export default function lazyLoader (images: NodeList<HTMLElement>): void {
  const callback = function(entries, observer) { 
    for (let entry of entries) {
      if (entry.isIntersecting && !entry.target.src) {
        let target = entry.target
        target.setAttribute('src', target.getAttribute('data-src'))
      }
    }
  }
  const options: IntersectionObserverInit = {
    root: null,
    rootMargin: '200px'
  }
  const observer: IntersectionObserver = new IntersectionObserver(callback, options)

  images.forEach(el => observer.observe(el))
}


export default function lazyLoader (images: NodeList<HTMLElement>): void {
  const callback = function(entries, observer) { 
    for (let entry of entries) {
      if (entry.isIntersecting && !entry.target.src) {
        let target = entry.target
        target.setAttribute('src', target.getAttribute('data-src'))
        target.addEventListener('load', () => {
          target.removeAttribute('style')
        })
      }
    }
  }
  const options: IntersectionObserverInit = {
    root: null,
    rootMargin: '200px'
  }
  const observer: IntersectionObserver = new IntersectionObserver(callback, options)

  images.forEach(el => observer.observe(el))
}

Remove style after image loaded
feat: Remove style after image loaded
