Thursday, December 22, 2016

jQuery detect when user stops scrolling

<div class="scroll" style="height:300px;overflow:auto;border:1px solid blue">
    <div style="height:1000px"></div>
</div>
<div class="log"></div>

<script type="text/javascript">
    $("div.scroll").scroll(function() {
        clearTimeout($.data(this, 'scrollTimer'));
        $.data(this, 'scrollTimer', setTimeout(function() {
            $("div.log").prepend("Haven't scrolled in 250ms!<br/>");
        }, 250));
    });
</script>


No comments:

Post a Comment