mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +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() {
|
function scrollToActiveMenu() {
|
||||||
window.setTimeout(function(){
|
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 ){
|
if( e && e.scrollIntoView ){
|
||||||
e.scrollIntoView({
|
e.scrollIntoView({
|
||||||
block: 'center',
|
block: 'center',
|
||||||
|
@ -493,6 +493,20 @@ function scrollToActiveMenu() {
|
||||||
}, 10);
|
}, 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
|
// Get Parameters from some url
|
||||||
var getUrlParameter = function getUrlParameter(sPageURL) {
|
var getUrlParameter = function getUrlParameter(sPageURL) {
|
||||||
var url = sPageURL.split('?');
|
var url = sPageURL.split('?');
|
||||||
|
@ -544,6 +558,7 @@ jQuery(function() {
|
||||||
initSwagger();
|
initSwagger();
|
||||||
initMenuScrollbar();
|
initMenuScrollbar();
|
||||||
scrollToActiveMenu();
|
scrollToActiveMenu();
|
||||||
|
scrollToFragment();
|
||||||
initLightbox();
|
initLightbox();
|
||||||
initImageStyles();
|
initImageStyles();
|
||||||
initToc();
|
initToc();
|
||||||
|
|
Loading…
Reference in a new issue