Skip to content
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

In UIViewLazyList's UITableView, adding special-case handling for programmatic scroll-to-top calls #1944

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

dnagler
Copy link
Collaborator

@dnagler dnagler commented Apr 8, 2024

  • CHANGELOG.md's "Unreleased" section has been updated, if applicable.


// Notify the scrollProcessor as needed
if (wasDoingProgrammaticScroll) {
scrollViewDidScroll(scrollView)
Copy link
Collaborator Author

@dnagler dnagler Apr 8, 2024

Choose a reason for hiding this comment

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

I know that this method should not be called for programmatic scrolls, but without this call, the placeholders at the top of the scrollView remain in place after the scroll animation finishes, without being swapped out for rendered widgets.

With this call in place, we see two animations: the scroll itself (up to the top of the scrollView), followed by a second animation where the "wall of placeholders" being shown collapses upward, to be replaced with rendered widgets.

Is there a better hook to call here? Ideally the placeholders would swap out for rendered widgets without the second animation after the scroll finishes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I played around with some alternatives, replacing the scrollViewDidScroll(scrollView) call with each of the following:

  • updateProcessor.onEndChanges()
  • (scrollView as? UITableView)?.reloadData()
  • scrollView.setNeedsDisplay()

but all of them kept the "wall of placeholders" in place. I wish we could do something akin to the lazyPagingItems.refresh() call we're doing in the Treehouse layer, which repopulates the feed without animation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Marginal improvement: rather than keeping track of wasDoingProgrammaticScroll, it's better to just use the native scrollViewDidScrollToTop hook (which is actually fired earlier than this hook).

This feels better, but the above concern (needing to get rid of the second animation) remains to be addressed.

@dnagler dnagler force-pushed the dylan/ios-scroll-to-top branch from 19d7259 to 1cb4930 Compare April 8, 2024 17:03
Copy link
Collaborator

@JakeWharton JakeWharton left a comment

Choose a reason for hiding this comment

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

Would prefer Jesse take a look still

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@underscoretang underscoretang left a comment

Choose a reason for hiding this comment

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

Just to confirm before merging. Did you test this on the money app from regressions?

@dnagler
Copy link
Collaborator Author

dnagler commented Apr 8, 2024

Just to confirm before merging. Did you test this on the money app from regressions?

I'm not seeing anything happen at all when tapping on the tab bar icon for the Money tab--looks like scroll-to-top behavior hasn't been implemented on the client side yet?

@dnagler dnagler force-pushed the dylan/ios-scroll-to-top branch from 1cb4930 to ed0f4cd Compare April 8, 2024 20:04
@underscoretang
Copy link
Collaborator

Oh yeah, the tab button isn't hooked up (not sure if that's part of the plan, but does tapping to status bar still work?

It will scroll to top for us rn without doing anything extra

@dnagler
Copy link
Collaborator Author

dnagler commented Apr 8, 2024

Oh yeah, the tab button isn't hooked up (not sure if that's part of the plan, but does tapping to status bar still work?

It will scroll to top for us rn without doing anything extra

Yep, that still works as expected!

@dnagler dnagler force-pushed the dylan/ios-scroll-to-top branch 3 times, most recently from 7ef0945 to 9b25379 Compare April 9, 2024 22:32
@dnagler dnagler force-pushed the dylan/ios-scroll-to-top branch from 9b25379 to 8a74958 Compare April 9, 2024 23:43
@dnagler
Copy link
Collaborator Author

dnagler commented Apr 10, 2024

Would prefer Jesse take a look still

Screenshot 2024-04-09 at 9 23 15 PM Chatted offline with Jesse--will pair with him on this tomorrow, but this change is good to land as-is, as an incremental improvement.

@dnagler dnagler merged commit 4a4bdb0 into trunk Apr 10, 2024
10 checks passed
@dnagler dnagler deleted the dylan/ios-scroll-to-top branch April 10, 2024 01:24
dnagler added a commit that referenced this pull request Apr 10, 2024
… the LazyListScrollProcessor so that it can update its viewport early

Follow-up to PR #1944
dnagler added a commit that referenced this pull request Apr 10, 2024
… the LazyListScrollProcessor so that it can update its viewport early

Follow-up to PR #1944
dnagler added a commit that referenced this pull request Apr 10, 2024
… the LazyListScrollProcessor so that it can update its viewport early

Follow-up to PR #1944
dnagler added a commit that referenced this pull request Apr 10, 2024
… the LazyListScrollProcessor so that it can update its viewport early

Follow-up to PR #1944
dnagler added a commit that referenced this pull request Apr 10, 2024
… the LazyListScrollProcessor so that it can update its viewport early

Follow-up to PR #1944
dnagler added a commit that referenced this pull request Apr 10, 2024
… the LazyListScrollProcessor so that it can update its viewport early (#1956)

Follow-up to PR #1944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants