[docs] handle incorrect hash in url (#10999)

* [docs] handle incorrect hash in url

* fix mistype
This commit is contained in:
Ivan Blinkov 2020-05-18 13:31:01 +03:00 committed by GitHub
parent 0fe723acc9
commit 528ac30a01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,9 +20,12 @@
var offset = 0; var offset = 0;
if (selector !== '#') { if (selector !== '#') {
offset = $(selector).offset().top - $('#top-nav').height() * 1.5; var destination = $(selector);
if (destination.length) {
offset = destination.offset().top - $('#top-nav').height() * 1.5;
dst += selector; dst += selector;
} }
}
$('html, body').animate({ $('html, body').animate({
scrollTop: offset scrollTop: offset
}, 500); }, 500);
@ -32,11 +35,14 @@
var top_nav = $('#top-nav.sticky-top'); var top_nav = $('#top-nav.sticky-top');
if (window.location.hash.length > 1 && top_nav.length) { if (window.location.hash.length > 1 && top_nav.length) {
var offset = $(window.location.hash).offset().top - top_nav.height() * 1.5; var hash_destination = $(window.location.hash);
if (hash_destination.length) {
var offset = hash_destination.offset().top - top_nav.height() * 1.5;
$('html, body').animate({ $('html, body').animate({
scrollTop: offset scrollTop: offset
}, 70); }, 70);
} }
}
$('img').each(function() { $('img').each(function() {
var src = $(this).attr('data-src'); var src = $(this).attr('data-src');