High-level approach to your problem:
- Capture scroll events, track the time you received last.
Calculate actual speed vA versus time until last event
vA(dT): // if we last scrolled a long time ago, pretend it was MinTime // MinTime is the dT which, when scrolled // at or less than, behaves linearly if (dT > MinTime) dT = MinTime vA = MinTime / dT
Come up with some conversion to run on vA to get your desired vD speed:
vD(vA):
Calculate the "scroll factor" fS, the ratio of vD to vA:
fS(vD, vA):
Calculate the scrolling of the delta dS using fS and dSi, the initial scroll size (1 scroll of the scroll event)
dS(fS): dS = fS * dSi
Scroll this page
Scroll(dS)
If you scroll less than once per minute or slower, you get typical linear behavior. If you try to scroll faster, you will scroll the square with the actual scroll speed.
I don't know how to actually do this with javascript, but I hope it starts somewhere.
Is there a scroll unit that I can use randomly? My terminology looks ridiculous.
source share