| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent efb6c69 commit 0d781e4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,15 @@ form.inline-search input[type="submit"] { | |||
| 51 | 51 | width: 40px; | |
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | + div.document { | ||
| 55 | + display: flex; | ||
| 56 | + } | ||
| 57 | + | ||
| 54 | 58 | div.sphinxsidebar { | |
| 59 | + float: none; | ||
| 60 | + position: sticky; | ||
| 61 | + top: 0; | ||
| 62 | + max-height: 100vh; | ||
| 55 | 63 | background-color: #eeeeee; | |
| 56 | 64 | border-radius: 5px; | |
| 57 | 65 | line-height: 130%; | |
@@ -62,6 +70,13 @@ div.sphinxsidebar h3, div.sphinxsidebar h4 { | |||
| 62 | 70 | margin-top: 1.5em; | |
| 63 | 71 | } | |
| 64 | 72 | ||
| 73 | + div.sphinxsidebarwrapper { | ||
| 74 | + box-sizing: border-box; | ||
| 75 | + height: 100%; | ||
| 76 | + overflow-x: hidden; | ||
| 77 | + overflow-y: auto; | ||
| 78 | + } | ||
| 79 | + | ||
| 65 | 80 | div.sphinxsidebarwrapper > h3:first-child { | |
| 66 | 81 | margin-top: 0.2em; | |
| 67 | 82 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,8 @@ | |||
| 2 | 2 | * sidebar.js | |
| 3 | 3 | * ~~~~~~~~~~ | |
| 4 | 4 | * | |
| 5 | - * This script makes the Sphinx sidebar collapsible and implements intelligent | ||
| 6 | - * scrolling. This is a slightly modified version of Sphinx's own sidebar.js. | ||
| 5 | + * This script makes the Sphinx sidebar collapsible. This is a slightly | ||
| 6 | + * modified version of Sphinx's own sidebar.js. | ||
| 7 | 7 | * | |
| 8 | 8 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds in | |
| 9 | 9 | * .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton used to | |
@@ -25,10 +25,7 @@ $(function() { | |||
| 25 | 25 | // global elements used by the functions. | |
| 26 | 26 | // the 'sidebarbutton' element is defined as global after its | |
| 27 | 27 | // creation, in the add_sidebar_button function | |
| 28 | - var jwindow = $(window); | ||
| 29 | - var jdocument = $(document); | ||
| 30 | 28 | var bodywrapper = $('.bodywrapper'); | |
| 31 | - var documentwrapper = $('.documentwrapper'); | ||
| 32 | 29 | var sidebar = $('.sphinxsidebar'); | |
| 33 | 30 | var sidebarwrapper = $('.sphinxsidebarwrapper'); | |
| 34 | 31 | ||
@@ -46,13 +43,6 @@ $(function() { | |||
| 46 | 43 | var dark_color = '#AAAAAA'; | |
| 47 | 44 | var light_color = '#CCCCCC'; | |
| 48 | 45 | ||
| 49 | - function get_viewport_height() { | ||
| 50 | - if (window.innerHeight) | ||
| 51 | - return window.innerHeight; | ||
| 52 | - else | ||
| 53 | - return jwindow.height(); | ||
| 54 | - } | ||
| 55 | - | ||
| 56 | 46 | function sidebar_is_collapsed() { | |
| 57 | 47 | return sidebarwrapper.is(':not(:visible)'); | |
| 58 | 48 | } | |
@@ -62,8 +52,6 @@ $(function() { | |||
| 62 | 52 | expand_sidebar(); | |
| 63 | 53 | else | |
| 64 | 54 | collapse_sidebar(); | |
| 65 | - // adjust the scrolling of the sidebar | ||
| 66 | - scroll_sidebar(); | ||
| 67 | 55 | } | |
| 68 | 56 | ||
| 69 | 57 | function collapse_sidebar() { | |
@@ -72,7 +60,6 @@ $(function() { | |||
| 72 | 60 | bodywrapper.css('margin-left', bw_margin_collapsed); | |
| 73 | 61 | sidebarbutton.css({ | |
| 74 | 62 | 'margin-left': '0', | |
| 75 | - 'height': documentwrapper.height(), | ||
| 76 | 63 | 'border-radius': '5px' | |
| 77 | 64 | }); | |
| 78 | 65 | sidebarbutton.find('span').text('»'); | |
@@ -86,35 +73,28 @@ $(function() { | |||
| 86 | 73 | sidebarwrapper.show(); | |
| 87 | 74 | sidebarbutton.css({ | |
| 88 | 75 | 'margin-left': ssb_width_expanded-12, | |
| 89 | - 'height': Math.max(sidebarwrapper.height(), documentwrapper.height()), | ||
| 90 | 76 | 'border-radius': '0 5px 5px 0' | |
| 91 | 77 | }); | |
| 92 | 78 | sidebarbutton.find('span').text('«'); | |
| 93 | 79 | sidebarbutton.attr('title', _('Collapse sidebar')); | |
| 94 | - //sidebarwrapper.css({'padding-top': | ||
| 95 | - // Math.max(window.pageYOffset - sidebarwrapper.offset().top, 10)}); | ||
| 96 | 80 | document.cookie = 'sidebar=expanded'; | |
| 97 | 81 | } | |
| 98 | 82 | ||
| 99 | 83 | function add_sidebar_button() { | |
| 100 | 84 | sidebarwrapper.css({ | |
| 101 | 85 | 'float': 'left', | |
| 102 | 86 | 'margin-right': '0', | |
| 103 | - 'width': ssb_width_expanded - 28 | ||
| 87 | + 'width': ssb_width_expanded - 13 | ||
| 104 | 88 | }); | |
| 105 | 89 | // create the button | |
| 106 | 90 | sidebar.append( | |
| 107 | 91 | '<div id="sidebarbutton"><span>«</span></div>' | |
| 108 | 92 | ); | |
| 109 | 93 | var sidebarbutton = $('#sidebarbutton'); | |
| 110 | - // find the height of the viewport to center the '<<' in the page | ||
| 111 | - var viewport_height = get_viewport_height(); | ||
| 112 | - var sidebar_offset = sidebar.offset().top; | ||
| 113 | - var sidebar_height = Math.max(documentwrapper.height(), sidebar.height()); | ||
| 114 | 94 | sidebarbutton.find('span').css({ | |
| 115 | 95 | 'display': 'block', | |
| 116 | 96 | 'position': 'fixed', | |
| 117 | - 'top': Math.min(viewport_height/2, sidebar_height/2 + sidebar_offset) - 10 | ||
| 97 | + 'top': '50%' | ||
| 118 | 98 | }); | |
| 119 | 99 | ||
| 120 | 100 | sidebarbutton.click(toggle_sidebar); | |
@@ -125,8 +105,7 @@ $(function() { | |||
| 125 | 105 | 'background-color': '#CCCCCC', | |
| 126 | 106 | 'font-size': '1.2em', | |
| 127 | 107 | 'cursor': 'pointer', | |
| 128 | - 'height': sidebar_height, | ||
| 129 | - 'padding-top': '1px', | ||
| 108 | + 'height': '100%', | ||
| 130 | 109 | 'padding-left': '1px', | |
| 131 | 110 | 'margin-left': ssb_width_expanded - 12 | |
| 132 | 111 | }); | |
@@ -161,34 +140,4 @@ $(function() { | |||
| 161 | 140 | add_sidebar_button(); | |
| 162 | 141 | var sidebarbutton = $('#sidebarbutton'); | |
| 163 | 142 | set_position_from_cookie(); | |
| 164 | - | ||
| 165 | - | ||
| 166 | - /* intelligent scrolling */ | ||
| 167 | - function scroll_sidebar() { | ||
| 168 | - var sidebar_height = sidebarwrapper.height(); | ||
| 169 | - var viewport_height = get_viewport_height(); | ||
| 170 | - var offset = sidebar.position()['top']; | ||
| 171 | - var wintop = jwindow.scrollTop(); | ||
| 172 | - var winbot = wintop + viewport_height; | ||
| 173 | - var curtop = sidebarwrapper.position()['top']; | ||
| 174 | - var curbot = curtop + sidebar_height; | ||
| 175 | - // does sidebar fit in window? | ||
| 176 | - if (sidebar_height < viewport_height) { | ||
| 177 | - // yes: easy case -- always keep at the top | ||
| 178 | - sidebarwrapper.css('top', $u.min([$u.max([0, wintop - offset - 10]), | ||
| 179 | - jdocument.height() - sidebar_height - 200])); | ||
| 180 | - } | ||
| 181 | - else { | ||
| 182 | - // no: only scroll if top/bottom edge of sidebar is at | ||
| 183 | - // top/bottom edge of window | ||
| 184 | - if (curtop > wintop && curbot > winbot) { | ||
| 185 | - sidebarwrapper.css('top', $u.max([wintop - offset - 10, 0])); | ||
| 186 | - } | ||
| 187 | - else if (curtop < wintop && curbot < winbot) { | ||
| 188 | - sidebarwrapper.css('top', $u.min([winbot - sidebar_height - offset - 20, | ||
| 189 | - jdocument.height() - sidebar_height - 200])); | ||
| 190 | - } | ||
| 191 | - } | ||
| 192 | - } | ||
| 193 | - jwindow.scroll(scroll_sidebar); | ||
| 194 | 143 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments