developer0218
developer0218

Reputation: 23

how to cancel OnDrag in swiftui?

I am making drag & drop lazyVGrid.

i did reference this answer

SwiftUI | Using onDrag and onDrop to reorder Items within one single LazyGrid?

when drag move another item position it working well

but when I long press and not move and drop itself self.dragging not set to nil

how can I fix it??

Upvotes: 1

Views: 877

Answers (1)

Taeeun Kim
Taeeun Kim

Reputation: 1256

I would try to do like this.

.gesture(DragGesture()
    .onChanged({ value in
                    if value.x == 0 && value.y == 0 {
                        self.dragging = nil
                    }
                    })
)

Upvotes: 0

Related Questions