Recently, I have been working on a Javascript function that automatically scrolls the page when the user drags an element close to the window's edge. The function is shown below in its simplified form:
var scroll = function() {
var scrollTop = $myElement.scrollTop();
$myElement.scrollTop(scrollTop += delta);
setTimeout(scroll, 25);
}
Unfortunately, I've noticed some performance issues arise when testing on older browsers. To improve this, I decided to lower the resolution of my scroll()
function from 25 to around 100.
Is there a way to dynamically adjust the resolution based on the browser's speed?
I would like to find a solution that doesn't involve detecting specific user agents.