Skip to content

Commit 3e618c8

Browse files
author
y-p
committed
DOC: Spihnx theme, don't sticky nav on api ref page, toc too long to fit on screen
1 parent a625fbd commit 3e618c8

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

doc/source/themes/nature_with_gtoc/layout.html

+28-19
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,35 @@ <h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3>
6868
</div>
6969

7070
<script type="text/javascript">
71-
// http://movethewebforward.org/
72-
// paul irish et al. we <3 you.
73-
var $body = $( document.body );
74-
75-
var $scrollable = $(window); // default scrollable thingy, which'll be body or docEl (html)
76-
$originalnavtop =52; //$scrollable.css('top');
77-
78-
// work on scroll, but debounced
79-
var $document = $(document).scroll( function() {
80-
var $nav = $("div.sphinxsidebar");
81-
if($scrollable.scrollTop() > ($originalnavtop - 20)) {
82-
$nav.addClass('sticky').css('top', '0');
83-
$nav.addClass('sticky').css('position', 'fixed');
84-
} else {
85-
$nav.removeClass('sticky');
86-
$nav.addClass('sticky').css('position', '');
87-
$nav.addClass('sticky').css('top', '');
88-
}
71+
$(function () {
8972

90-
});
73+
var chapter = window.location.href.split("/").pop()
74+
if (chapter.indexOf("api.html") === 0) {
75+
// don't sticky the nav when in the API doc,
76+
// TOC too long to fit on screem
77+
return
78+
}
79+
// http://movethewebforward.org/
80+
// paul irish et al. we <3 you.
81+
var $body = $(document.body);
82+
83+
var $scrollable = $(window); // default scrollable thingy, which'll be body or docEl (html)
84+
$originalnavtop = 52; //$scrollable.css('top');
85+
86+
// work on scroll, but debounced
87+
var $document = $(document).scroll(function () {
88+
var $nav = $("div.sphinxsidebar");
89+
if ($scrollable.scrollTop() > ($originalnavtop - 20)) {
90+
$nav.addClass('sticky').css('top', '0');
91+
$nav.addClass('sticky').css('position', 'fixed');
92+
} else {
93+
$nav.removeClass('sticky');
94+
$nav.addClass('sticky').css('position', '');
95+
$nav.addClass('sticky').css('top', '');
96+
}
97+
98+
});
99+
})
91100
</script>
92101

93102
{%- endblock %}

0 commit comments

Comments
 (0)