1. If the jquery binding event is used, touch obtain the touchstart touchmove contact coordinates, e.originalEvent.targetTouches[0].pageX
Access touchend is usede.originalEvent.changedTouches[0].pageX
2. In some versions iphone4 , audio and the video default playback events do not trigger
such as window.onload the use or timer can not trigger playback, you must use JS the write event to let the user manually click on the trigger to start playback, such as
$(document).one(‘touchstart‘,function(){ audio.play(); })
3.想要在touchmove:function(e,参数一)加一个参数,结果直接使用e.preventDefault()就会 e 报错,处理方法为
Touchmovefunction(e, parameter i) {var e=arguments[0]; E.preventdefault (); }
4. Click on an element, the use touchstart will be triggered immediately, and the use click of the approximate 0.3s delay
There are two ways to simulate a Click event that is triggered immediately.fastclick.jsAndzepto.jsIn thetapEvent
5. zepto The incident, however, tap has an incident penetrating issue.
If you have tap a popup layer element (this element masks a a label), this element disappears immediately, so that the 0.3s delay tap event is passed to the a tag as an click event causing the A-tag to jump.
in the example above, the solution depends on the situation:
tap Let the Mask fade away when ①, this process will 400ms not penetrate to the next level.
② is touchend added in the event callback preventDefault and added in the next layer pointer-events:none . (This is useless)
③ sometimes such as pop up a iphone slide out of the layer, click on the Black Translucent area pop-up layer disappears, this can be in black area binding touchend is also tap similar effect
1. When the pop-up window appears, want to prohibit the screen slide, add an event to the mask layer, touchmove with e.preventDefault() the blocking scroll , and click so on off , and then lost,
$ ( "Touchmove", function (E) {e.preventdefault (); });
2. When uploading a file using input file , you can specify the accepted type, accept= "Image/png,image/jpeg,image/gif" ,
the camera is not available on Android at the same time, you can add capture= "Camera"
at the same time, because the native style does not look good, You can trigger the INPUT element's click by setting the Display:none of input and then using Id.click ().
3. Add: Active Pseudo-class, if the requirement is high, compatibility is good, you have to use JS monitor Touchstart and then add the corresponding class
$(document).on("touchstart", function(e) { var target = $(e.target); if (target.hasClass("is_hover")) { target.addClass("hover_css"); } });
Mobile-Side JS Knowledge Summary