jQuery ScrollTop activates Scroll listener
<p>I use a jquery scroller to move one panel at a time (see <a href="http://jsfiddle.net/kxWGU/1/" rel="nofollow">http://jsfiddle.net/kxWGU/1/</a>), and I am having some strange problem with it.</p>

<p>Each time I scroll, it scrolls several panels at once, and never stops.</p>

<p>It seems that the scrolling animation causes the scroll detector to fire.</p>

<p>Here is the jquery script:</p>

<pre><code>jQuery(document).ready(function($){
    var prevScrollTop = 0;
    var $scrollDiv    = jQuery('div#container');
    var $currentDiv   = $scrollDiv.children('div:first-child');

    var $sectionid    = 1;
    var $numsections  = 5;

    $scrollDiv.scroll(function(eventObj)
    {
        var curScrollTop = $scrollDiv.scrollTop();
        if (prevScrollTop &lt; curScrollTop)
        {
        // Scrolling down:
            if ($sectionid+1 &gt; $numsections) {
                console.log("End Panel Reached");
            }
            else {
                $currentDiv = $currentDiv.next().scrollTo();
                console.log("down");
                console.log($currentDiv);
                $sectionid=$sectionid+1;
                console.log($currentDiv.attr('id'));
                var divid =$currentDiv.attr('id');
                jQuery('#container').animate({scrollTop:jQuery('#'+divid).position().top}, 'slow');
                stop();
                }
        }
        else if (prevScrollTop &gt; curScrollTop)
        {
        // Scrolling up:
            if ($sectionid-1 == 0) {
                console.log("Top Panel Reached");
            }
            else {
                $currentDiv = $currentDiv.prev().scrollTo();
                console.log("up");
                console.log($currentDiv);
                $sectionid=$sectionid-1;
                var divid =$currentDiv.attr('id');
                jQuery('#container').animate({scrollTop:jQuery('#'+divid).position().top}, 'slow');
                stop();
                }
        }
        prevScrollTop = curScrollTop;
    });
});​
</code></pre>

<p>Any ideas?</p>
