diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index ffc1632064b0..0f7b32fa7488 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -407,6 +407,7 @@ img { } .sidebar-resizer { + touch-action: none; width: 9px; cursor: col-resize; z-index: 10; @@ -417,12 +418,14 @@ img { } .rustdoc.src .sidebar-resizer { - /* when closed, place resizer glow on top of the normal src sidebar border (no need to worry about sidebar) */ + /* when closed, place resizer glow on top of the normal src sidebar border (no need to worry + about sidebar) */ left: 49px; } .src-sidebar-expanded .rustdoc.src .sidebar-resizer { - /* for src sidebar, gap is already provided by 1px border on sidebar itself, so place resizer to right of it */ + /* for src sidebar, gap is already provided by 1px border on sidebar itself, so place resizer + to right of it */ left: var(--src-sidebar-width, 300px); } @@ -443,7 +446,8 @@ img { .sidebar-resizer.active { width: 10px; margin: 0; - /* when active or hovered, place resizer glow on top of the sidebar (right next to, or even on top of, the scrollbar) */ + /* when active or hovered, place resizer glow on top of the sidebar (right next to, or even + on top of, the scrollbar) */ left: var(--desktop-sidebar-width, 200px); border-left: solid 1px var(--sidebar-resizer-hover); } @@ -457,7 +461,8 @@ img { } .sidebar-resizer.active { - /* make the resize tool bigger when actually resizing, to avoid :hover styles on other stuff while resizing */ + /* make the resize tool bigger when actually resizing, to avoid :hover styles on other stuff + while resizing */ padding: 0 140px; width: 2px; margin-left: -140px; diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js index f00857dc81a9..c7ef4d408b60 100644 --- a/src/librustdoc/html/static/js/main.js +++ b/src/librustdoc/html/static/js/main.js @@ -1280,6 +1280,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\ hasClass(document.documentElement, "hide-sidebar"); }; const resize = e => { + e.preventDefault(); const pos = e.clientX - sidebar.offsetLeft - 3; if (pos < 50) { hideSidebar(); @@ -1292,22 +1293,25 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\ changeSidebarSize(Math.min(pos, window.innerWidth - 100)); } }; - const stopResize = () => { + const stopResize = e => { + e.preventDefault(); removeClass(resizer, "active"); - window.removeEventListener("mousemove", resize, false); - window.removeEventListener("mouseup", stopResize, false); + window.removeEventListener("pointermove", resize, false); + window.removeEventListener("pointerup", stopResize, false); removeClass(document.documentElement, "sidebar-resizing"); }; const initResize = e => { + e.preventDefault(); if (e.altKey || e.ctrlKey || e.metaKey || e.button !== 0) { return; } - window.addEventListener("mousemove", resize, false); - window.addEventListener("mouseup", stopResize, false); + window.addEventListener("pointermove", resize, false); + window.addEventListener("pointercancel", stopResize, false); + window.addEventListener("pointerup", stopResize, false); addClass(resizer, "active"); addClass(document.documentElement, "sidebar-resizing"); }; - resizer.addEventListener("mousedown", initResize, false); + resizer.addEventListener("pointerdown", initResize, false); }()); (function() { diff --git a/src/librustdoc/html/static/js/storage.js b/src/librustdoc/html/static/js/storage.js index fb65653c9381..3356f7ecbcbc 100644 --- a/src/librustdoc/html/static/js/storage.js +++ b/src/librustdoc/html/static/js/storage.js @@ -196,14 +196,14 @@ if (getSettingValue("hide-sidebar") === "true") { function updateSidebarWidth() { const desktopSidebarWidth = getSettingValue("desktop-sidebar-width"); - if (desktopSidebarWidth) { + if (desktopSidebarWidth && desktopSidebarWidth !== "null") { document.documentElement.style.setProperty( "--desktop-sidebar-width", desktopSidebarWidth + "px" ); } const srcSidebarWidth = getSettingValue("src-sidebar-width"); - if (srcSidebarWidth) { + if (srcSidebarWidth && srcSidebarWidth !== "null") { document.documentElement.style.setProperty( "--src-sidebar-width", srcSidebarWidth + "px"