I'd like to do some fancy jQuery stuff when the user scrolls the page. But I have no idea how to tackle this problem, since there is only the scroll() method.
Any ideas?
I'd like to do some fancy jQuery stuff when the user scrolls the page. But I have no idea how to tackle this problem, since there is only the scroll() method.
Any ideas?
Here is another more generic solution based on the same ideas mentioned:
There are scrollstart and scrollstop functions that are part of jquery mobile.
Example using scrollstop:
Hope this helps someone.
Why so complicated? As the documentation points out, this http://jsfiddle.net/x3s7F/9/ works!
http://api.jquery.com/scroll/.
Note: The
scroll
event on Windows Chrome is differently to all others. You need to scroll fast to get the same as result as in e.g. FF. Look at https://liebdich.biz/back.min.js the "X" function.Some findings from my
how many ms a scroll event
test:http://jsfiddle.net/TRNCFRMCN/1Lygop32/4/.
I had the need to implement onScrollEnd event discussed hear as well. The idea of using timer works for me.
I implement this using JavaScript Module Pattern:
Hope this will help / inspire someone
I pulled some code out of a quick piece I cobbled together that does this as an example (note that scroll.chain is an object containing two arrays start and end that are containers for the callback functions). Also note that I am using jQuery and underscore here.
There is no such event as 'scrollEnd'. I recommend that you check the value returned by
scroll()
every once in a while (say, 200ms) usingsetInterval
, and record the delta between the current and the previous value. If the delta becomes zero, you can use it as your event.