touch--Mobile End

Source: Internet
Author: User

Touch Event native must be bound with AddEventListenerFirst, the native
    • Touchstart: triggered when touch starts
    • Touches: List of all fingers currently on the screen
      • Event.touches.length: Record the hand index touched by the moment
      • Event.touches[0].screenx: Record the x-axis position of the first finger on the screen
      • Event.touches[0].screeny: Record the position of the first finger on the y-axis of the screen
    • Touchmove: Triggers when a finger moves through the screen
    • Touchend: Trigger at end of touch
To prevent the page from toggling when you swipe the screen, you typically add a block default event:
Document.addeventlistener ("Touchstart",function  () {    event.preventdefault ();},false );
Second, touch.js
    • Format:
      • Touch.on (obj, "", listener);
      • Obj: Object, not acquired, such as: #div等
      • "": Inside for the move event
      • Listener: Functions function () {}
    • Drag: Grabbing and dragging a target
    • Touch.on ("#div1", "drag",function  (EV) {console.log (ev.x// moving x/y axis distance });
    • Dragend: Trigger at end of drag
    • Swipe: swipe finger trigger
      • Swipeleft: Swipe left to trigger
      • Swiperight: Swipe right to trigger
      • Swipeup: Swipe down to trigger
      • Swipedown: Swipe up to trigger
    • Tap: Click once to Trigger
    • DOUBLETAP: Double-click Trigger
  • Pinch: Capture gesture (zoom in or zoom out)
      • Ev.scale: Capturing a multiple of magnification
      • Obj.style.webkitTransform = "scale (" +ds+ ")"; // set the magnification/zoom factor for the original

  • Rotate: Rotation (two fingers)
      • Touch.on ("#div1", "rotate",function  (EV) {var//ev.rotation Capture the angle of the current rotation if // Ev.fingerstatus capture Current finger State (start/motion/end)angle=newangle;}  This // Setting the transform angle });

  • Add in Touchstart:
      • Touch.on ("#div1", "Touchstart",function// can be rotated with a single finger ev.preventdefault ();});
Third, mobile event--deviceorientation (can do gravity game)
    • EVENT.BETA:X Shaft
    • EVENT.GAMMA:Y Shaft
    • EVENT.ALPHA:Z Shaft

touch--Mobile End

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.