mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 10:49:24 +00:00
[matrix] Add scroll to top button
This commit is contained in:
parent
bc0e214b98
commit
f78f135505
12
docs/_static/custom.js
vendored
12
docs/_static/custom.js
vendored
@ -5,6 +5,7 @@ let bottomHeightThreshold, sections;
|
|||||||
let hamburgerToggle;
|
let hamburgerToggle;
|
||||||
let mobileSearch;
|
let mobileSearch;
|
||||||
let sidebar;
|
let sidebar;
|
||||||
|
let toTop;
|
||||||
|
|
||||||
class Modal {
|
class Modal {
|
||||||
constructor(element) {
|
constructor(element) {
|
||||||
@ -49,6 +50,10 @@ class SearchBar {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scrollToTop() {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
mobileSearch = new SearchBar();
|
mobileSearch = new SearchBar();
|
||||||
|
|
||||||
@ -56,6 +61,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
sections = document.querySelectorAll('section');
|
sections = document.querySelectorAll('section');
|
||||||
hamburgerToggle = document.getElementById('hamburger-toggle');
|
hamburgerToggle = document.getElementById('hamburger-toggle');
|
||||||
|
|
||||||
|
toTop = document.getElementById('to-top');
|
||||||
|
toTop.hidden = !(window.scrollY > 0);
|
||||||
|
|
||||||
if (hamburgerToggle) {
|
if (hamburgerToggle) {
|
||||||
hamburgerToggle.addEventListener('click', (e) => {
|
hamburgerToggle.addEventListener('click', (e) => {
|
||||||
sidebar.element.classList.toggle('sidebar-toggle');
|
sidebar.element.classList.toggle('sidebar-toggle');
|
||||||
@ -76,6 +84,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
// insert ourselves after the element
|
// insert ourselves after the element
|
||||||
parent.insertBefore(table, element.nextSibling);
|
parent.insertBefore(table, element.nextSibling);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('scroll', () => {
|
||||||
|
toTop.hidden = !(window.scrollY > 0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener('keydown', (event) => {
|
document.addEventListener('keydown', (event) => {
|
||||||
|
33
docs/_static/style.css
vendored
33
docs/_static/style.css
vendored
@ -97,6 +97,8 @@ Historically however, thanks to:
|
|||||||
--rtd-ad-background: var(--grey-2);
|
--rtd-ad-background: var(--grey-2);
|
||||||
--rtd-ad-main-text: var(--grey-6);
|
--rtd-ad-main-text: var(--grey-6);
|
||||||
--rtd-ad-small-text: var(--grey-4);
|
--rtd-ad-small-text: var(--grey-4);
|
||||||
|
--rtd-version-background: #272525;
|
||||||
|
--rtd-version-main-text: #fcfcfc;
|
||||||
--attribute-table-title: var(--grey-6);
|
--attribute-table-title: var(--grey-6);
|
||||||
--attribute-table-entry-border: var(--grey-3);
|
--attribute-table-entry-border: var(--grey-3);
|
||||||
--attribute-table-entry-text: var(--grey-5);
|
--attribute-table-entry-text: var(--grey-5);
|
||||||
@ -576,6 +578,37 @@ div.modal input {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* scroll to top button */
|
||||||
|
|
||||||
|
#to-top {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 50px;
|
||||||
|
right: 20px;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#to-top.is-rtd {
|
||||||
|
bottom: 90px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#to-top > span {
|
||||||
|
display: block;
|
||||||
|
|
||||||
|
width: auto;
|
||||||
|
height: 30px;
|
||||||
|
padding: 0 6px;
|
||||||
|
|
||||||
|
background-color: var(--rtd-version-background);
|
||||||
|
color: var(--rtd-version-main-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#to-top span {
|
||||||
|
line-height: 30px;
|
||||||
|
font-size: 90%;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
/* copy button */
|
/* copy button */
|
||||||
|
|
||||||
.relative-copy {
|
.relative-copy {
|
||||||
|
4
docs/_templates/layout.html
vendored
4
docs/_templates/layout.html
vendored
@ -190,5 +190,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="to-top" onclick="scrollToTop()"{%- if READTHEDOCS %} class="is-rtd"{%- endif %} hidden>
|
||||||
|
<span><span class="material-icons">arrow_upward</span> to top</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user