I\'m trying to recreate the iPhone flick / scroll event in a window using JavaScript.
Starting with JQuery, I\'m measuring the mouse\'s acceleration and offset during cl
Here's what I found when looking for kinetic/momentum scrolling libraries:
You might be interested in the jQuery plugin named overscroll: http://www.azoffdesign.com/overscroll (GitHub page)
Hit up this link for the full explanation of one approach that seems to be what you're looking for.
http://www.faqts.com/knowledge_base/view.phtml/aid/14742/fid/53
Here's an excerpt:
This handler then sets up event capture for mouse movement and stores mouse cursor positions in variables mouseX and mouseY. It then starts the timer monitorMouse() which measures mouse cursor speed by sampling the values in these variables at regular intervals. The variables mouseLeft and mouseTop hold each samplings mouse positions and the sampling rate is set to 100 milliseconds in the variable monitor.timerDelay.
And some of the author's code:
nn4 = (document.layers)? true:false;
mouseLeft = mouseTop = mouseX = mouseY = 0;
monitor = {
timerDelay:100,
moveLimit:2,
sampleLimit:10
};
function startMonitor(thisText) {
if (!tip) return;
toolTipText = thisText;
writeTooltip(toolTipText);
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = function (evt) {
mouseX = evt.pageX;
mouseY = evt.pageY;
return true;
}
monitorMouse();
}
function stopMonitor() {
if (!tip) return;
hideTooltip();
if (monitor.timer) {
clearTimeout(monitor.timer);
monitor.timer = null;
}
document.releaseEvents(Event.MOUSEMOVE);
document.onmousemove = null;
monitor.slowSamples = 0;
}
function monitorMouse() {
if (Math.abs(mouseX - mouseLeft) > monitor.moveLimit
|| Math.abs(mouseY - mouseTop) > monitor.moveLimit)
{
monitor.slowSamples = 0;
}
else if (++monitor.slowSamples > monitor.sampleLimit) {
showTooltip();
return;
}
mouseLeft = mouseX;
mouseTop = mouseY;
monitor.timer = setTimeout("monitorMouse()",monitor.timerDelay);
}