[BUG] Weird moving transparent Image appearing when scrolling fast.
danstorre opened this issue · comments
Dan Torres commented
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!