Skip to content

[2.7] bpo-24712: Doc: Make sidebar sticky using browser support. #13179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Doc/tools/static/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ $(function() {
var dark_color = $('.related').css('background-color');
var light_color = $('.document').css('background-color');

// set position: sticky on sidebar
// (browsers that don't support this will fall-back to
// positioning via scroll_sidebar)
var supportsPositionSticky = (window.CSS && window.CSS.supports &&
window.CSS.supports('position', 'sticky'));
if (supportsPositionSticky) {
sidebarwrapper.css('position', 'sticky');
}

function get_viewport_height() {
if (window.innerHeight)
return window.innerHeight;
Expand Down Expand Up @@ -157,6 +166,9 @@ $(function() {

/* intelligent scrolling */
function scroll_sidebar() {
if (supportsPositionSticky) {
return;
}
var sidebar_height = sidebarwrapper.height();
var viewport_height = get_viewport_height();
var offset = sidebar.position()['top'];
Expand Down