|
1 | 1 | <script type="text/javascript" src="/-/static/menu.js?{{ docsrs_version() | slugify }}"></script> |
2 | 2 | <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 | | - |
34 | 3 | {# see comment in ../storage-change-detection.html for details #} |
35 | 4 | <iframe src="/-/storage-change-detection.html" width="0" height="0" style="display: none"></iframe> |
36 | 5 | {%- include "footer.html" -%} |
0 commit comments