Prevent function from running while user is scrolling
<p>How can I do something like this?</p>

<pre><code>myfunction () {

    if (notscrolling) {

        // do stuff

    }
}
</code></pre>

<p><strong>This is the best solution that I could find:</strong></p>

<p>It gets the current scroll position, then gets it again 5 milliseconds later. If the numbers are the same, then the page is not scrolling! No global variable required.</p>

<pre><code>myfunction () {

    var a = $(document).scrollTop();

    setTimeout(function() { 
        var b = $(document).scrollTop();

            if (a === b) {

                // do stuff here cuz its not scrolling :) !!!!

            }
    }, 5);

}
</code></pre>
