fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.29k stars 172 forks source link

[BUG] Gestures of the previous page invoked when tapping left of the PagerView #172

Closed kellysoft-andreas closed 3 years ago

kellysoft-andreas commented 3 years ago

Hi @fermoya,

thanks for the Pager! really cool. I think I found a little glitch.

When you have a view left of the Pager (in a HStack) and you have swiped to page two then the gestures of the view on the left don't work any more. instead you get the gestures of the no longer visible page 1.

Here is a simple view that reproduces it: the tap gesture only works while you are on the first page.

struct ContentView: View {
    @State var x = 0
    @State var page: Int = 0
    var items = Array(0..<10)

    var body: some View {
        HStack() {
            Text("\(x)").frame(width: 100, height: 100).onTapGesture {
                x += 1
            }
            Pager(page: $page, data: items, id: \.self) { i in
                Text("Page \(i)").frame(width: 100, height: 100).background(Color.yellow).onTapGesture {
                    x -= 1
                }
            }
        }.frame(width: 200)
    }
}

I would expect the gestures to work no matter which page I am on.

I am using 1.14.1 and it happens on all iOS devices and simulators I have tried.

Cheers & Thanks, Andreas

fermoya commented 3 years ago

Hi @kellysoft-andreas thanks for your feedback. I've just released 1.14.2-beta.2. It should have this issue covered.

fermoya commented 3 years ago

should be solved now, please use version 2.0.0

kellysoft-andreas commented 3 years ago

yeap - I upgraded to 2.0.0 and it works fine. Thanks!