@@ -47,25 +47,29 @@ function saveRightScroll() {
47
47
48
48
function restoreScrolls ( ) {
49
49
var leftSidebar = document . getElementById ( 'dartdoc-sidebar-left' ) ;
50
- var leftSidebarX = sessionStorage . getItem ( 'dartdoc-sidebar-left-scrolll' ) ;
51
- var leftSidebarY = sessionStorage . getItem ( 'dartdoc-sidebar-left-scrollt' ) ;
52
-
53
50
var mainContent = document . getElementById ( 'dartdoc-main-content' ) ;
54
- var mainContentX = sessionStorage . getItem ( 'dartdoc-main-content-scrolll' ) ;
55
- var mainContentY = sessionStorage . getItem ( 'dartdoc-main-content-scrollt' ) ;
56
-
57
51
var rightSidebar = document . getElementById ( 'dartdoc-sidebar-right' ) ;
58
- var rightSidebarX = sessionStorage . getItem ( 'dartdoc-sidebar-right-scrolll' ) ;
59
- var rightSidebarY = sessionStorage . getItem ( 'dartdoc-sidebar-right-scrollt' ) ;
60
-
61
- // Set visibility to visible after scroll to prevent the brief appearance of the
62
- // panel in the wrong position.
63
- leftSidebar . scrollTo ( leftSidebarX , leftSidebarY ) ;
64
- leftSidebar . style . visibility = 'visible' ;
65
- mainContent . scrollTo ( mainContentX , mainContentY ) ;
66
- mainContent . style . visibility = 'visible' ;
67
- rightSidebar . scrollTo ( rightSidebarX , rightSidebarY ) ;
68
- rightSidebar . style . visibility = 'visible' ;
52
+
53
+ try {
54
+ var leftSidebarX = sessionStorage . getItem ( 'dartdoc-sidebar-left-scrolll' ) ;
55
+ var leftSidebarY = sessionStorage . getItem ( 'dartdoc-sidebar-left-scrollt' ) ;
56
+
57
+ var mainContentX = sessionStorage . getItem ( 'dartdoc-main-content-scrolll' ) ;
58
+ var mainContentY = sessionStorage . getItem ( 'dartdoc-main-content-scrollt' ) ;
59
+
60
+ var rightSidebarX = sessionStorage . getItem ( 'dartdoc-sidebar-right-scrolll' ) ;
61
+ var rightSidebarY = sessionStorage . getItem ( 'dartdoc-sidebar-right-scrollt' ) ;
62
+
63
+ leftSidebar . scrollTo ( leftSidebarX , leftSidebarY ) ;
64
+ mainContent . scrollTo ( mainContentX , mainContentY ) ;
65
+ rightSidebar . scrollTo ( rightSidebarX , rightSidebarY ) ;
66
+ } finally {
67
+ // Set visibility to visible after scroll to prevent the brief appearance of the
68
+ // panel in the wrong position.
69
+ leftSidebar . style . visibility = 'visible' ;
70
+ mainContent . style . visibility = 'visible' ;
71
+ rightSidebar . style . visibility = 'visible' ;
72
+ }
69
73
}
70
74
71
75
function initScrollSave ( ) {
@@ -250,9 +254,10 @@ function initSearch(name) {
250
254
}
251
255
252
256
document . addEventListener ( "DOMContentLoaded" , function ( ) {
257
+ // Place this first so that unexpected exceptions in other JavaScript do not block page visibility.
258
+ restoreScrolls ( ) ;
253
259
hljs . initHighlightingOnLoad ( ) ;
254
260
initSideNav ( ) ;
255
- restoreScrolls ( ) ;
256
261
initScrollSave ( ) ;
257
262
initSearch ( "search-box" ) ;
258
263
initSearch ( "search-body" ) ;
0 commit comments