Avoid the 'divide by zero' problem in bindMobileTouchHandler.

This commit is contained in:
Hyunje Alex Jun 2014-01-28 14:51:53 +09:00
parent aa0b57c51d
commit fa51f455fe

View File

@ -462,9 +462,13 @@
startCoords = currentCoords;
var currentTime = (new Date()).getTime();
speed.x = differenceX / (currentTime - startTime);
speed.y = differenceY / (currentTime - startTime);
startTime = currentTime;
var timeGap = currentTime - startTime;
if (timeGap > 0) {
speed.x = differenceX / timeGap;
speed.y = differenceY / timeGap;
startTime = currentTime;
}
e.preventDefault();
}