MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / scroll_sidebar

Function scroll_sidebar

doc/static/sidebar.js:166–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

164
165 /* intelligent scrolling */
166 function scroll_sidebar() {
167 var sidebar_height = sidebarwrapper.height();
168 var viewport_height = get_viewport_height();
169 var offset = sidebar.position()['top'];
170 var wintop = jwindow.scrollTop();
171 var winbot = wintop + viewport_height;
172 var curtop = sidebarwrapper.position()['top'];
173 var curbot = curtop + sidebar_height;
174 // does sidebar fit in window?
175 if (sidebar_height < viewport_height) {
176 // yes: easy case -- always keep at the top
177 sidebarwrapper.css('top', $u.min([$u.max([0, wintop - offset - 10]),
178 jdocument.height() - sidebar_height - 200]));
179 }
180 else {
181 // no: only scroll if top/bottom edge of sidebar is at
182 // top/bottom edge of window
183 if (curtop > wintop && curbot > winbot) {
184 sidebarwrapper.css('top', $u.max([wintop - offset - 10, 0]));
185 }
186 else if (curtop < wintop && curbot < winbot) {
187 sidebarwrapper.css('top', $u.min([winbot - sidebar_height - offset - 20,
188 jdocument.height() - sidebar_height - 200]));
189 }
190 }
191 }
192 jwindow.scroll(scroll_sidebar);
193});

Callers 1

toggle_sidebarFunction · 0.85

Calls 3

get_viewport_heightFunction · 0.85
minMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected