Describe the bug
When inserting new data after scrolling to top, ASCollectionView refreshes the data and scrolls to the (new)top, instead of maintaining current scroll position.
To Reproduce
ASCollectionView(data: viewModel.messages) { (message, _) in
MessageView(message: message, containerWidth: reader.size.width)
}
.layout { _ in .list(spacing: 10)}
.scrollPositionSetter($scrollPosition)
.onReachedBoundary({ (boundary) in
if boundary == .top { viewModel.fetchMessages() }
})
viewModel.fetchMessages() looks something like this
Expected behaviour
What I'm trying is to implement something similar to a chat like functionality, where you start at the
bottom and scroll upwards until you reach the top, then load a new batch of data, then scroll some more, and so on.
I expect that scrolling remains where I left off after loading the new batch of data.
Instead I get scrolled to the top of the newly fetched data.
Describe the bug When inserting new data after scrolling to top, ASCollectionView refreshes the data and scrolls to the (new)top, instead of maintaining current scroll position.
To Reproduce
viewModel.fetchMessages() looks something like this
Expected behaviour What I'm trying is to implement something similar to a chat like functionality, where you start at the bottom and scroll upwards until you reach the top, then load a new batch of data, then scroll some more, and so on. I expect that scrolling remains where I left off after loading the new batch of data. Instead I get scrolled to the top of the newly fetched data.