Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use HTML touch event on Mobile

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use HTML touch event in mobile terminal, the content is detailed and easy to understand, the operation is simple and fast, and it has certain reference value. I believe everyone will gain something after reading this article on how to use HTML touch event in mobile terminal. Let's take a look at it together.

1.touchstart

Trigger when finger touches screen

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

The e object returned by the event contains mobile-specific attributes:

tarchTouches: all current touches of the target element

changedTouches: all recently changed touches on the page

touches: all touches on the page

2.touchmove

Triggers continuously as your finger slides across the screen

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

The e object returned by the event contains mobile-specific attributes:

tarchTouches: all current touches of the target element

changedTouches: all recently changed touches on the page

touches: all touches on the page

3.touchend

Trigger when finger leaves screen

dom.addEventListener ('touchend ',funciton(e){});//Touches can't get touch object in touchend,//because touch has ended, changedTouches gets touch object//console.log (e);//endX=e.touches[0]; undefined endX=e.changedTouches [0].clientX;

The e object returned by the event contains mobile-specific attributes:

changedTouches: all recently changed touches on the page

touchcancel: Triggered when the system stops tracking touches. (Not often used)

event notification records changeTouches at the time of the touchend event

4. e.touches[0]

clientX: Touch the X coordinate of the target in the viewport.

clientY: Touch the Y coordinate of the target in the viewport.

pageX: X coordinate of the touch target in the page.

pageY: y coordinate of the touch target in the page.

screenX: Touch the x coordinate of the target on the screen.

screenY: Touch the y coordinate of the target on the screen.

The content of this article on "How to use HTML touch events in mobile" is introduced here. Thank you for reading! I believe everyone has a certain understanding of the knowledge of "how to use HTML touch events in mobile terminal." If you still want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report