Mobile-touch events and objects

Source: Internet
Author: User

<! DOCTYPE html>
<meta charset= "Utf-8" >
<meta name= "viewport" content= "initial-scale=1.0, maximum-scale=1.0, User-scalable=no"/>
<title></title>
<body>
<div class= "One" >hehehehehehe</div>
<div class= "both" >hahhahhahaha</div>
<script type= "Text/javascript" >
/*
*clientx: Touch the x-coordinate of the target in the viewport.
*clienty: Touch the y-coordinate of the target in the viewport.
*identifier: Identifies the unique ID of the touch.
*pagex: Touch the x-coordinate of the target in the page.
*pagey: Touch the y-coordinate of the target in the page.
*screenx: Touch the x-coordinate of the target in the screen.
*screeny: Touch the y-coordinate of the target in the screen.
*target: The target DOM node of the touch destination.
The *touches:touch object, which contains some coordinate information.
* The Targettouches:touch object, which contains coordinate information, is unclear, if length represents the number of fingers.
* Changedtouches:touch object, contains coordinate information, the situation is unclear.
* */
Monitor finger swipe
Document.addeventlistener (' Touchmove ', function (event) {
var x = Event.touches[0].clientx;
var y = event.touches[0].clienty;
var identifier = Event.touches[0].identifier;
var PageX = Event.touches[0].pagex;
var pagey = Event.touches[0].pagey;
var ScreenX = Event.touches[0].screenx;
var ScreenY = Event.touches[0].screeny;
var target = Event.touches[0].target;
Console.log (X,y,identifier,pagex,pagey,screenx,screeny,target)
Console.log (Event.targetTouches.length)
Console.log (' 2: ', event.changedtouches)
});
Monitor Touch
Document.addeventlistener (' Touchstart ', function (event) {
Alert (1)
//});
Listening Touch End
Document.addeventlistener (' Touchend ', function () {
Alert (3)
// });
</script>

</body>

Mobile-touch events and objects

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.