From 6b0c41f6160ad74bb1155efebe526f9b4717d111 Mon Sep 17 00:00:00 2001 From: Arsen Melikyan Date: Sat, 16 Jan 2016 21:30:47 +0400 Subject: [PATCH] Auto-scroll the map to the last completed challenge --- client/main.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/main.js b/client/main.js index 9e7e43c886..9b08476590 100644 --- a/client/main.js +++ b/client/main.js @@ -263,6 +263,15 @@ $(document).ready(function() { window.location.href = link; }); + if ($('.sr-only').length) { + 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); + } + // map $('#nav-map-btn').on('click', () => { if (!main.isMapAsideLoad) {