luis-almeida / unveil

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

Horizontal scrolling images? #49

Open mspanish opened 10 years ago

mspanish commented 10 years ago

Hey this looks great, I tried adjusting for a horizontal container rather than the default vertical scrolling - and it works to show just the visible images, but doesn't do anything on scroll. Probably because I replaced "scrollTop" with "scrollLeft" which I sort of made up!

Here is what I adjusted:

function unveil() {
  var inview = images.filter(function() {
    var $e = $(this);
    if ($e.is(":hidden")) return;

    var wt = $w.scrollLeft(),
        wb = wt + $w.width(),
        et = $e.offset().left,
        eb = et + $e.width();

    return eb >= wt - th && et <= wb + th;
  });
jiggy1com commented 9 years ago

Exactly what I wanted!

Thanks