ScrollView + LazyVGrid jumps around when scrolling backward
I have a LazyVGrid inside a Scrollview.. scrolling from start to finish works great , as I scroll backward the scrollview jumps around.. I think the issue is the scrollview content size for each grid item is changing. If I hard code the frame of the image it no longer hitches. I think I should be able to do that as all my images are the same size.. but I didn't run into this issue when trying other image caching frameworks like SDWebImageSwiftUI for example. Just thought you might want to know if it's something that can be looked at.
ScrollView {
LazyVGrid(columns: columnLayout) {
ForEach(settings.wallpaperDataFiltered, id: \.guid) { wallpaper in
ZStack {
NavigationLink(destination: WallpaperUI()) {
KFImage.url(URL(string: wallpaper.thumbUrl))
.fade(duration: 0.25)
.resizable()
.aspectRatio(contentMode: .fit)
}
}
}
}
}
Maybe a little bit late... but from my experience using the .aspectRatio(..) modifier with aspectRatio: CGSize parameter helps SwiftUI to calculate the layout and dramatically improves scrolling performance and may fix your described behaviour. But it would require to know the dimensions of the resource before requesting.