0

I have a function which runs based on a setInterval() call. It looks like this:

function update()
{
    destinationY = targetPage.offset().top - $("div#reel").offset().top;
    currentY -= (currentY - destinationY) / REEL_EASE;

    $(document).scrollTop(currentY);
}

This updates the position of the document constantly to give the effect of a sliding animation, sliding towards certain points which are stored by the navigation items.

I want to not run the above code if the scrollbar has been clicked on the page. How can I call a method when the scrollbar is clicked?

Marty
  • 39,033
  • 19
  • 93
  • 162

2 Answers2

1

You can't detect when the bar itself is clicked. The closest you can get is attaching a handler to window.onscroll, which is fired only when the scrollbar's position changes (clicking to scroll or mouse wheel up/down to scroll).

http://jsfiddle.net/CTHCe/

Kai
  • 9,038
  • 5
  • 28
  • 28
0

This isn't an exact answer, but you should be able to use the scroll event to keep track of whether the scrollbar is being used: http://api.jquery.com/scroll/

Kyle
  • 3,549
  • 1
  • 19
  • 25
  • That seems to fire when the above in my question is called as well though, ideas? – Marty Feb 06 '12 at 03:19
  • This sounds similar to what you're trying to achieve: http://stackoverflow.com/questions/8858994/let-user-scrolling-stop-jquery-animation-of-scrolltop – Kyle Feb 06 '12 at 03:30