1. The large area touch of Android will cause the problem of triggering touchmove determine if the last position of the Touchstart is the same as the current position, so that the move return
<body><div class= "page" > <div id= "box" ></div></div><script type= "Text/javascript" >varpage = Document.queryselector ('. Page '));p Age.addeventlistener (' Touchstart ',function(e) {E.preventdefault ();});varLastpoint ={};box.addeventlistener (' Touchstart ',function(e) {Lastpoint={x:e.changedtouches[0].pagex, y:e.changedtouches[0].pagey} This. InnerHTML = "Start"; This. InnerHTML + = "<br/>x:" +e.changedtouches[0].pagex; This. InnerHTML + = "<br/>y:" +e.changedtouches[0].pagey;}); Box.addeventlistener (' Touchmove ',function(e) {if(E.changedtouches[0].pagex = =Lastpoint.x&&e.changedtouches[0].pagey = =Lastpoint.y) { return; } This. InnerHTML + = "<br/>move"; This. InnerHTML = "x:" +e.changedtouches[0].pagex; This. InnerHTML + = "<br/>y:" +e.changedtouches[0].pagey; Lastpoint={x:e.changedtouches[0].pagex, y:e.changedtouches[0].pagey}});</script>
2. Mobile input box is blocked how to do in focus: Get screen height, compare the bottom of the input box is beyond the screen, beyond let the frame upward move beyond the distance in Blur do: The frame back to the original position
<div class= "page" > <div class= "info" ></div> <input type= "text" class= "text" Name= "" ></div ><script type= "Text/javascript" src= "js/mtween.js" ></script><script type= "Text/javascript" >(function(){ varpage = Document.queryselector ('. Page ')); varText = Document.queryselector ('. Text ')); varinfo = Document.queryselector ('. Info ')); varOld = 0; CSS (page,"Translatey", 0); /*the problem with the mobile input box being obscured 1) is after the software disk pops up (add a delay time in focus), get the coordinates of input 2) to determine if input is obscured by 1. Determine if input is below the height of the visible area 3) If it is obscured, move up the entire page 1. The distance that is obscured by the software disk*/Text.addeventlistener (' Focus ',function(e) {setTimeout (function(){ //After a period of delay, you can get the coordinates after the soft keyboard pops up varRect =Text.getboundingclientrect (); varh =Document.documentElement.clientHeight; old= CSS (page, "Translatey")); if(Rect.bottom >h) { //info.innerhtml = "obscured"; vardis = rect.bottom-h; CSS (page,"Translatey", old-dis); } },1000); }); Text.addeventlistener (' Blur ',function(e) { old= CSS (page, "Translatey"), old); });}) ();</script>3. Mobile How to fixed horizontal screen display detection cell phone vertical screen, the element to the element to add 90deg rotation detection cell phone horizontal screen, the element to the rotation of the element to 0 4. Event point through the PC side of the mouse event is also effective on the mobile side, but the use of mouse events on the mobile side has a 300 millisecond delay, If there are two elements overlapping, click on the above element disappears, there will be a point through the event, if the following element has a mouse event, it will be triggered because the execution process: After the finger is pressed, the touch event is executed first, then the clicked coordinates are recorded, and after 300ms, the coordinates are searched for the element. If the element is bound to a mouse event, the event is resolved by E.preventdefault (), or by delaying more than 300 milliseconds to handle the event Deprecated workaround: Add block bubbles to a single space 5. Solve the problem that the blur of input cannot be triggered after clicking on the soft keyboard scaling under Android
<body><input id= "text" type= "text" name= "" ><div id= "info" ></div><script type= "text/ JavaScript ">(function(){ varText = Document.queryselector (' #text '); varinfo = document.queryselector (' #info '); Text.onfocus=function(){ //the popup of the soft keyboard will affect the size of the window changes //unfold is change once, shrink up and change againWindow.addeventlistener (' Resize ', toresize); }; functiontoresize () {Window.removeeventlistener (' Resize ', toresize); Window.addeventlistener (' Resize ', Toblur); } functionToblur () {Window.removeeventlistener (' Resize ', Toblur); Text.blur (); }})(); </script>
6. The current version of the browser does not support the prohibit scaling and maximum scaling value limit in viewport to block the default event 7. Multi-fingered operation compatible with Android there is no gestures event and needs to be encapsulated using e.touches.
Document.addeventlistener (' Touchstart ',function(e) {E.preventdefault ();});/*init:{el: Element, Start:fn, CHANGE:FN, END:FN}*/(function(){ varbox = Document.queryselector (' #box '); varstartdeg = 0; varStartscale = 0; CSS (box,"Rotate", 0); CSS (box,"Scale", 100); Gesture ({el:box, start:function(e) {Startscale= CSS (box, "scale")/100; startdeg = CSS (box, "rotate")); This. Style.background = "Blue"; }, change:function(e) {css ( This, "scale", (E.scale * startscale) *100); This. InnerHTML =e.rotation; CSS (box,"Rotate", E.rotation +startdeg); }, End:function(e) { This. Style.background = "Red"; } });}) ();functiongesture (init) {varEl =Init.el; varIsgesture =false; varStartdis = 0; varstartdeg = 0; El.addeventlistener (' Touchstart ',function(e) {if(E.touches.length >= 2) {Startdis= Getdis (e.touches[0],e.touches[1]); Startdeg= Getdeg (e.touches[0],e.touches[1]); Isgesture=true; Init.start&&Init.start.call (el,e); } }); El.addeventlistener (' Touchmove ',function(e) {if(Isgesture&&e.touches.length >= 2) {isgesture=true; varNowdis = Getdis (e.touches[0],e.touches[1]); varNowdeg = Getdeg (e.touches[0],e.touches[1]); E.scale= nowdis/startdis;//Scaling Value e.rotation = nowdeg-startdeg; Init.change&&Init.change.call (el,e); } }); El.addeventlistener (' Touchend ',function(e) {if(isgesture) {init.end&&Init.end.call (el,e); } isgesture=false; }); } functionGetdis (point,point2) {returnMath.sqrt ((Point.pagex-point2.pagex) * (Point.pagex-point2.pagex) + (point.pagey-point2.pagey) * (Point.pageY-point2.pagey));}functiongetdeg (point,point2) {vary = point.pagey-Point2.pagey; varx = Point.pagex-Point2.pagex; returnMath.atan2 (y,x)/math.pi*180;}
8. Lag problem on sliding screen prevent the default event 9.transition mobile side of the splash screen problem to turn the frame into 3D, generally do not encounter. 10. After using 3d animation, the problem of the text distortion below the 3d element to the above animated slide or the outer layer plus absolute positioning, positioning the inside and relative positioning. 11. Some Android down with file, can only call to the album, can not call the camera on input add a caption attribute, but if it is X5 or iOS browser will appear only to the camera problem, so to add a judge, judge the browser version, If it is an ISO browser or X5 browser, the add caption attribute of this renturn off 12.audio does not automatically play the problem to the document plus. Play () 13. How to tell if the network environment is wireless or traffic Navigator has all the Internet-related stuff.
Few interview questions on the mobile side