Before you begin to describe the touch event, you need to describe the touch objects that are unique to the multi-touch system (Android and iOS, and even Nokia's newest Meego systems emulate similar objects). This object encapsulates a screen touch, usually from a finger. It is generated when the touch event is triggered and can be taken from the event object of the touch events handler
The effect of mobile touch screen sliding is actually the picture carousel, which is well implemented on the PC's page, binding the click and MouseOver events to complete. But on mobile devices, to achieve this kind of carousel effect, you need to use the core touch event. Handle touch events to track each finger to the screen slide.
Here are four kinds of touch events
Touchstart: Triggers when the finger is placed on the screen
Touchmove://finger on-screen swipe trigger
Touchend://trigger when finger leaves screen
Touchcancel://The system cancels the touch event when triggered, this seems to be less use
Once each touch event is triggered, an event object is generated and the event object includes the following three touch lists in addition
Touches://List of all fingers on the current screen
Targettouches://The list of fingers on the current DOM element, try to use this instead of touches
Changedtouches://List of fingers that involve the current event, try to use this instead of touches
Each touch in these lists consists of the touch object, which contains the touching information, with the following main attributes:
Clientx/clienty://Touch point relative to the location of the browser window
Pagex/pagey://Touch point relative to the position of the page
Screenx/screeny://Touch point relative to the position of the screen
Identifier: ID of the//touch object
Target://Current DOM element
Attention:
When you swipe the entire screen, your finger affects the browser's behavior, such as scrolling and zooming. So when you invoke the touch event, be careful to suppress zooming and scrolling.
1. Disable zooming
Set with meta meta tags.
2. Disable scrolling
Preventdefault is blocking the default behavior, and the default behavior of the touch event is scrolling.
Event.preventdefault ();
Use case:
<! DOCTYPE html>