ScrollViewProxy icon indicating copy to clipboard operation
ScrollViewProxy copied to clipboard

Not scrolling to `scrollId` inside List

Open DanSkeel opened this issue 4 years ago • 4 comments

  1. Frames has zero offset when you use AmzdScrollViewReader inside List
  2. You can't scroll to the row that is not yet appeared

DanSkeel avatar Jun 07 '21 12:06 DanSkeel

Yeah this is because List has lazy views so they won't actually exist until needed. If they dont exist then we can't get the frame. I don't have a solution for this issue right now, I am sorry for the inconvenience.

You can try to tackle this problem and make a PR or restructure to use a ScrollView.

Amzd avatar Jun 07 '21 12:06 Amzd

Possible starting points to get this working is trying to Introspect the underlying view for List, it should be a table view or collection view, which you could then ask for the frame of a view maybe?

Amzd avatar Jun 07 '21 12:06 Amzd

Thanks for feedback, yes its UITableView there but it can be tricky to map indexes onto IDs.

Also the first problem with frames seams to be caused by coordinateSpace and geometry.frame(in: .named(space)) because it gives offsets in ScrollView and in List they are zeros even for visible cells. I don't get how to figure out whats going on there.

DanSkeel avatar Jun 07 '21 12:06 DanSkeel

From the README:

An important difference between this library and Apples implementation is that the ScrollViewReader goes inside the ScrollView. If you place the ScrollViewReader around the ScrollView the scrollTo function will not scroll to the correct location (due to its coordinateSpace not being part of the scrolling content). I considered fixing this to align with Apple but that would break backwards compatibility with projects already using ScrollViewProxy.

Amzd avatar Jun 07 '21 12:06 Amzd