-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't munge window.location.hash to fix scroll positions #873
Conversation
26450ce
to
37d1a56
Compare
This comment has been minimized.
This comment has been minimized.
37d1a56
to
9e4aefd
Compare
This comment has been minimized.
This comment has been minimized.
9e4aefd
to
9744d58
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5b9bfc7
to
b71d417
Compare
OK, so we had a good time on discord figuring out how to solve this for the This weird javascript I'd touched earlier was necessary because of the fixed-position navbar; since this causes #595 and the solution in #510 looked much better, we decided to go with @Koxiaet's solution from #510 after all, and try fitting elements into the viewport despite the overlapping top navbar. The solution I pushed here uses javascript on page load (and on anchor jump links) to scroll just the right amount; unfortunately, no pure-CSS solution seemed to work:
So I went with the solution from #510 (comment), adjusting it so that back/forward buttons don't jump to where a user might have left off. This solution isn't ideal either:
OTOH, My back/forward button work quite well now, and the highlighted elements go in the right places (: |
OK - pushed up yet another massive rework for different/maybe-better tradeoffs:
I tested the following things, with JS turned on, in chrome/safari/firefox & for good measure, on an iOS device:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few superficial comments but I think @GuillaumeGomez should do a more thorough review - Guillaume, do you have the time?
In the meantime I'd love to get feedback from the people having issues in #595. I'm currently working on getting a staging server set up and I'll ping people once I have a link available.
Also I love that this is mostly CSS and the JavaScript is only for the scroll position :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of small things, and I'm not really convinced by this solution but since we don't have something better... Thanks for the PR in any case!
templates/style.scss
Outdated
padding-top: $top-navbar-height; | ||
height: 100%; | ||
overflow: hidden; | ||
margin: 0px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
margin: 0px; | |
margin: 0; |
This comment has been minimized.
This comment has been minimized.
4b2d24b
to
104bad9
Compare
I have a staging server with these changes running at http://50.116.47.176:3000/. @Koxiaet , @cormacrelf, @imjasonmiller, @Nemo157, @rudedogg could you check if this fixes the issues you were having with slow scrolling and keyboard shortcuts? This exact PR won't be merged (it needs changes once we finally finish up #786) but it will end up looking very similar to what I have on the staging server. |
@jyn514 it seems to be fixed for me on the main page, but not on the actual documentation pages themselves. The sidebar with I could also send you screen recording, if that's okay? |
A screen recording sounds great!
That's a shame ... by main page you mean the /crate URLs? Those are using a different stylesheet than the rustdoc pages which might be why. I'm really confused now why this doesn't work, the header is no longer |
I'm guessing the way that the flex box top navbar fixation works causes behavior similar to the way a @imjasonmiller - can you tell me what exact configuration you're running (what browser, OS version, device type)? I'd love a screen recording, too. |
@jyn514, I think this might be an error on my part. The actual documentation page (and sidebar) for a crate itself (e.g. http://50.116.47.176:3000/bat/0.15.4/bat/) seems to not support momentum scrolling, but the other pages seem to work fine. Are those pages using the separate style sheet you mentioned?
@antifuchs, if the other tagged users aren't experiencing any issues, it might be considered legacy? It's an old iPhone 5S on iOS Safari and I've switched to Android quite some time ago. It's currently past midnight, so I'll get to the screen recording this weekend, if you'd still like to? |
@imjasonmiller so the 5S is running iOS 12, I suppose? My 13.5 iPhone 11 does do momentum scrolling - I wonder if that's why we see different things. Either way, if you could get a screen recording, that'd be marvelous! (No rush, this PR won't be "ripe" until the template refactor is done) (: |
It still doesn't work for me, but it's probably more the the fault of my browser which is unable to scroll anything other than the body itself. |
Let me eat my words, 30 minutes after posting this :D :D :D Turns out there might be a solution that pleases everyone!! I'd been trying this before and discarded it because I hadn't attached the attribute to the right elements (been trying it with the headers that get jumped to). This article finally set me straight. The solution works (as in keyboard scrolling, jump-target positioning, back/forward DTRT) in Chrome and Firefox, requires zero javascript and no page structure modification. I think we have a winner. Will commit what I have and push it up asap. |
Nice finding! If this is the miracle solution we've been looking for so long, I'll be really happy to finally close this chapter! :D |
Welp. Testing this in some more browsers, it looks like mobile and desktop Safari does not support the attribute for anchor elements: https://bugs.webkit.org/show_bug.cgi?id=179379 I guess we'll have to put a little bit of javascript back to fix safari positioning support, but it's better-enough of a solution that it'd probably be worth it. |
104bad9
to
fbad575
Compare
I rebased away the (confusing) flex layout changes) & pushed the scroll-padding-top based solution up now. The JS does look a little intimidating, but I hope it's not too bad. The only place where it really has any effect is in Safari. |
Thanks for the comments, @Koxiaet - that definitely makes the code easier to read; I've converted all the assignments to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I redeployed the changes to http://50.116.47.176:3000/. This is really exciting!
I don't think you have. I checked it and it's still the old code, and my cache is off. |
Oops, fixed. Good catch! |
At least for me, it works perfectly! |
I asked my colleagues to try the staging server on Android devices, and they confirmed that it seems to work there in both Chrome and Firefox \o/ |
Ok great! Then I think this is only waiting on #879, then a rebase and we'll be good to go :) I'll see if I can review Tera this afternoon. |
I’ll have time later today/tonight to work on it, if you’re extra-free it’d help tons to investigate the "funky JS" issues on the templates I made but if not then no sweat |
This (fairly new) CSS attribute gets browsers that support it perfectly set up to skip the top nav bar. Unfortunately, Safari (both macOS and iOS) don't support it for this purpose yet, so we work around them in JS.
cccdc7f
to
d2080e8
Compare
OK, I rebased this onto master & ported the scroll-position fixing script to I tried the change on Safari (mobile and desktop), and it works as it did on the old master branch. |
This fixes #764 and #510 by changing rustdoc pages' CSS layout to work together with the
position:fixed
nav bar such that keyboard focus and anchor-ID jumping work.(Edited a great deal from when I first submitted this)
The technique used here relies on
scroll-padding-top
in the CSS, which is supported everywhere except Safari (neither iOS nor macOS). To fix Safari, we use a JS script to adjust the scroll offset on initial visits to the page and on internal jumping.With this, the following things work (tested on Firefox, Chrome, mobile&desktop Safari):