Created
December 5, 2013 08:10
-
-
Save omurphy27/7c07a839657adcaf0b43 to your computer and use it in GitHub Desktop.
Clear SetTimeout Scroll Jquery Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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