This should be fairly simple but I just can't get it right. I want to create a way of scrolling the page when the user clicks and drags somewhere, similar to how you navigate in most pdf apps. So, click, move cursor one px to the right, the site scrolls one pixel to the right, etc.

So as long as the mouse button is pressed down, I want the scroll position to be equal to: cursor position in relation to the entire document, minus the cursor position in relation to the viewport. Right? Well I can't make it work... I haven't quite understood the difference between screenX/Y, offsetX/Y, clientX/Y, and plain x/y, and they don't quite behave the way I expect them to. So, if anyone could explain what's what, what I might be doing wrong, or better yet, point me to a good free cross browser script that already does what I want (there should be one somewhere...?), I'd be grateful!