mirror of https://github.com/rust-lang/rust.git
rustdoc: fix resize trouble with mobile
This commit is contained in:
parent
77fa09d9a1
commit
fd9f1a7148
|
@ -1305,6 +1305,7 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
|
|||
// at most 400px. Otherwise, it would start out at the default size, then
|
||||
// grabbing the resize handle would suddenly cause it to jank to
|
||||
// its contraint-generated maximum.
|
||||
const RUSTDOC_MOBILE_BREAKPOINT = 700;
|
||||
const BODY_MIN = 400;
|
||||
// At half-way past the minimum size, vanish the sidebar entirely
|
||||
const SIDEBAR_VANISH_THRESHOLD = SIDEBAR_MIN / 2;
|
||||
|
@ -1474,6 +1475,9 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/how-to-read-rustdoc.html\
|
|||
}
|
||||
// Respond to the window resize event.
|
||||
window.addEventListener("resize", () => {
|
||||
if (window.innerWidth < RUSTDOC_MOBILE_BREAKPOINT) {
|
||||
return;
|
||||
}
|
||||
stopResize();
|
||||
if (desiredSidebarSize >= (window.innerWidth - BODY_MIN)) {
|
||||
changeSidebarSize(window.innerWidth - BODY_MIN);
|
||||
|
|
|
@ -18,6 +18,10 @@ wait-for-property: (".sidebar", {"clientWidth": 500}, [NEAR])
|
|||
// make the window small enough that the sidebar has to shrink
|
||||
set-window-size: (750, 600)
|
||||
wait-for-property: (".sidebar", {"clientWidth": 350}, [NEAR])
|
||||
assert-local-storage: {"rustdoc-desktop-sidebar-width": "350"}
|
||||
set-window-size: (400, 600)
|
||||
wait-for-css: (".sidebar", {"display": "block", "left": "-1000px"})
|
||||
assert-local-storage: {"rustdoc-desktop-sidebar-width": "350"}
|
||||
|
||||
// grow the window again to make the sidebar bigger
|
||||
set-window-size: (1280, 600)
|
||||
|
|
Loading…
Reference in New Issue