Closed alinless closed 2 years ago
Hi @alinless , the scenario you describe is tricky because of the combination of gestures in Pager
and List
. Do you think you could share a sample ContentView
with a similar scenario as yours? The simpler the better. I can take a look and see if there's something that I can do.
Thank you for such a fast answer! Here is an example of this bug
import SwiftUI
import SwiftUIPager
struct ContentView: View {
var models = [makeStack(), makeStack(), makeStack(), makeStack(), makeStack()]
var body: some View {
List {
ForEach((1...10), id: \.self) { _ in
Pager(page: .first(), data: models, id: \.self) { page in
VStack(spacing: 0) {
ForEach(page) { model in
CellView(model: model)
}
}
}
.preferredItemSize(CGSize(width: UIScreen.main.bounds.size.width, height: 150))
.alignment(.start(20))
.itemSpacing(15)
.horizontal()
.frame(height: 150)
}
}
}
static func makeStack() -> [CellModel] {
let stack = [CellModel(), CellModel(), CellModel(),
CellModel(), CellModel(), CellModel(),
CellModel(), CellModel()
]
return stack
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
struct CellView: View {
let model: CellModel
var body: some View {
HStack {
Text(model.id)
}
.background(model.color)
.frame(height: 50)
}
}
struct CellModel: Equatable, Hashable, Identifiable {
let id = UUID().uuidString
let color = Color.random
}
extension Color {
static var random: Color {
return Color(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
}
}
First of all, thanks for such an amazing library. It is really nice!
I use Pager inside a list view. Pager has only a horizontal scroll. Then I try to scroll the list, it gets stuck almost every second swipe or touch. I have to use list and I cant just use vStack with scrollView If I disable Dragging - everything works nice. Any other options didn't help me at all.
May I somehow disable vertical scrolling on Pager at all? Or there are any ideas on how to fix this problem?