UX: Fixes navigation 1px jitter (#17467)

Context: https://meta.discourse.org/t/pixel-jump-whenever-page-refreshes-mobile-desktop/231053

We currently add 1 extra pixel when we try to restore the last scroll position on a few routes. 

This is causing a bit of jumpiness, as described in the linked topic above. 

<img height="300" src="ae9e69f7fd.gif">

Notice how the content shifts by 1px while stuff loads.

I believe this 1px that we add is an artifact from the days when we used to set the header to `fixed` but I'm not sure. Either way, the header now uses `position: sticky;` so we shouldn't need that 1px adjustment.

This PR introduced no visual changes except that it fixes the jitter mentioned above.
This commit is contained in:
Joe 2022-07-13 13:39:30 +08:00 committed by GitHub
parent 8a3c02c985
commit 3a3628e9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ export default Component.extend(Scrolling, {
if (scrollTo >= 0) { if (scrollTo >= 0) {
schedule("afterRender", () => { schedule("afterRender", () => {
if (this.element && !this.isDestroying && !this.isDestroyed) { if (this.element && !this.isDestroying && !this.isDestroyed) {
next(() => window.scrollTo(0, scrollTo + 1)); next(() => window.scrollTo(0, scrollTo));
} }
}); });
} }

View File

@ -17,7 +17,7 @@ export default Component.extend(UrlRefresh, LoadMore, {
if (scrollTo >= 0) { if (scrollTo >= 0) {
schedule("afterRender", () => { schedule("afterRender", () => {
if (this.element && !this.isDestroying && !this.isDestroyed) { if (this.element && !this.isDestroying && !this.isDestroyed) {
next(() => window.scrollTo(0, scrollTo + 1)); next(() => window.scrollTo(0, scrollTo));
} }
}); });
} else { } else {

View File

@ -78,7 +78,7 @@ export default Component.extend(LoadMore, {
if (scrollTo >= 0) { if (scrollTo >= 0) {
schedule("afterRender", () => { schedule("afterRender", () => {
if (this.element && !this.isDestroying && !this.isDestroyed) { if (this.element && !this.isDestroying && !this.isDestroyed) {
next(() => window.scrollTo(0, scrollTo + 1)); next(() => window.scrollTo(0, scrollTo));
} }
}); });
} }

View File

@ -77,7 +77,7 @@ export default Component.extend(LoadMore, {
if (scrollTo >= 0) { if (scrollTo >= 0) {
schedule("afterRender", () => { schedule("afterRender", () => {
if (this.element && !this.isDestroying && !this.isDestroyed) { if (this.element && !this.isDestroying && !this.isDestroyed) {
next(() => window.scrollTo(0, scrollTo + 1)); next(() => window.scrollTo(0, scrollTo));
} }
}); });
} }