Fix incorrect auto-scrolling logic

This commit is contained in:
Arsen Melikyan
2016-01-16 22:31:42 +04:00
parent 5b21cf8545
commit d0f1edf245

View File

@ -267,9 +267,11 @@ $(document).ready(function() {
var lastChallenge = $('.sr-only').filter(function() { var lastChallenge = $('.sr-only').filter(function() {
return $(this).text() === ' Complete'; return $(this).text() === ' Complete';
}); });
lastChallenge = lastChallenge[lastChallenge.length - 1]; if (lastChallenge.length) {
var scrollTo = $(lastChallenge).offset().top - 250; lastChallenge = lastChallenge[lastChallenge.length - 1];
$('html, body').scrollTop(scrollTo); var scrollTo = $(lastChallenge).offset().top - 250;
$('html, body').scrollTop(scrollTo);
}
} }
// map // map