Is it possible to call a function only when starting a scroll?

Possible duplicate:
Can I declare jQuery logic for the beginning and end of the scroll event?

Tried this:

$(window).scroll(function() {
    console.log("ciao");
});

but the function is called while scrolling. I want to print ciao only after the start of scrolling. Than not. Well, after locking the scroll, when I restart, type "ciao" again, etc.

Is it possible to call a function only when starting a scroll?

+3
source share
2 answers

There is no built-in function for jQuery that allows you to detect start or stop scroll events.

There are several plugins that allow you to use this functionality, try this one .

Then you can change your code:

$(window).on('scrollstart', function() {
    console.log("ciao");
});
+2
source
$(window).bind("scrollstart", function() {
console.log("ciao");
});

jquery.scroll.events.js.

+2

All Articles