The title is "the impossibility of dragging and dragging in mobile browsers", but think about it or change it into a difficult one, to avoid too absolute
I wanted to implement a control button like the iphone that I could drag on my mobile Web page, but finally found naught,
While drag-and-drop actions are commonplace in mobile browsers, it is impossible to implement components that can be dragged in a mobile browser.
Let's take a look at the PC Web page, how the drag action is done,
First of all, we have a button, click on the action, has been pressed, can be arbitrarily dragged, just like the iphone can be arbitrarily dragged the control button,
such as the gray layer, it is not very easy to write,
First of all, to change the position property of the gray layer to Abosulte, and then the task to be implemented in the jquery script is to differentiate between click and Mousedown+mouseup, because click would be equal to mousedown+ MouseUp, but fortunately, mousedown a period of time, immediately unbind empty layer to the Cilck action of the binding, tell the system, MouseDown after the action is not related to the click, see the following real code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
The reason is to write the Mouseout event, and the previous "JQuery" Long press button (click the Open link) article, to prevent the browser, blacked out to avoid the MouseUp to determine the bug.The above looks very perfect, because in the PC each big browser test pass, also perfectly compatible with IE8, is really beautiful picturesque,
But as soon as you get to the phone, it's a big problem.
Only in the Google browser in the phone debugging mode, not yet to the real machine, it can not be used!
There is no problem with the jquery Click event in the Mobile browser, but the long-press event conflicts with the right-click feature on the phone, even if it is replaced by the. On ("Taphold", function () {}) in jquery Mobile. Event or in the above MouseDown add E.preventdefault (), IE is used window.event.preventDefault (), I disable the mobile browser's own menu, can only make long-press function, drag and drop is not to think about it, Because the main function of drag and drop is the MouseMove action, the mobile browser does not support the MouseMove () action at all.
So, someone protested, you can use the jquery UI in the. draggable () and Jquerymobile in the swipe event, really HTML5 drag events Ah!
All of these solutions, however, are futile,
For the. draggable () in the jquery UI (click the Open link), the swipe event in Jquerymobile (click the Open link), the drag-and-drop event in the HTML5 (click the open link) can be used in the browser's phone debug mode, found that there is no way to drag.
"JQuery" on the difficulty of dragging and dragging in mobile browser