From d0f1edf245b84f103db46facafc09bc43e086b3f Mon Sep 17 00:00:00 2001 From: Arsen Melikyan Date: Sat, 16 Jan 2016 22:31:42 +0400 Subject: [PATCH] Fix incorrect auto-scrolling logic --- client/main.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/main.js b/client/main.js index 9b08476590..a81e14578f 100644 --- a/client/main.js +++ b/client/main.js @@ -267,9 +267,11 @@ $(document).ready(function() { var lastChallenge = $('.sr-only').filter(function() { return $(this).text() === ' Complete'; }); - lastChallenge = lastChallenge[lastChallenge.length - 1]; - var scrollTo = $(lastChallenge).offset().top - 250; - $('html, body').scrollTop(scrollTo); + if (lastChallenge.length) { + lastChallenge = lastChallenge[lastChallenge.length - 1]; + var scrollTo = $(lastChallenge).offset().top - 250; + $('html, body').scrollTop(scrollTo); + } } // map