How would you approach a continuous "+=" Tween to scroll the container?
(The scrolling mechanism isn't at issue here. It is a simple overflow: scroll box, which scrolls perfectly on both mouse and touch devices)
All I need is a starting point on how to tween something without an actual duration;
Thanks!
Lerp it! This is what drives most animations and graphics, linear interpolation.
function lerp(start, end, progress) {
return start + (end - start) * progress;
}
All it does is find a value in a range based on a percent. If you're moving from 0 to 300 and you're 50% the way through, how far along are you?
var x = 300 * 0.5; // 150
What if you started at 50 instead of 0?
var x = 50 + (300 - 50) * 0.5; // 175
You've probably written a lerp