mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
toc: add scrollbar #262
This commit is contained in:
parent
63a4297da9
commit
bcd4b2694b
2 changed files with 6 additions and 2 deletions
|
@ -1159,9 +1159,10 @@ option {
|
||||||
|
|
||||||
#TableOfContents {
|
#TableOfContents {
|
||||||
font-size: 13px !important;
|
font-size: 13px !important;
|
||||||
max-height: 85%;
|
max-height: 90vh;
|
||||||
overflow: auto;
|
overflow: hidden;
|
||||||
padding: 15px 5px !important;
|
padding: 15px 5px !important;
|
||||||
|
position: relative; /* PS */
|
||||||
}
|
}
|
||||||
|
|
||||||
#TableOfContents > ul > li > a {
|
#TableOfContents > ul > li > a {
|
||||||
|
|
|
@ -427,6 +427,7 @@ function initToc(){
|
||||||
function showToc(){
|
function showToc(){
|
||||||
var b = document.querySelector( 'body' );
|
var b = document.querySelector( 'body' );
|
||||||
b.classList.toggle( 'toc-flyout' );
|
b.classList.toggle( 'toc-flyout' );
|
||||||
|
pst && pst.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector( '#sidebar-overlay' ).addEventListener( 'click', showNav );
|
document.querySelector( '#sidebar-overlay' ).addEventListener( 'click', showNav );
|
||||||
|
@ -434,10 +435,12 @@ function initToc(){
|
||||||
document.querySelector( '#toc-overlay' ).addEventListener( 'click', showToc );
|
document.querySelector( '#toc-overlay' ).addEventListener( 'click', showToc );
|
||||||
var t = document.querySelector( '#toc-menu' );
|
var t = document.querySelector( '#toc-menu' );
|
||||||
var p = document.querySelector( '.progress' );
|
var p = document.querySelector( '.progress' );
|
||||||
|
var pst;
|
||||||
if( t && p ){
|
if( t && p ){
|
||||||
// we may not have a toc
|
// we may not have a toc
|
||||||
t.addEventListener( 'click', showToc );
|
t.addEventListener( 'click', showToc );
|
||||||
p.addEventListener( 'click', showToc );
|
p.addEventListener( 'click', showToc );
|
||||||
|
pst = new PerfectScrollbar('#TableOfContents');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue