Skip to content

Commit 438dccc

Browse files
committed
trying...
1 parent 926bd9d commit 438dccc

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

python_docs_theme/layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ <h3>{{ _('Navigation') }}</h3>
7777
<script type="text/javascript" src="{{ pathto('_static/copybutton.js', 1) }}"></script>
7878
<script type="text/javascript" src="{{ pathto('_static/menu.js', 1) }}"></script>
7979
<script type="text/javascript" src="{{ pathto('_static/search-focus.js', 1) }}"></script>
80+
<script type="text/javascript" src="{{ pathto('_static/smooth.js', 1) }}"></script>
8081
<script type="text/javascript" src="{{ pathto('_static/themetoggle.js', 1) }}"></script>
8182
{%- endif -%}
8283
{%- endif -%}

python_docs_theme/static/pydoctheme.css

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
@import url('classic.css');
22

3-
/* Smooth scroll */
4-
html {
5-
scroll-behavior: auto;
6-
}
7-
8-
html:has(:target) {
9-
scroll-behavior: smooth;
10-
}
11-
123
/* Common colours */
134
:root {
145
--good-color: rgb(41 100 51);

python_docs_theme/static/smooth.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
window.addEventListener('load', function() {
2+
document.documentElement.style.scrollBehavior = 'auto';
3+
4+
const target = window.location.hash;
5+
if (target) {
6+
window.scrollTo(0, 0);
7+
document.querySelector(target)?.scrollIntoView();
8+
}
9+
10+
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
11+
anchor.addEventListener('click', function(e) {
12+
document.documentElement.style.scrollBehavior = 'smooth';
13+
});
14+
});
15+
});

0 commit comments

Comments
 (0)