I am using the LazyLoad library at github.com/tuupola/lazyload which works great if you have the body as the root to detect images that come into the viewport.
However, I have a DIV with fixed width and height, actually covering the entire visible browser window. And I need to have lazyload assigned to this DIV, so when the DIV is scrolled, lazy load loads the images inside this DIV, that are coming into the viewport.
With the LazyLoad library it is possible to pass another root:
new LazyLoad(images, {
root: document.querySelector('#wrapper'),
});
In my JQuery code I specifically use:
$('img.lazyload').lazyload({
effect: 'fadeIn',
root: $('#wrapper'),
});
But it does not work. Neither with root: $('#wrapper')[0],
I also reported this at github/lazyload but maybe it is not a bug with the library, however, has to do with the Intersection Observer API?
I make an example and it works
https://jsbin.com/koyuquduzu/edit?html,css,js,console,output