How would I make it so I can mousedown on the body on my page, then drag the page up or down, like you can in a PDF?
Basically I want to be able to drag the whole page u
Quick fix for the scrollbar problem: use $(document.body) instead of $(document).
Still, the animation behave strangely sometimes, especially with repetitive scrolls. (eg. scrolling up and the following animation scrolls down).
Since the OP asked for a PDF viewer-like scrolling (and not an iPhone-like scrolling) that don't involve any kind of animation, I guess we could put Sohnee's code on a diet and write this:
var gesturesY = 0;
var startPosition = 0;
var isMouseDown = false;
$(document.body).mousemove( function (e) {
gesturesY = parseInt(e.pageY, 10);
if (isMouseDown) {
window.scrollBy(0, startPosition - gesturesY);
return false;
}
});
$(document.body).mousedown( function() {
startPosition = gesturesY;
isMouseDown = true;
});
$(document.body).mouseup( function() {
isMouseDown = false;
return false;
});