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

ScrollView + LazyVGrid jumps around when scrolling backward #19

Open
danielkramer opened this issue Jul 24, 2022 · 1 comment
Open

ScrollView + LazyVGrid jumps around when scrolling backward #19

danielkramer opened this issue Jul 24, 2022 · 1 comment

Comments

@danielkramer
Copy link

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)
                        
                }
            
            }

        }

    }

}
@tomstoermerdotcom
Copy link

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.

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

No branches or pull requests

2 participants