ParallaxSwiftUI icon indicating copy to clipboard operation
ParallaxSwiftUI copied to clipboard

Parallax view shrinking inside a ScrollView

Open Saim-Khan1 opened this issue 2 years ago • 0 comments

Hi there,

I have a ZStack containing some images with varying amounts of parallax inside a vertical ScrollView. On launch it all appears fine, however if I scroll up and down a few times one of the parallax layers (or the outer ZStack) seems to shrink randomly.

It's meant to look like this: image

But ends up looking like this: image

Also sometimes it fixes itself and pops back to the original size, other times it stays in that shrunken state.

Any ideas what may be causing this? Here is the code for reference:

ScrollView(.vertical, showsIndicators: false) {           
                VStack(spacing: 0) {
                    ZStack {
                        Image("Background")
                            .resizable()
                            .aspectRatio(contentMode: .fit)
                            .parallax(amount: 16)
                            .frame(width: 130)
                            .padding()
                        
                        
                        Rectangle()
                            .frame(width: 130, height: 130)
                            .foregroundColor(.clear)
                            .padding()
                        
                        Image("BorderLayer")
                            .resizable()
                            .aspectRatio(contentMode: .fit)
                            .parallax(amount: 15)
                            .frame(width: 110)
                            .padding()
                        
                        Image("IconLayer")
                            .resizable()
                            .aspectRatio(contentMode: .fit)
                            .parallax(amount: 10)
                            .frame(width: 75)
                            .padding()
                        
                    }
...

Any help would be much appreciated! Thanks a lot

Saim-Khan1 avatar Apr 11 '23 23:04 Saim-Khan1