Skip to content

Instantly share code, notes, and snippets.

@logeshpaul
Created April 24, 2014 05:30
Show Gist options
  • Select an option

  • Save logeshpaul/11242598 to your computer and use it in GitHub Desktop.

Select an option

Save logeshpaul/11242598 to your computer and use it in GitHub Desktop.
Detect window scrolling
$(function(){
var _top = $(window).scrollTop();
var _direction;
$(window).scroll(function(){
var _cur_top = $(window).scrollTop();
if(_top < _cur_top)
{
_direction = 'down';
}
else
{
_direction = 'up';
}
_top = _cur_top;
console.log(_direction);
});
});​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment