forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustdoc: use CSS
overscroll-behavior
instead of JavaScript
Fixes the desktop scrolling weirdness mentioned in rust-lang#98775 (comment) As described in the MDN page for this property: * The current Firefox ESR is 102, and the first Firefox version to support this feature is 59. * The current Chrome version 112, and the first version to support this is 63. * Edge is described as having a minor bug in `none` mode, but we use `contain` mode anyway, so it doesn't matter. * Safari 16, released September 2022, is the last browser to add this feature, and is also the oldest version we officially support.
- Loading branch information
Showing
5 changed files
with
20 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,12 @@ | ||
// This test ensures that the mobile sidebar preserves scroll position. | ||
// This test ensures that the mobile disables scrolling the page. | ||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html" | ||
// Switching to "mobile view" by reducing the width to 600px. | ||
set-window-size: (700, 600) | ||
assert-css: (".sidebar", {"display": "block", "left": "-1000px"}) | ||
|
||
// Scroll down. | ||
scroll-to: "//h2[@id='blanket-implementations']" | ||
assert-window-property: {"pageYOffset": "622"} | ||
|
||
// Open the sidebar menu. | ||
click: ".sidebar-menu-toggle" | ||
wait-for-css: (".sidebar", {"left": "0px"}) | ||
|
||
// We are no longer "scrolled". It's important that the user can't | ||
// scroll the body at all, but these test scripts are run only in Chrome, | ||
// and we need to use a more complicated solution to this problem because | ||
// of Mobile Safari... | ||
assert-window-property: {"pageYOffset": "0"} | ||
|
||
// Close the sidebar menu. Make sure the scroll position gets restored. | ||
click: ".sidebar-menu-toggle" | ||
wait-for-css: (".sidebar", {"left": "-1000px"}) | ||
assert-window-property: {"pageYOffset": "622"} | ||
|
||
// Now test that scrollability returns when the browser window is just resized. | ||
click: ".sidebar-menu-toggle" | ||
wait-for-css: (".sidebar", {"left": "0px"}) | ||
assert-window-property: {"pageYOffset": "0"} | ||
set-window-size: (900, 600) | ||
assert-window-property: {"pageYOffset": "622"} | ||
set-window-size: (1280, 800) // desktop | ||
assert-css: (".sidebar", {"overscroll-behavior": "contain"}) | ||
set-window-size: (700, 600) // mobile | ||
assert-css: (".sidebar", {"overscroll-behavior": "contain"}) | ||
|
||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" | ||
set-window-size: (1280, 800) // desktop | ||
assert-css: (".sidebar", {"overscroll-behavior": "contain"}) | ||
set-window-size: (700, 600) // mobile | ||
assert-css: (".sidebar", {"overscroll-behavior": "contain"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters