Return Swipe Distance with jQuery++

Working on iPad optimisations for a big clients at the moment, and we’ve settled on using a custom jQuery++ (jQuery Plus Plus) build to detect swipes.

As we also have jQuery powered scroll areas, we need to not only detect swipe, and their direction, but their distance too. Luckily, a tiny tweak of jQ++ will give us this information.

In the function commencing:

the critical section is:

 

Simply add the already defined variable distance to this.call() to read:

Now we can use that information as we see fit:

Leave a Reply

Your e-mail address will not be published. Required fields are marked *