I am trying to get the position of the finger during a drag gesture (from an origin point of where the finger first began the drag). I want to do this while simultaneously allowing for scrolling within a ScrollView.
I can do these independently, but it seems scrolling in a ScrollView prevents the drag gesture.
I have tried adding the .gesture() part of the code below to the Component(), the VStack, and I also tried wrapping all of this in a GeometryReader and adding it to that. Each time, the .gesture() only prints when no scrolling happens (so, it prints when dragging horizontally).
How can I achieve this?
ScrollView {
VStack(alignment: .center, spacing: 0) {
ForEach((0..<reports.count), id: \.self) {i in
Component(report: reports[i])
.offset(y: -(CGFloat(i) * 12.0))
}
}
}
.gesture(
DragGesture()
.onChanged { value in
self.position = value.translation
print(self.position)
}
.onEnded { _ in
self.position = .zero
}
)