mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
Make hijacked docs links update the location hash (#4535)
If you click on a section title, we hijack the link to animate it. However, we did not update the location hash. This makes it quite annoying to copy links to a specific section. This PR sets the jquery animate callback to update the hash as well. I’ve also included a small fix for the link on the section title which previously produced an error in the JS console since "#" is not a valid jquery selector. changelog_begin changelog_end
This commit is contained in:
parent
c64919cd58
commit
29ac82ae1c
14
docs/theme/js/theme.js
vendored
14
docs/theme/js/theme.js
vendored
@ -486,8 +486,16 @@ $(document).ready(function () {
|
||||
if ($(window).width() < 1600) {
|
||||
$('.content-menu').toggleClass('collapsed');
|
||||
}
|
||||
var position = $($(this).attr('href')).offset().top;
|
||||
$("html, body").animate({scrollTop: position}, "slow");
|
||||
var href = $(this).attr('href');
|
||||
// Special treatment for going back to the top since those links
|
||||
// don't have an id and just go to #
|
||||
var position = href === "#" ? 0 : $(href).offset().top;
|
||||
$("html, body").animate(
|
||||
{scrollTop: position},
|
||||
"slow",
|
||||
function () {
|
||||
window.location.hash = href;
|
||||
});
|
||||
ev.preventDefault();
|
||||
});
|
||||
// sections padding
|
||||
@ -699,4 +707,4 @@ if (searchEngine === 'sphinx') {
|
||||
}, 50);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user