How to cancel "swipeStart" event?

Is there a way to cancel “swipeStart” events?

I have a popup where the user can write stuff. And sometimes, they close it with an unintentional swipe down.

I would like to intercept the “swipeStart” event, check if there has been stuff written by the user, and if it is the case, I would like to cancel the event (so the popup move back to it’s original place) and I will show an action sheet where the user can confirm or cancel the move. If he confirms, then I will programmatically close() the popup.

Do you know how to reproduce this behavior?

You can test this scenario on the iOS Calendar app: create a new event but do not modify anything, you can close it with a swipe ; but if you start writing stuff, then the swipe down is cancelled and an action sheet appears to ask you confirmation.

I think about implementing a new “swipe-to-close-locked” property for the popup. When true, you can drag the popup but with a lot of “resistance” (instead of a 1 for 1 translation).

And when a popup is locked, there is still the “swipestart” and “swipeend” events, but the popup cannot be closed, and if it’s dragged enough, it triggers a “swipelocked” event.

So the user has a feedback that normally the popup is draggable but that it is not currently.
And the dev can implement easily enough a way of switching the “swipe-to-close-locked” property to “true” when he wants to prevent the popup from closing, and he can implement a “close confirmation” when he detects that the user tries to close the locked popup.

With this, I believe we can reproduce quite easily the behavior we can observe in the native iOS calendar app.

@nolimits4web, what do you think about it? If you like the idea, I can make a PR.