1
Fork 0

Animate scrolling when clicking on ToC

This commit is contained in:
Jake Howard 2020-07-24 23:36:45 +01:00
parent 6e6a7c3716
commit 81d8166ff4
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -61,16 +61,26 @@ $(document).ready(function() {
});
});
$('#scroll-top').on('click', function(event) {
function scrollTo(offset) {
$('html, body')
.stop()
.animate(
{
scrollTop: 0,
scrollTop: offset,
},
500
);
}
$('#scroll-top').on('click', function(event) {
event.preventDefault();
scrollTo(0);
});
$('#TableOfContents a').on('click', function(event) {
event.preventDefault();
const target = $($(this).attr('href'));
scrollTo(target.offset().top);
});
$('[data-clipboard-text]').on('click', function(event) {