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

Fix bringing items into view with ItemsRepeater #4040

Closed
wants to merge 14 commits into from

Conversation

grokys
Copy link
Member

@grokys grokys commented May 30, 2020

What does the pull request do?

ItemsRepeater has problems with bringing items into view. This PR aims to fix them

  • Update ControlCatalog to add a "scroll to last" and "scroll to random" button for testing
  • Handle RequestBringIntoView event in ItemsRepeater
  • Fix difference between default values for cache size between ItemsRepeater and ViewportManager
  • Add a callback to reset anchor element (WinUI does this on CompositionTarget.Rendering event - we don't have that so just schedule it using DispatcherTimer)
  • Remove an old hack that seems to no longer be necessary
  • Fix calculation of effective viewport

Note that this PR only fixes the issues on the Avalonia side. There are still bugs remaining in ItemsRepeater itself such as microsoft/microsoft-ui-xaml#1422

To diagnose problems with `ItemsRepeater`.
The default value needs to be the same as the default value in the associated `ItemsRepeater` properties.
Hack was added when porting `ItemsRepeater. Not sure it's needed anymore.
@grokys grokys force-pushed the fixes/itemsrepeater-bringintoview branch from caef2a2 to bb1fe19 Compare June 1, 2020 14:04
@grokys grokys marked this pull request as ready for review June 1, 2020 14:12
@grokys grokys changed the title WIP: Fix bringing items into view with ItemsRepeater Fix bringing items into view with ItemsRepeater Jun 1, 2020
@grokys grokys requested a review from MarchingCube June 1, 2020 14:12
@grokys
Copy link
Member Author

grokys commented Jun 2, 2020

This still seems to be broken with variable-height items in the ControlCatalog.

`ItemsRepeater` doesn't work properly with a 0 cache length.
`OnEffectiveViewportChanged` needs to be triggered first, otherwise `_makeAnchorElement` is cleared too early, breaking scrolling in a list with variable-height items.
So one can see their bounds easily.
Instead of simply reading old `TranslatedBounds` value when `Bounds` changes, use the clip and transform from the previous `TranslatedBounds` with the new `Bounds`.
@grokys
Copy link
Member Author

grokys commented Jun 5, 2020

Closing this. Will reopen a new PR with this and #3436 combined as they're hard to separate.

@grokys grokys closed this Jun 5, 2020
@grokys grokys deleted the fixes/itemsrepeater-bringintoview branch June 5, 2020 13:00
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.

1 participant