Skip to content

Parallax view shrinking inside a ScrollView #2

@Saim-Khan1

Description

@Saim-Khan1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions