Skip to content

Commit 556f98f

Browse files
jshasyphar
authored andcommitted
Remove JS workaround for scroll-padding-top
Safari didn't previously support it, put it is now supported since version 14 (latest is 15).
1 parent 5b11920 commit 556f98f

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

templates/rustdoc/body.html

-31
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,5 @@
11
<script type="text/javascript" src="/-/static/menu.js?{{ docsrs_version() | slugify }}"></script>
22
<script type="text/javascript" src="/-/static/index.js?{{ docsrs_version() | slugify }}"></script>
3-
<script>
4-
// Reset the scroll offset on browsers that don't support
5-
// scroll-padding-top (Desktop & Mobile Safari):
6-
const maybeFixupViewPortPosition = function() {
7-
if (window.location.hash) {
8-
const anchorElement = document.getElementById(window.location.hash.substr(1));
9-
const navBarHeight = document.getElementsByClassName("nav-container-rustdoc")[0].offsetHeight;
10-
if (anchorElement &&
11-
anchorElement.getBoundingClientRect().top <= navBarHeight &&
12-
Math.abs(anchorElement.getBoundingClientRect().top) >= 0) {
13-
// It's just overlapped by the nav bar. This can't be a coincidence, scroll it into view:
14-
requestAnimationFrame(function() {
15-
scrollBy(0, -navBarHeight);
16-
});
17-
}
18-
}
19-
};
20-
window.addEventListener("hashchange", maybeFixupViewPortPosition, false);
21-
// Fix up the scroll position if this was a direct visit to the page
22-
// (not back/forward navigation):
23-
if (window.performance) {
24-
const navEntries = window.performance.getEntriesByType('navigation');
25-
const usedBack = navEntries.length > 0 && navEntries[0].type === 'back_forward' ||
26-
(window.performance.navigation &&
27-
window.performance.navigation.type == window.performance.navigation.TYPE_BACK_FORWARD);
28-
if (!usedBack && window.location.hash) {
29-
window.addEventListener("scroll", maybeFixupViewPortPosition, {"once": true});
30-
}
31-
}
32-
</script>
33-
343
{# see comment in ../storage-change-detection.html for details #}
354
<iframe src="/-/storage-change-detection.html" width="0" height="0" style="display: none"></iframe>
365
{%- include "footer.html" -%}

0 commit comments

Comments
 (0)