I'll try to answer your question with another question.
If you drag the Capsule up 10 float, and then the View scales accordingly, and then the capsule lands underneath of your new finger position... What is the Value.translation.height?
0?
10?
Technically, it's right where it began, underneath of your finger. But it took a trip to get there, so...
I think this confusion is the source of the jitters.
If this were true, then adding the value.translation.height to the viewSize ( instead of setting it equal to ) would solve the issue. And it does.
struct CustomSplitView: View {
@State private var height: CGFloat = 400
var body: some View {
VStack ( spacing: 0 ) {
Color.blue
.frame ( height: height )
Capsule()
.fill ( Color.secondary.opacity ( 0.5 ) )
.frame ( width: 40, height: 6 )
.frame ( height: 12 )
.gesture ( DragGesture()
.onChanged ( self.dragChanged )
)
Color.green
}
}
private func dragChanged ( value: DragGesture.Value ) {
self.height += value.translation.height <-- here _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
self.height = self.height .clamp ( lower: 100 , upper: 600 )
}
}
public extension Comparable {
func clamp ( lower: Self , upper: Self ) -> Self {
min ( max ( self , lower ) , upper )
}
}