When placing a DragGesture on a view containing a ScrollView, dragging within the ScrollView causes onChanged to trigger, while onEnded does not trigger. Does anybody have a workaround for this?
struct ContentView: View {
@State var offset: CGSize = .zero
var body: some View {
ZStack {
Spacer()
Color.clear
if self.offset != .zero {
Color.blue.opacity(0.25)
}
VStack {
Color.gray.frame(height: 44.0)
ScrollView {
ForEach(0..<100, id: \.self) { _ in
Text("Don't move please")
}
}
Color.gray.frame(height: 44.0)
}
.frame(width: 320.0, height: 568.0)
.offset(self.offset)
.animation(.easeInOut)
.gesture( DragGesture(minimumDistance: 10.0, coordinateSpace: .global)
.onChanged { (value) in
self.offset = value.translation
}
.onEnded { (_) in
self.offset = .zero
})
}
}
}
I know I could place gestures on the top/bottom gray areas (they represent bars), but in my actual app the owner of the drag gesture is a container that knows nothing about its contents.