ApoorvSaxena / lozad.js

🔥 Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more
https://apoorv.pro/lozad.js/demo/
MIT License
7.44k stars 447 forks source link

Compatibility with smooth scroll #256

Open elliott-impression opened 3 years ago

elliott-impression commented 3 years ago

Hello,

Expected Behavior

It should work as expected/normal behaviour when using a smooth-scroll library, for example locomotive-scroll.

Current Behavior

It does not work, which is likely because Lozad does not know the current scroll position.

Possible Solution

Option to detect by native (existing) scroll or by another means on desktop? I.e...

smoothScroll.on('scroll', (obj) => {
            updateScroll(obj.scroll.x, obj.scroll.y);
});

Here is an example of that: Preview / Code.

Steps to Reproduce (for bugs)

Just install Locomotive Scroll, and Lozad as normal.

Tested on:

Latest version of Chrome on Windows 10 and MacOS.