'DragGesture on Path in ScrollView doesn't work

Im working on a macOS app. It should be possible to move Shapes and Lines around in a ScrollView. Moving Shapes like Circle is working. But when I try to move or tap a Path (for drawing a Line), the drag gesture is not working at all. When the ScrollView is removed, it's possible to move the Path around. But I need it in a ScrollView. See code below

struct ContentView: View
{
    @State private var offset = CGSize.zero
    @State private var x: CGFloat = 0
    @State private var y: CGFloat = 0

    var body: some View
    {
        ScrollView( [.vertical, .horizontal])
        {
            ZStack
            {
                Path
                { path in

                    path.move(to: CGPoint(x: 100, y: 100))
                    path.addLine(to: CGPoint(x: 300, y: 300))
                }
                .stroke(.blue ,style: StrokeStyle(lineWidth: 5, lineCap: .round, dash: []))

                .offset(x: offset.width+x, y: offset.height+y)
                .simultaneousGesture( DragGesture(minimumDistance: 0, coordinateSpace: .global)
                    .onChanged
                    { gesture in

                        offset = gesture.translation
                    }
                    .onEnded
                    { _ in

                        x += offset.width
                        y += offset.height
                        offset = CGSize.zero
                    }
                )
            }
        }
        .frame(width: 800, height: 800)
    }
}

When I replace the Path with a circle in the code, everything works fine.

Circle()
    .foregroundColor(.blue)
    .frame(width: 50, height: 50)

Replacing simultaneousGesture with gesture or highPriorityGesture doesn't change anything. Is there a solution to drag a Path within a ScrollView? Or is there another approach to create Lines and drag them around in a ScrollView.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source