How do I detect horizontal scrolling with jQuery?
This will get all scrolls:
$(window).scroll(function () { alert('in'); });
I want just the horizontal one.
This seems to work.
var lastScrollLeft = 0; $(window).scroll(function() { var documentScrollLeft = $(document).scrollLeft(); if (lastScrollLeft != documentScrollLeft) { console.log('scroll x'); lastScrollLeft = documentScrollLeft; } });
jsFiddle.
2.1m questions
2.1m answers
60 comments
57.0k users