current position:Home>How to use HTML for touch event in mobile terminal

How to use HTML for touch event in mobile terminal

2022-04-29 17:25:27Billion cloud speed

HTML In the mobile end touch How do events work

This article mainly introduces HTML In the mobile end touch Knowledge of how events are used , The content is detailed and easy to understand , The operation is simple and fast , It has certain reference value , I believe that after reading this article HTML In the mobile end touch How to use the event, the article will gain something , Let's have a look .

1.touchstart

Trigger when your finger touches the screen

dom.addEventListener('touchstart',function(e){});startX=e.touches[0].clientX;

The event returns e Object contains properties unique to the mobile terminal :
tarchTouches: All current touches of the target element
changedTouches: All newly changed touches on the page
touches: All the touches on the page

2.touchmove

Trigger continuously when fingers slide on the screen

dom.addEventListener('touchmove',function(e){});

The event returns e Object contains properties unique to the mobile terminal :
tarchTouches: All current touches of the target element
changedTouches: All newly changed touches on the page
touches: All the touches on the page

3.touchend

Trigger when the finger leaves the screen

dom.addEventListener('touchend',funciton(e){});// stay touchend in ,touches Can't get touch object ,// Because the touch is over ,changedTouches Get the touch object in //console.log(e);//endX=e.touches[0];  undefined endX=e.changedTouches[0].clientX;

The event returns e Object contains properties unique to the mobile terminal :
changedTouches: All newly changed touches on the page
touchcancel: When the system stops tracking the touch, it will trigger .( Not often )
stay touchend At the time of the event ,event Notification record changeTouches

4. e.touches[0]

clientX: Touch the target in the X coordinate .
clientY: Touch the target in the Y coordinate .
pageX: Touch the target in the x coordinate .
pageY: Touch the target in the y coordinate .
screenX: Touch the target in the x coordinate .
screenY: Touch the target in the y coordinate .

About “HTML In the mobile end touch How do events work ” That's all for this article , Thank you for reading ! I'm sure you're right “HTML In the mobile end touch How do events work ” Knowledge has a certain understanding , If you want to learn more , Welcome to the Yisu cloud industry information channel .

copyright notice
author[Billion cloud speed],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204291539468011.html

Random recommended