Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

BACAT Scrolling #2842

Merged
merged 55 commits into from
Mar 29, 2019
Merged

BACAT Scrolling #2842

merged 55 commits into from
Mar 29, 2019

Conversation

bwindels
Copy link
Contributor

@bwindels bwindels commented Mar 28, 2019

Related ticket: element-hq/element-web#8565

This implements a new way of restoring scroll position, dubbed BACAT (Bottom-Aligned, Clipped-At-Top) scrolling.

The motivation for the changes is having noticed that setting scrollTop while scrolling tends not work well on at least Chrome on macOs. Also see element-hq/element-web#528. The approach taken instead manually sets the height of the timeline in 200px increments, with the timeline being aligned to the bottom of the container element. The relatively tiny 200px height comes from the fact that we don't want the user to ever scroll off into pages of whitespace and we have no way of preventing overscroll, so by keeping it to 200px and putting a spinner 100px up from the top of the page, we avoid death by whitespace.

By changing the height of the container, we can compensate for anything that grew below the viewport to maintain what's currently visible in the viewport without jumping. For anything above the viewport growing or shrinking, we don't need to do anything as the timeline is bottom-aligned. We do need to update the height manually to keep all content visible. To maintain scroll position after the portion above the viewport changes height, we need to set the scrollTop, as we cannot balance it out with more height changes. We do this 100ms after the user has stopped scrolling, so setting scrollTop has not nasty side-effects.

As part of this PR, the timeline now also uses native scrollbars instead of gemini. Gemini gave us a way to observe the size of the scrollable area, which I replaced with the ResizeNotifier, which determines that e.g. if the left panel sizes was changed, the timeline must have also changed size. It it also notified if the window resizes. This is passed everywhere where it's needed by means of a resizeNotifier prop.

There are a lot of commits in this PR, if it's really hard to review, I'm happy to squash the commits to make it a bit easier.

Some things remain to be done in subsequent PRs:

  • fix the search UX, which now is also aligned to the bottom which looks weird
  • write e2e tests for the scroll panel, as we've removed the app tests for it as they completely broke.
  • Matthew might have found another jump on macOs/Chrome.
  • update some obsolete comments in ScrollPanel

as it's used in PersistentElement which could be used at various places
…ur restore position logic. Disable it like this.
as it's used in PersistentElement which could be used at various places
…ur restore position logic. Disable it like this.
…x-org/matrix-react-sdk into bwindels/timeline-nativescrollbars
these variables are now relative to bottom of timeline,
before it was the top
instead of setting a min-height on the whole timeline,
track how much height we need to add to prevent shrinking
and set paddingBottom on the container element of the timeline.
@bwindels bwindels requested a review from a team March 28, 2019 17:44
@dbkr dbkr self-assigned this Mar 29, 2019
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's certainly a lot to this, but looks plausible as far as I can see - lgtm!

src/components/structures/MatrixChat.js Outdated Show resolved Hide resolved
@jryans jryans unassigned dbkr Mar 29, 2019
@bwindels
Copy link
Contributor Author

Thanks for the quick review Dave! Merging now.

@bwindels bwindels merged commit a326c83 into develop Mar 29, 2019
@t3chguy t3chguy deleted the bwindels/bacat-scrolling-merged-develop branch June 29, 2019 05:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants