From 5b9e96f1833e58fe9a2fbbfa4ba7d94a13b4f726 Mon Sep 17 00:00:00 2001 From: Henri Pihkala Date: Wed, 22 Jun 2016 19:13:11 +0300 Subject: [PATCH] Fix scroll animation callback called twice jQuery calls the animation callback for each of the matched elements in the selector. Hopscotch was selecting both the `html` element and the `body` element for adjusting the `scrollTop` value, leading to the callback being called twice. Adjusting `scrollTop` on the `html` element seems questionable anyway, so just removing it fixes the issue. --- src/js/hopscotch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 88572416..5bb3fd38 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1464,7 +1464,7 @@ // Use jQuery if it exists else if (hasJquery) { - jQuery('body, html').animate({ scrollTop: scrollToVal }, getOption('scrollDuration'), cb); + jQuery('body').animate({ scrollTop: scrollToVal }, getOption('scrollDuration'), cb); } // Use my crummy setInterval scroll solution if we're using plain, vanilla Javascript. @@ -2435,4 +2435,4 @@ return winHopscotch; -}))); \ No newline at end of file +})));