I made a WebApp, my users are using Macs and iPads.
To get to the next page, they have to click a < or > button. Similar like the new “Photo”-App in the “big picture view” from OS X.
How can I implement a swipe detection for the iPad users? When the user swipe from the right to left, the next page should be shown, and a swipe from left to right should go to the previous page. I see that this is possible on webpages. The German “BILD” [www.bild.de] have such a swipe detection on their 5 or 6 headlines.
A possibilty would be: I save the points from mousedown - and detect the direction of mouse move? But this costs much Performance?
Is there a good xojo solution out from the box, to detect the swipes?
This from http://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android works very nicely on my iPad.
[code]document.addEventListener(‘touchstart’, handleTouchStart, false);
document.addEventListener(‘touchmove’, handleTouchMove, false);
var xDown = null;
var yDown = null;
function handleTouchStart(evt) {
xDown = evt.touches[0].clientX;
yDown = evt.touches[0].clientY;
};
function handleTouchMove(evt) {
if ( ! xDown || ! yDown ) {
return;
}
var xUp = evt.touches[0].clientX;
var yUp = evt.touches[0].clientY;
var xDiff = xDown - xUp;
var yDiff = yDown - yUp;
if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
if ( xDiff > 0 ) {
/* left swipe */
} else {
/* right swipe */
}
} else {
if ( yDiff > 0 ) {
/* up swipe */
} else {
/* down swipe */
}
}
/* reset values */
xDown = null;
yDown = null;
};
[/code]
Use a WebSDK control to trigger an event on your app from the left swipe and right swipe, or use
window.location.replace('#'+'SwipeLeft');
and you get that value in Session.HashtagChanged.