About these three mobile events, detailed information on the Internet a large search, I will not waste time
1. Mobile End Long press event
var NULL ; $ (ele). On (' Touchstart ',function() { = setTimeout (function() { Alert ("I am the long-press event!") ") }); $ (Ele). On (' touchend ',function() { cleartimeout (timer);});
Description: Simulates a long-press event via a timer, this example is based on jquery, where "ele" is the element to be long pressed;
2. Swipe up or down events on the mobile side
<! DOCTYPE html>//left and right swipe eventsvarStartX = 0, Starty = 0;functionTouchsatrtfunc (evt) {Try{evt.preventdefault ();//Browser zoom, scroll bar scrolling, and so on when blocking touch vartouch = evt.touches[0];//get the first touch point varx = number (Touch.pagex);//page contact X coordinate vary = number (touch.pagey);//page Contact Y coordinate //Record Contact initial positionStartX =x; Starty=y; } Catch(e) {alert (' Touchsatrtfunc: ' +e.message); }}functionTouchmovefunc (evt) {Try{evt.preventdefault ();//Browser zoom, scroll bar scrolling, and so on when blocking touch vartouch = evt.touches[0];//get the first touch point varx = number (Touch.pagex);//page contact X coordinate vary = number (touch.pagey);//page Contact Y coordinate vartext; //Judging slide left and right direction if(x-startx>=30) {text= ' Swipe right '; document.getElementById (' TOUCHLR '). InnerHTML =text; }Else if(x-startx<=-30) {text= ' swipe left '; document.getElementById (' TOUCHLR '). InnerHTML =text; } //Judging slide up and down direction if(y-starty>=30) {text= ' Swipe down '; document.getElementById (' TOUCHLR '). InnerHTML =text; }Else if(y-starty<=-30) {text= ' swipe up '; document.getElementById (' TOUCHLR '). InnerHTML =text; } } Catch(e) {alert (' Touchmovefunc: ' +e.message); }}functionbindevent () {Document.addeventlistener (' Touchstart ', Touchsatrtfunc,false); Document.addeventlistener (' Touchmove ', Touchmovefunc,false);} Bindevent ();</script></body>Description: The specific principle of a search a bunch of concrete examples here, the copy can be used; my way of learning is that, no matter what the principle, the first thing to do is to get the demand out, the principle of the elusive;
Mobile-side events Touchstart, Touchmove, Touchend