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
@@ -26,7 +26,6 @@ $(function() {
26
26
// the 'sidebarbutton' element is defined as global after its
27
27
// creation, in the add_sidebar_button function
28
28
var jwindow = $ ( window ) ;
29
- var jdocument = $ ( document ) ;
30
29
var bodywrapper = $ ( '.bodywrapper' ) ;
31
30
var documentwrapper = $ ( '.documentwrapper' ) ;
32
31
var sidebar = $ ( '.sphinxsidebar' ) ;
@@ -62,8 +61,6 @@ $(function() {
62
61
expand_sidebar ( ) ;
63
62
else
64
63
collapse_sidebar ( ) ;
65
- // adjust the scrolling of the sidebar
66
- scroll_sidebar ( ) ;
67
64
}
68
65
69
66
function collapse_sidebar ( ) {
@@ -100,7 +97,7 @@ $(function() {
100
97
sidebarwrapper . css ( {
101
98
'float' : 'left' ,
102
99
'margin-right' : '0' ,
103
- 'width' : ssb_width_expanded - 28
100
+ 'width' : ssb_width_expanded - 13
104
101
} ) ;
105
102
// create the button
106
103
sidebar . append (
@@ -161,34 +158,4 @@ $(function() {
161
158
add_sidebar_button ( ) ;
162
159
var sidebarbutton = $ ( '#sidebarbutton' ) ;
163
160
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
161
} ) ;
0 commit comments