I’m looking for a way to always scroll up or down an entire page ($(window).height) when using the scroll bar or the mouse.
I’ve already tried a few things, but in the code displayed I always scroll to the end of the document
var lastScrollTop = 0;
$(window).scroll(function(event){
var st = parseInt($(this).scrollTop());
var hg = parseInt($(window).height());
if (st > lastScrollTop){
$(document).scrollTop(st + hg);
}
lastScrollTop = st;
});
2
Answers
Based on your description and code, it seems that you want the page to scroll directly to the top or bottom on scroll. Here is a sample code that you can try:
To achieve scrolling in two directions (up and down) you need to update your code, here is an example: