This mobile development encountered the Android 4.2 system can not trigger touchend problems, there are the following requirements.
1. Horizontal Pulley Map
2. Drop-down Refresh page content
3.body scroll bar cannot be invalidated
The Touchend event can be triggered when the browser default behavior is blocked at the beginning of the Carousel Diagram Touchmove event.
Drag-and-drop carousel diagram
Parentnode.addeventlistener (' Touchmove ', function (e) { e.preventdefault ();
Then copied a copy of the drop-down refresh event (at which point the drop-down refresh is OK)
Drop-down Refresh code document.addeventlistener (' Touchmove ', function (e) { if (gettopdistance () <=) { E.preventdefault (); } });
However, the new problem came out again, the page can not scroll up and down, after analysis of the Touchmove event in the document to prevent the browser default behavior causes the page can not swipe up and down.
Finally referred to a foreigner's article to solve this problem. (Horizontal slip fried over 7 think it is a drag-and-drop recording map)
Parentnode.addeventlistener (' Touchmove ', function (e) { var _x = E.touches[0].pagex; if ((Math.Abs (_X-PARENTNODE.STARTX) >7)) { e.preventdefault (); } E.stoppropagation ();
The drop-down refresh also adds a judging condition that determines whether the browser default behavior is blocked (scrolling more than 10 vertically prevents browser default behavior)
Document.addeventlistener (' Touchmove ', function (e) { if (gettopdistance () <= 10) {//when scroll bar position is less than //alert (' < '); var _x = E.touches[0].pagex; var _y = E.touches[0].pagey; if (_y-obj.y > 10) {//scroll distance greater than e.preventdefault ();}} );
/* Get scroll bar position
*/
function Gettopdistance () {
return Document.documentElement.scrollTop | | Window.pageyoffset | | Document.body.scrollTop;
}
Completely solve the low-end Android phone Touchend event does not trigger (consider scroll)