@@ -18,42 +18,45 @@ hljs.registerLanguage('apiheader', function() {
1818hljs . addPlugin ( mergeHTMLPlugin ) ;
1919hljs . highlightAll ( ) ;
2020
21- type NavState = { [ key : string ] : boolean } ;
22- const PAGE_NAV_STATE_KEY = 'pagesNavState' ;
23- const sessionState = JSON . parse ( sessionStorage . getItem ( PAGE_NAV_STATE_KEY ) ) as NavState
21+ type NavExpandState = { [ key : string ] : boolean } ;
22+ const PAGE_NAV_EXPAND_STATE_KEY = 'pagesNavState' ;
23+ const navState = JSON . parse ( localStorage . getItem ( PAGE_NAV_EXPAND_STATE_KEY ) ) as NavExpandState
2424
2525function keepNavState ( nav : HTMLElement ) {
2626 const inputs = $$ ( 'input[type="checkbox"]' , nav ) ;
27- if ( sessionState ) {
27+ if ( navState ) {
2828 inputs . forEach ( input => {
2929 const key = input . id ;
3030 if ( input . dataset [ 'shouldExpand' ] === 'true' ) {
3131 input . checked = true ;
3232 } else {
33- input . checked = sessionState [ key ] ;
33+ input . checked = navState [ key ] ;
3434 }
3535 } ) ;
3636 }
3737 window . addEventListener ( 'beforeunload' , ( ) => {
3838 const inputs = $$ ( 'input[type="checkbox"]' , nav ) ;
39- const state : NavState = inputs . reduce ( ( state : NavState , input ) => {
39+ const state : NavExpandState = inputs . reduce ( ( state : NavExpandState , input ) => {
4040 const key = input . id ;
4141 const value = input . checked ;
4242 return { ...state , [ key ] : value } ;
4343 } , { } ) ;
44- sessionStorage . setItem ( PAGE_NAV_STATE_KEY , JSON . stringify ( state ) ) ;
44+ localStorage . setItem ( PAGE_NAV_EXPAND_STATE_KEY , JSON . stringify ( state ) ) ;
4545 } ) ;
4646}
4747
48+ type NavScrollPosition = number ;
4849const PAGE_NAV_SCROLL_POSITION_KEY = 'pagesNavScrollPosition' ;
49- const scrollPosition = sessionStorage . getItem ( PAGE_NAV_SCROLL_POSITION_KEY ) ;
50+ const pagesNavScrollPosition : NavScrollPosition = parseInt (
51+ localStorage . getItem ( PAGE_NAV_SCROLL_POSITION_KEY )
52+ ) ;
5053
5154function keepNavPosition ( nav : HTMLElement ) {
52- if ( scrollPosition ) {
53- nav . scrollTop = parseInt ( scrollPosition ) ;
55+ if ( pagesNavScrollPosition ) {
56+ nav . scrollTop = pagesNavScrollPosition ;
5457 }
5558 window . addEventListener ( 'beforeunload' , ( ) => {
56- sessionStorage . setItem ( PAGE_NAV_SCROLL_POSITION_KEY , nav . scrollTop . toString ( ) ) ;
59+ localStorage . setItem ( PAGE_NAV_SCROLL_POSITION_KEY , nav . scrollTop . toString ( ) ) ;
5760 } ) ;
5861}
5962
@@ -75,8 +78,8 @@ function isElementInViewport(el: HTMLElement): boolean {
7578 ) ;
7679}
7780
78-
7981const pagesNav = $ ( '#pages-nav' ) ;
80- keepNavPosition ( pagesNav ) ;
8182keepNavState ( pagesNav ) ;
83+ keepNavPosition ( pagesNav ) ;
84+ pagesNav . style . opacity = '1' ;
8285scrollCurrentNaviItemIntoView ( pagesNav , 100 ) ;
0 commit comments