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

[BUG] Weird moving transparent Image appearing when scrolling fast. #307

Open
danstorre opened this issue Dec 27, 2022 · 0 comments
Open
Labels
bug Something isn't working

Comments

@danstorre
Copy link

Describe the bug
Transparent image across the whole page view when swiping too fast to the right.

To Reproduce

  • Run the code below.
  • Swipe left rapidly.

Note: Set images from your Asset folder by setting the array pages.

let pages: [String] = [
    "#image1",
    "#image2",
    "#image3",
    "#image4",
    "#image5"
]

struct InfiniteExampleView: View {
    @StateObject var page = Page.first()
    @State var isPresented: Bool = false
    var data = Array(0..<5)

    var body: some View {
        ZStack {
            
            Pager(page: self.page,
                  data: self.data,
                  id: \.self) {
                self.pageView($0)
            }
                  .pagingPriority(.simultaneous)
                  .loopPages()
                  .itemSpacing(0)
            
        }
        .edgesIgnoringSafeArea(.all)
    }

    func pageView(_ page: Int) -> some View {
        PageView(image: pages[page])
            .clipped()
            .edgesIgnoringSafeArea(.all)
    }

}



public struct PageView: View {
    let image: String
 
    public init(image: String
    ){
        self.image = image
    }
}

extension PageView {
    public var body: some View {
        ZStack(alignment: .bottomLeading) {
            Image(image)
                .resizable()
                .scaledToFill()
            
            LinearGradient(gradient: Gradient(colors: [.clear, .black]), startPoint: .top, endPoint: .bottom)
                .frame(height: 600)
            
            VStack(spacing: 22) {
                HStack {
                    VStack(alignment: .leading, spacing: 20) {
                        Text("a title")
                        Text("another title")
                            
                    }
                    
                    Spacer()
                }
            }
        }
    }
}

Expected behavior
The page view should scroll normally without showing a strange moving transparent image when doing the swiping.

Screenshots / Videos

Environment:

  • OSX: iOS 16.1
  • Device: iPhone 14 Pro
  • SwiftUIPager version: 2.5.0

Additional context
Just run the code above, you'll see the issue.

Btw, Amazing works guys! keep it up!

ScreenRecorderProject15_1.mp4
@danstorre danstorre added the bug Something isn't working label Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant