Integrate with Infinite Scrolling
-
Hello,
I found the images weren’t being loaded when I had posts being dynamically inserted.
The Infinite Scrolling had a callback function so I inserted the entire unveil script again,;(function($) { var $w = $(window), th = 200, attrib = "data-src", images = $('img[data-src]'), inview; images.bind('scrollin', {}, function() { load_image(this); }); $w.scroll(unveil); $w.resize(unveil); unveil(); function unveil() { inview = images.filter(function() { var $e = $(this), wt = $w.scrollTop(), wb = wt + $w.height(), et = $e.offset().top, eb = et + $e.height(); return eb >= wt - th && et <= wb + th; }); images = images.not(inview.trigger('scrollin')); } function load_image(img) { var $img = jQuery(img), src = $img.attr(attrib); $img.unbind('scrollin').hide().removeAttr(attrib); img.src = src; $img.fadeIn(); } return this; })(jQuery);
Is there a better way, tried to just trigger unveil and run it on images but it doesn’t seem to be the same Unveil.js I found here:
https://github.com/luis-almeida/unveil
*Seems an adapted or as the filename in the plugin says optimized version.
jquery.optimum-lazy-load.jsWould love to see the plugin function by default with dynamic loading such as infinite scrolling in place. Or at least a simple function call that can be introduced into the callback method.
Appreciate any thoughts on if there’s a better implementation.
Thanks
- The topic ‘Integrate with Infinite Scrolling’ is closed to new replies.