From 07fc92369ce40c26a656c69f5f96426efa8ce6b4 Mon Sep 17 00:00:00 2001 From: Chuck Dries Date: Tue, 14 Feb 2017 04:27:29 -0700 Subject: [PATCH] Fix bug preventing scroll animation from running --- scroll.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scroll.js b/scroll.js index 1285a85..2d20e1c 100644 --- a/scroll.js +++ b/scroll.js @@ -7,16 +7,14 @@ var targetHeight = null; var prevHeight = null; var currentHeight = null; var startTime = null; -var count = 0; /* does some basic checking then calls animate() to do the heavy lifting */ function smoothScroll(targetId){ target = document.getElementById(targetId);//grab the element targetHeight = target.offsetTop; //get its height currentHeight = getScrollY(); //grab the current scroll position prevHeight = null; - startTime = null; //we have to reset the start time every time the animation runs + startTime = performance.now(); //we have to reset the start time every time the animation runs if(currentHeight != targetHeight){ - count = 0; window.requestAnimationFrame(animateScroll);//schedule the animation } }