I have an View which I want to be able to drag, but only by 25 points in every direction.
Is this possible in SwiftUI ?
Right now I have something like this:
.offset(x: viewState.width, y: viewState.height)
.gesture(
DragGesture()
.onChanged { value in
self.viewState = ((value.translation.width > -25 &&
value.translation.width < 25) ||
(value.translation.height > -25 &&
value.translation.height < 25)) ?
value.translation :
CGSize.zero
}
.onEnded { _ in
self.viewState = CGSize.zero
}
)
But I am still able to drag it further than this if I drag slow.
Is it any way to drag it just a little bit and thats it ?