|
4 | 4 |
|
5 | 5 | "use strict";
|
6 | 6 |
|
7 |
| -// WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY |
8 |
| -// If you update this line, then you also need to update the media query with the same |
9 |
| -// warning in rustdoc.css |
10 |
| -window.RUSTDOC_MOBILE_BREAKPOINT = 700; |
11 |
| - |
12 | 7 | // Given a basename (e.g. "storage") and an extension (e.g. ".js"), return a URL
|
13 | 8 | // for a resource under the root-path, with the resource-suffix.
|
14 | 9 | function resourcePath(basename, extension) {
|
@@ -730,65 +725,18 @@ function preLoadCss(cssUrl) {
|
730 | 725 | window.rustdoc_add_line_numbers_to_examples();
|
731 | 726 | }
|
732 | 727 |
|
733 |
| - let oldSidebarScrollPosition = null; |
734 |
| - |
735 |
| - // Scroll locking used both here and in source-script.js |
736 |
| - |
737 |
| - window.rustdocMobileScrollLock = function() { |
738 |
| - const mobile_topbar = document.querySelector(".mobile-topbar"); |
739 |
| - if (window.innerWidth <= window.RUSTDOC_MOBILE_BREAKPOINT) { |
740 |
| - // This is to keep the scroll position on mobile. |
741 |
| - oldSidebarScrollPosition = window.scrollY; |
742 |
| - document.body.style.width = `${document.body.offsetWidth}px`; |
743 |
| - document.body.style.position = "fixed"; |
744 |
| - document.body.style.top = `-${oldSidebarScrollPosition}px`; |
745 |
| - if (mobile_topbar) { |
746 |
| - mobile_topbar.style.top = `${oldSidebarScrollPosition}px`; |
747 |
| - mobile_topbar.style.position = "relative"; |
748 |
| - } |
749 |
| - } else { |
750 |
| - oldSidebarScrollPosition = null; |
751 |
| - } |
752 |
| - }; |
753 |
| - |
754 |
| - window.rustdocMobileScrollUnlock = function() { |
755 |
| - const mobile_topbar = document.querySelector(".mobile-topbar"); |
756 |
| - if (oldSidebarScrollPosition !== null) { |
757 |
| - // This is to keep the scroll position on mobile. |
758 |
| - document.body.style.width = ""; |
759 |
| - document.body.style.position = ""; |
760 |
| - document.body.style.top = ""; |
761 |
| - if (mobile_topbar) { |
762 |
| - mobile_topbar.style.top = ""; |
763 |
| - mobile_topbar.style.position = ""; |
764 |
| - } |
765 |
| - // The scroll position is lost when resetting the style, hence why we store it in |
766 |
| - // `oldSidebarScrollPosition`. |
767 |
| - window.scrollTo(0, oldSidebarScrollPosition); |
768 |
| - oldSidebarScrollPosition = null; |
769 |
| - } |
770 |
| - }; |
771 |
| - |
772 | 728 | function showSidebar() {
|
773 | 729 | window.hideAllModals(false);
|
774 |
| - window.rustdocMobileScrollLock(); |
775 | 730 | const sidebar = document.getElementsByClassName("sidebar")[0];
|
776 | 731 | addClass(sidebar, "shown");
|
777 | 732 | }
|
778 | 733 |
|
779 | 734 | function hideSidebar() {
|
780 |
| - window.rustdocMobileScrollUnlock(); |
781 | 735 | const sidebar = document.getElementsByClassName("sidebar")[0];
|
782 | 736 | removeClass(sidebar, "shown");
|
783 | 737 | }
|
784 | 738 |
|
785 | 739 | window.addEventListener("resize", () => {
|
786 |
| - if (window.innerWidth > window.RUSTDOC_MOBILE_BREAKPOINT && |
787 |
| - oldSidebarScrollPosition !== null) { |
788 |
| - // If the user opens the sidebar in "mobile" mode, and then grows the browser window, |
789 |
| - // we need to switch away from mobile mode and make the main content area scrollable. |
790 |
| - hideSidebar(); |
791 |
| - } |
792 | 740 | if (window.CURRENT_TOOLTIP_ELEMENT) {
|
793 | 741 | // As a workaround to the behavior of `contains: layout` used in doc togglers,
|
794 | 742 | // tooltip popovers are positioned using javascript.
|
|
0 commit comments