0

I am trying to build a gallery using the isotope plugin, and in that i am using masonryHorizontal layout. All the images are placed in an unordered list and under that i have li which further has an anchor tag and an image tag nested.

<ul>
 <li><a href="#"><img src="#></a></li>
  ...
</ul>

The layout is working properly ie the images align themselves optimally leaving very less white spaces (done through isotope) but i want to have an animation when i scroll through horizontally. I searched for a day and was not able to find anything substantial. Any help is appreciated.

Turnip
  • 35,836
  • 15
  • 89
  • 111
rawatadit
  • 31
  • 1
  • 1
  • 5

1 Answers1

0

I don't know your plugins. But if you are trying to detect sideways scroll with jQuery on the Page (Not some plugin specific scrolling) then give this a try:

    var lastScrollLeft = 0;
    $(window).scroll(function() {
        var documentScrollLeft = $(document).scrollLeft();
        if (lastScrollLeft != documentScrollLeft) {
            console.log('scroll x');
            lastScrollLeft = documentScrollLeft;
        }
    });

That should detect if the scrolling position is still the same. And then you can make changes accordingly.

If that is not what you meant by scroll. Then nevermind :)

The code snippet comes from this answer:

https://stackoverflow.com/a/7076832/3767100

Community
  • 1
  • 1
Schoening
  • 79
  • 1
  • 7