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

FB14688465: ScrollView gesture ignored when DragGesture used by subview #542

Open
Sjmarf opened this issue Aug 6, 2024 · 0 comments
Open

Comments

@Sjmarf
Copy link

Sjmarf commented Aug 6, 2024

  • Date: 2024-08-06
  • Resolution: Open
  • Area: SwiftUI
  • OS: iOS 18 dev beta 5
  • Type: Incorrect/Unexpected Behavior
  • Keywords:

Description

I have a view with a horizontal DragGesture. The ScrollView that my view is contained within ignores scroll up/down gestures. This behavior is new in iOS 18 (I have tested dev betas 4 & 5). Example code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        ScrollView {
            ForEach(0..<20) { n in
                TileView(color: n % 2 == 0 ? .red : .blue)
            }
        }
    }
}

struct TileView: View {
    @GestureState var dragState: CGFloat = .zero
    
    let color: Color
    
    var body: some View {
        color
            .frame(height: 100)
            .gesture(
                DragGesture(
                    minimumDistance: 10,
                    coordinateSpace: .global
                )
                .updating($dragState) { value, state, _ in
                    state = value.translation.width
                }
            )
            .offset(x: dragState)
    }
}

See attached video of the above script running on iOS 17.5 (left) and iOS 18 dev beta 5 (right).

In the above example, the scroll gesture is always ignored. In my actual app, scroll gestures are only sometimes ignored.

Built using Xcode beta 5, happens on a sim (22A5326g) and on my physical device (22A5326f).

Files

Screen.Recording.2024-08-06.at.21.46.09.mov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant