Highlight currently visited section.
This commit is contained in:
parent
7a06f0f3bf
commit
9cbbd8af65
31
docs/_static/custom.js
vendored
Normal file
31
docs/_static/custom.js
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
$(document).ready(function () {
|
||||
var sections = $('div.section');
|
||||
var activeLink = null;
|
||||
var bottomHeightThreshold = $(document).height() - 30;
|
||||
|
||||
$(window).scroll(function (event) {
|
||||
var distanceFromTop = $(this).scrollTop();
|
||||
var currentSection = null;
|
||||
|
||||
if(distanceFromTop + window.innerHeight > bottomHeightThreshold) {
|
||||
currentSection = $(sections[sections.length - 1]);
|
||||
}
|
||||
else {
|
||||
sections.each(function () {
|
||||
var section = $(this);
|
||||
if (section.offset().top - 1 < distanceFromTop) {
|
||||
currentSection = section;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (activeLink) {
|
||||
activeLink.parent().removeClass('active');
|
||||
}
|
||||
|
||||
if (currentSection) {
|
||||
activeLink = $('.sphinxsidebar a[href="#' + currentSection.attr('id') + '"]');
|
||||
activeLink.parent().addClass('active');
|
||||
}
|
||||
});
|
||||
});
|
5
docs/_static/style.css
vendored
5
docs/_static/style.css
vendored
@ -421,6 +421,11 @@ div#welcome-to-discord-py > h1 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.active {
|
||||
background-color: #dbdbdb;
|
||||
border-left: 5px solid #dbdbdb;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 870px) {
|
||||
|
||||
div.document {
|
||||
|
@ -304,3 +304,6 @@ texinfo_documents = [
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
|
||||
def setup(app):
|
||||
app.add_javascript('custom.js')
|
||||
|
Loading…
x
Reference in New Issue
Block a user