0

In JavaScript I am looking for a moment when user scrolls to some <div>. Then I want to stop user's inertial scrolling and scroll to some another object via script.

How can I stop the scrolling which has already started?

So I want something like this:

$('#selector').stopScrolling().scrollTo('#another_object');    

I know that $('#selector').stop() stops animations, but it seems like it can't help me there

www139
  • 4,960
  • 3
  • 31
  • 56

1 Answers1

0

Instead of using .scrollTo(), use

// see http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12/
$('html,body').animate({ scrollTo: 0 }, 1000);

then you can stop the scrolling using

// see http://stackoverflow.com/a/2836104/145346
$('html,body').stop();
Mottie
  • 84,355
  • 30
  • 126
  • 241