aboutsummaryrefslogtreecommitdiff
path: root/docs/_static/custom.js
diff options
context:
space:
mode:
authorJosh <[email protected]>2021-01-12 17:34:54 +1000
committerGitHub <[email protected]>2021-01-12 02:34:54 -0500
commitf78f1355050721324997a80aae6e4ad05d6f131d (patch)
tree67196a7fa508785b39fd5ae88bad0a809f58e7e8 /docs/_static/custom.js
parent[commands] Correct ChannelNotFound docstring (diff)
downloaddiscord.py-f78f1355050721324997a80aae6e4ad05d6f131d.tar.xz
discord.py-f78f1355050721324997a80aae6e4ad05d6f131d.zip
[matrix] Add scroll to top button
Diffstat (limited to 'docs/_static/custom.js')
-rw-r--r--docs/_static/custom.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/_static/custom.js b/docs/_static/custom.js
index 1274b405..f3cfa461 100644
--- a/docs/_static/custom.js
+++ b/docs/_static/custom.js
@@ -5,6 +5,7 @@ let bottomHeightThreshold, sections;
let hamburgerToggle;
let mobileSearch;
let sidebar;
+let toTop;
class Modal {
constructor(element) {
@@ -49,12 +50,19 @@ class SearchBar {
}
+function scrollToTop() {
+ window.scrollTo({ top: 0, behavior: 'smooth' });
+}
+
document.addEventListener('DOMContentLoaded', () => {
mobileSearch = new SearchBar();
bottomHeightThreshold = document.documentElement.scrollHeight - 30;
sections = document.querySelectorAll('section');
hamburgerToggle = document.getElementById('hamburger-toggle');
+
+ toTop = document.getElementById('to-top');
+ toTop.hidden = !(window.scrollY > 0);
if (hamburgerToggle) {
hamburgerToggle.addEventListener('click', (e) => {
@@ -76,6 +84,10 @@ document.addEventListener('DOMContentLoaded', () => {
// insert ourselves after the element
parent.insertBefore(table, element.nextSibling);
});
+
+ window.addEventListener('scroll', () => {
+ toTop.hidden = !(window.scrollY > 0);
+ });
});
document.addEventListener('keydown', (event) => {