3

Possible Duplicate:
Can I declare logic on jQuery for the start and end of a scrolling event?

Tried this :

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

but the function is invoked during the scrolling. I want to print "ciao" only when I start scrolling. Than not. Well, after block the scroll, when I restart, print again "ciao", and so on.

Is it possible invoke a function only when I Start the scroll?

Community
  • 1
  • 1
markzzz
  • 47,390
  • 120
  • 299
  • 507
  • http://stackoverflow.com/questions/4096429/can-i-declare-logic-on-jquery-for-the-start-and-end-of-a-scrolling-event – Riz Apr 13 '12 at 09:21

2 Answers2

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

You must include jquery.scroll.events.js file at first. You can look for more here and here

Chuck Norris
  • 15,207
  • 15
  • 92
  • 123
2

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

There are several plugins which will enable this functionality though, try this one.

You can then change your code to this:

$(window).on('scrollstart', function() {
    console.log("ciao");
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339