Reputation:
Both appear to have the exact same effect. They come both when the finger is far enough away from the control. The "bounds" is not really the criteria for UIControlEventTouchDragExit. It gets fired only if it's far away enough...
Upvotes: 3
Views: 2422
Reputation: 16628
.touchDragOutside
is continous, while .touchDragExit
is not.
.touchDragOutside
gets called on every drag movement that happens outside bounds (similar to DragGesture.onChanged(_:)
), while
.touchDragExit
gets called once as the drag leaves the bounds.
They both (!) get called only when the drag is initiated within the view.
In addition, they are only fired when the finger is "far away" (~70 pt) from the control. They won't get fired as soon as the finger leaves the bounds (same goes
.touchUpOutside
). They seem to be designed for the users to deliberately cancel ongoing touches.
Upvotes: 0
Reputation: 1744
I came here looking for the same thing and the answer from eOgas did not seem accurate. I did my own test case and here are my results for those who want a detailed answer without having to test it for themselves:
UIControlEventTouchDragExit
UIControlEventTouchDragOutside
To understand or remember better, you can compare these events to a person leaving (and coming to) their house wherein they only exit the house once but then proceed to move outside repeatedly. Also, a person only enters their house once but then proceeds to move inside repeatedly.
*the extra space around a UIControl object that takes into consideration the user's potential for imprecise touches.
Upvotes: 13
Reputation: 109
UIControlEventTouchDragOutside An event where a finger is dragged just outside the bounds of the control.
UIControlEventTouchDragExit An event where a finger is dragged from within a control to outside its bounds.
It sounds like with UIControlEventTouchDragOutside is fired when the user touches just outside the bounds, regardless of whether or not the finger was ever within the bounds. UIControlEventTouchDragExit is only fired when the finger is dragged from within the bounds to outside the bounds.
So, UIControlEventTouchDragOutside would be used when resizing a control (an edge tap, then drag), whereas UIControlEventTouchDragExit would be used to move the control around (tap inside and drag).
Upvotes: 5