I have the following problem.
I have a View inside a ScrollView that I want to drag.
Now, everything works fine, the dragging occurs and the scrolling as well. But once I try to do both, the dragOffset appears to stay, instead of resetting to its initial position.
More so, onEnded of the DragGesture never happens. How can I stop this from happening and reset the green Rectangle to its initial position?
Visual representation
Dragging or scrolling works just fine.

But whenever I do both, this happens.
Demo Code
struct ContentView: View {
@State private var dragOffset: CGSize = .zero
var body: some View {
ScrollView {
Rectangle()
.frame(width: UIScreen.main.bounds.size.width, height: 300)
.foregroundColor(.green)
.offset(x: dragOffset.width)
}
.gesture(DragGesture()
.onChanged { value in
dragOffset = value.translation
}
.onEnded { value in
dragOffset = .zero
}
)
.animation(.default)
}
}
Thank you!