luis-almeida / unveil

A very lightweight jQuery plugin to lazy load images
4.16k stars 676 forks source link

Fix for scrolling fast to the bottom of the page #137

Open Sempervivum opened 7 years ago

Sempervivum commented 7 years ago

When using this script I noticed one disadvantage: When scrolling fast to the bottom of the page one scrolls over the images on the way down and initiates loading. Therefore loading of the final images being in the viewport after scrolling lasts long. There is an easy fix for this: //$w.on("scroll.unveil resize.unveil lookup.unveil", unveil); var scrollHandle = null; $w.on("scroll.unveil resize.unveil lookup.unveil", function () { if (scrollHandle) clearTimeout(scrollHandle); scrollHandle = setTimeout(unveil, 200); });