Castro
Castro

Reputation: 87

How to detect when user's finger away the element?

Now user taps the image, moves the finger away, release finger and can see the alert. Is it possible to check where user release finger and if he still on original image to show him alert? Otherwise do nothing.

Upvotes: 0

Views: 138

Answers (1)

woz
woz

Reputation: 10994

Try this:

var touchedObject;

$('body').bind("touchstart", function(e){
    touchedObject = $(this);
});

$('body').bind("touchend", function(e){
    if (touchedObject == $(this)) {
        //show alert
    }
});

Upvotes: 1

Related Questions