From fa51f455fe716fe2a65c7dfed8b10184ad917847 Mon Sep 17 00:00:00 2001 From: Hyunje Alex Jun Date: Tue, 28 Jan 2014 14:51:53 +0900 Subject: [PATCH] Avoid the 'divide by zero' problem in bindMobileTouchHandler. --- src/perfect-scrollbar.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index 94f5993..e4650cd 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -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(); }