Lorti / dominant-colors-lazy-loading-wordpress-plugin

This plugin allows you to lazy load your images while showing the dominant color of each image as a placeholder – like Pinterest or Google Images.
https://wordpress.org/plugins/dominant-colors-lazy-loading/
GNU General Public License v2.0
95 stars 10 forks source link

Adding 'mousemove' event listener #19

Closed fchaussin closed 6 years ago

fchaussin commented 6 years ago

Adding 'mousemove' event listener to be executed once. Why? When I use a masony plugin gallery, it can take a while for the page to be fully loaded, and some images in the viewport are not loaded. By adding this event, it fire the 'check' function when the user move the cursor over the body. I've wrapped the listener in a separeted function to be executed once.

Lorti commented 6 years ago

I do like your idea, but may I suggest to go even further and listen for “first user interaction”?

That means adding the same listener to keydown, mousedown, mousemove and touchstart. When any of those events occur the listener removes itself from all of those events, similar to your mousemoveFunction.

fchaussin commented 6 years ago

Even better!

In the same time it would be great to find a way to execute firstUserInteraction when the document is fully rendered. I've tested my edit in a bad way, and it is totally useless if the firstUserInteraction is early fired.

Is there a way to trigger the check() function from an external script?

Lorti commented 6 years ago

I have merged the changes and will publish a new version in the WordPress SVN soon. Thank you!

fchaussin commented 6 years ago

I was happy this afternoon when I've seen seen this changelog on the plugin update :+1: Thank you for this awesome plugin!