Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery check scroll direction

let scrollDirection = '';
let scrollTopPosition = 0;
$(window).on('scroll', function() {
	if(scrollTopPosition > $(window).scrollTop()) {
		scrollDirection = 'to-top';
	} else {
		scrollDirection = 'to-bottom';
	}
	
	scrollTopPosition = $(window).scrollTop();
});

console.log(scrollDirection);
 
PREVIOUS NEXT
Tagged: #jquery #check #scroll #direction
ADD COMMENT
Topic
Name
9+5 =