Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save omurphy27/7c07a839657adcaf0b43 to your computer and use it in GitHub Desktop.
Save omurphy27/7c07a839657adcaf0b43 to your computer and use it in GitHub Desktop.
Clear SetTimeout Scroll Jquery Javascript
// view source here: http://stackoverflow.com/questions/5632380/settimeout-solution-on-twitter
// basically, clearing a settimeout everytime the user scrolls, so the action isn't actually executed
//until the user stops scrolling
var $clear = null;
$(window).on('scroll',function() {
var $h2Span = $('.portfolio-page .top-content h2 span');
$h2Span.addClass('dotted-line');
if ($clear) {
clearTimeout($clear);
}
$clear = setTimeout(function() {
$h2Span.removeClass('dotted-line');
}, 600);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment