From d4e4b08b9b53f3dda7be3cc3bf8881db4180f736 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 17 Oct 2022 14:20:04 -0700 Subject: rustdoc: change mobile breakpoint to match CSS Since it's possible to have a 700.5px viewport width, the JS needs to not switch to mobile mode in such a setup. --- src/librustdoc/html/static/js/main.js | 4 ++-- src/librustdoc/html/static/js/storage.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/librustdoc/html') diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index 3bcadcda534..1251d6bfda3 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -737,7 +737,7 @@ function loadCss(cssFileName) { window.rustdocMobileScrollLock = function() { const mobile_topbar = document.querySelector(".mobile-topbar"); - if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) { + if (window.innerWidth <= window.RUSTDOC_MOBILE_BREAKPOINT) { // This is to keep the scroll position on mobile. oldSidebarScrollPosition = window.scrollY; document.body.style.width = `${document.body.offsetWidth}px`; @@ -783,7 +783,7 @@ function loadCss(cssFileName) { } window.addEventListener("resize", () => { - if (window.innerWidth >= window.RUSTDOC_MOBILE_BREAKPOINT && + if (window.innerWidth > window.RUSTDOC_MOBILE_BREAKPOINT && oldSidebarScrollPosition !== null) { // If the user opens the sidebar in "mobile" mode, and then grows the browser window, // we need to switch away from mobile mode and make the main content area scrollable. diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index 5fbad357f37..b462a2c50f1 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -12,7 +12,7 @@ window.mainTheme = document.getElementById("mainThemeStyle"); // WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY // If you update this line, then you also need to update the media query with the same // warning in rustdoc.css -window.RUSTDOC_MOBILE_BREAKPOINT = 701; +window.RUSTDOC_MOBILE_BREAKPOINT = 700; const settingsDataset = (function() { const settingsElement = document.getElementById("default-settings"); -- cgit 1.4.1-3-g733a5