[ad_1]
I’m utilizing the .onDrag modifier to allow a drag/drop operation:
struct RootView: View {
@State var dragging: Bool = false
var physique: some View {
VStack {
Shade.purple.cornerRadius(.some)
.body(width: 100, peak: 100)
.onDrag {
dragging = true
return NSItemProvider(object: NSString())
}
}
}
}
As quickly as a drag is invoked, I set the dragging flag to be true.
There’s no subject with performing a drop. Nonetheless, if I invoked a drag however ended it with none motion, I’m not knowledgeable, i.e. dragging stays set to true.
I’ve tried including a second gesture set to both highPriority or simultaneous of a drag gesture that ends with none perceived motion:
.gesture(DragGesture(minimumDistance: 0)
.onEnded({ worth in
if worth.translation.peak == 0 && worth.translation.width == 0 {
self.dragging = false
}
})
)
No matter whether or not I place it earlier than/after the onDrag modifier, it stops the onDrag from triggering.
Is there any method to have the ability to inform when an onDrag ends with none motion, i.e. drag launched instantly?
[ad_2]
