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.
1.4m articles
1.4m replys
5 comments
57.0k users