There isn’t a distance limit so you just have to play with the numbers.
Basically it’s a mix between the acceleration and spring stiffness. When the spring is stretched far enough it will counteract the acceleration.
The damping makes it less springy. Set it to 0 to see it bounce all over. The damping slows it down.
320 and 240 were just half the 640,480 window.
I used the layout size to limit the position we use to the scroll area. It’s not needed if you had unbounded scrolling.
The a and d variable are just the angle and distance from the camera to the mouse.
There’s always some feature I forget about with my examples. You may still be about to use screen shake after you set the mouse position. Or we could do our own with some random values added to the scroll position.