aboutsummaryrefslogtreecommitdiff
path: root/docs/_static/custom.js
diff options
context:
space:
mode:
authorNadir Chowdhury <[email protected]>2020-08-29 04:13:20 +0100
committerRapptz <[email protected]>2020-12-18 21:18:56 -0500
commita04a410c8ac9f5f9ec31aee91e841c8bafbdec1d (patch)
treeb0b19fc2e77db4e47565c97df38792e5b98978a4 /docs/_static/custom.js
parentFix methods from superclass showing under "Attributes" table (diff)
downloaddiscord.py-a04a410c8ac9f5f9ec31aee91e841c8bafbdec1d.tar.xz
discord.py-a04a410c8ac9f5f9ec31aee91e841c8bafbdec1d.zip
[matrix] collapsible sidebar headings
Diffstat (limited to 'docs/_static/custom.js')
-rw-r--r--docs/_static/custom.js20
1 files changed, 14 insertions, 6 deletions
diff --git a/docs/_static/custom.js b/docs/_static/custom.js
index 25a696ab..0d9d324a 100644
--- a/docs/_static/custom.js
+++ b/docs/_static/custom.js
@@ -125,12 +125,14 @@ window.addEventListener('scroll', () => {
currentSection = sections[sections.length - 1];
}
else {
- sections.forEach(section => {
- let rect = section.getBoundingClientRect();
- if (rect.top + document.body.offsetTop < 1) {
- currentSection = section;
- }
- });
+ if (sections) {
+ sections.forEach(section => {
+ let rect = section.getBoundingClientRect();
+ if (rect.top + document.body.offsetTop < 1) {
+ currentSection = section;
+ }
+ });
+ }
}
if (activeLink) {
@@ -140,6 +142,12 @@ window.addEventListener('scroll', () => {
if (currentSection) {
activeLink = document.querySelector(`#sidebar a[href="#${currentSection.id}"]`);
if (activeLink) {
+ let headingChildren = activeLink.parentElement.parentElement;
+ let heading = headingChildren.previousElementSibling.previousElementSibling;
+
+ if (heading && headingChildren.style.display === "none") {
+ activeLink = heading;
+ }
activeLink.parentElement.classList.add('active');
}
}