Answers for "jquery detect scroll"

1

jquery on scroll

Syntax
Trigger the scroll event for the selected elements:
$(selector).scroll()

Attach a function to the scroll event:
$(selector).scroll(function)
Posted by: Guest on June-25-2020
0

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);
Posted by: Guest on July-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language