[Python-checkins] [2.7] bpo-24712: Doc: Make sidebar sticky using browser support. (GH-13179)
Stéphane Wirtel
webhook-mailer at python.org
Wed May 8 09:32:14 EDT 2019
https://github.com/python/cpython/commit/8ab24b2ebcf99f703f00297cb3a0c3ff857eecf8
commit: 8ab24b2ebcf99f703f00297cb3a0c3ff857eecf8
branch: 2.7
author: Julien Palard <julien at palard.fr>
committer: Stéphane Wirtel <stephane at wirtel.be>
date: 2019年05月08日T09:32:07-04:00
summary:
[2.7] bpo-24712: Doc: Make sidebar sticky using browser support. (GH-13179)
Patch by Mike Taylor.
files:
M Doc/tools/static/sidebar.js
diff --git a/Doc/tools/static/sidebar.js b/Doc/tools/static/sidebar.js
index 1bdd829a7683..17f818ec140e 100644
--- a/Doc/tools/static/sidebar.js
+++ b/Doc/tools/static/sidebar.js
@@ -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;
@@ -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'];
More information about the Python-checkins
mailing list