mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
theme: scroll to heading on initial load #232
This commit is contained in:
parent
0dd92e332b
commit
cadc808932
1 changed files with 16 additions and 1 deletions
|
@ -484,7 +484,7 @@ function initSwipeHandler(){
|
|||
|
||||
function scrollToActiveMenu() {
|
||||
window.setTimeout(function(){
|
||||
var e = $("#sidebar ul.topics li.active a")[0];
|
||||
var e = document.querySelector( '#sidebar ul.topics li.active a' );
|
||||
if( e && e.scrollIntoView ){
|
||||
e.scrollIntoView({
|
||||
block: 'center',
|
||||
|
@ -493,6 +493,20 @@ function scrollToActiveMenu() {
|
|||
}, 10);
|
||||
}
|
||||
|
||||
function scrollToFragment() {
|
||||
if( !window.location.hash || window.location.hash.length <= 1 ){
|
||||
return;
|
||||
}
|
||||
window.setTimeout(function(){
|
||||
var e = document.querySelector( window.location.hash );
|
||||
if( e && e.scrollIntoView ){
|
||||
e.scrollIntoView({
|
||||
block: 'start',
|
||||
});
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// Get Parameters from some url
|
||||
var getUrlParameter = function getUrlParameter(sPageURL) {
|
||||
var url = sPageURL.split('?');
|
||||
|
@ -544,6 +558,7 @@ jQuery(function() {
|
|||
initSwagger();
|
||||
initMenuScrollbar();
|
||||
scrollToActiveMenu();
|
||||
scrollToFragment();
|
||||
initLightbox();
|
||||
initImageStyles();
|
||||
initToc();
|
||||
|
|
Loading…
Reference in a new issue