I have a scroll view, in which i have table. Columns of the table are resizable, and that is done through the RView, width that it is changing is the width of the column. Width of the column is set on the sample view. Total width of the table is additive of the width of eachColumn. Dragging on the columns at the beginning of the table results in the normal drag. But when dragging at the end. The drag is too fast. Maybe it is caused by that that the total width of the frame is changed and the RView is placed on this new position too, but I am not aware of the solution that can change this behaviour.
HStack {
ForEach(columns) { column in
ZStack(alignment: .trailing) {
sampleView()
.frame(width: width)
/// Other views above
RView(coordinateSpace: coordinateSpace, width: $width)
}
}
}.frame(width: totalWidthOfColumns from columns)
struct RView: View {
let coordinateSpace: String
@Binding
var width: CGFloat
var body: some View {
Image(systemName: "star.fill")
.gesture(
DragGesture(minimumDistance: 0, coordinateSpace: .named(coordinateSpace))
.onChanged { gesture in
let distance = gesture.translation.width
print(distance)
width += distance
}
)
}
}