Animate scrolling when clicking on ToC
This commit is contained in:
parent
6e6a7c3716
commit
81d8166ff4
1 changed files with 12 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue