当前位置:网站首页>DOM series of touch screen events
DOM series of touch screen events
2022-08-01 16:02:00 【Old __L】
Directory
1. Overview of touch screen events
The compatibility of mobile browsers is good. We don't need to consider the compatibility of previous JS, and we can use native JS writing effects with confidence, but the mobile terminal also has its own unique features.For example, the touch screen event touch (also called touch event), both Android and IOS have.
Thetouch object represents a touch point.The touch point may be a finger or a stylus.Touch events respond to user finger (or stylus) operations on the screen or trackpad.
2. Common touch screen events
3. TouchEvent Object (TouchEvent)
TouchEvent is a class of events that describe the state change of a finger on a touch plane (touch screen, touchpad, etc.).This type of event is used to describe one or more touchpoints, allowing developers to detect movement of touchpoints, increase and decrease of touchpoints, etc.
The three events touchstart, touchmove, and touchend will have their own event objects.
Touch Event Objects Focus on a list of three common objects:
Because we usually register touch events for elements, so focus on remembering targetTocuhes
4. Drag elements on the mobile side
- touchstart, touchmove, touchend can drag elements;
- But dragging the element needs the coordinate value of the current finger, we can use pageX and pageY in targetTouches[0];
- Principle of dragging on the mobile terminal: When the finger is moving, the distance the finger moves is calculated.Then use the original position of the box + the distance moved by the finger;
- The distance the finger moves: the position in the slide of the finger minus the position where the finger just started to touch;
4.1. Triad of dragging elements
(1), touch element touchstart: get the initial coordinates of the finger, and at the same time get the original position of the box;
(2) move the finger touchmove: calculate the sliding distance of the finger, and move the box;
(3) leaveFinger touchend:
Note: finger movement will also trigger scrolling, so here to prevent the default screen scrolling
e.preventDefault()
;
Afterword
If you feel that the article is not good
//(ㄒoㄒ)//
, leave a message in the comments, the author will continue to improve;o_O???
If you think the article is a little useful, you can give the author a like;\\*^o^*//
If you want to make progress with the author, you can Scan the QR code on WeChat and follow the front-end old L;~~~///(^v^)\\\~~~
Thank you readers(^_^)∠※
!!!
边栏推荐
- 接口测试框架开发实践5:配置文件读取
- 27英寸横置大屏+实体按键,全新探险者才是安全而合理的做法!
- 信息录入率百分百上海强化施工现场建筑工人实名制管理
- leetcode:33. 搜索旋转排序数组
- Zhaoqi Science and Technology Innovation Event Platform, Entrepreneurship Event Roadshow, Online Live Roadshow
- shell 基础之函数编写
- May 20, 2022 The most complete fish game navigation
- Zhaoqi Science and Technology Innovation Platform attracts talents and attracts talents, and attracts high-level talents at home and abroad
- 引用js报错$ is not defined解决办法
- "Find nearby shops" | Geohash+MySQL realizes geographic location filtering
猜你喜欢
Spark: Cluster Computing with Working Sets
到底什么才是真正的商业智能(BI)
南京科技大学、中国电子科技第28研究所等联合|MLRIP: Pre-training a military language representation model with informative factual knowledge and professional knowledge base(预训练具有丰富事实知识和专业知识库的军事语言表示模型)
ESP8266-Arduino编程实例-MLX90614红外测温传感器驱动
DOM树jsjs特效代码
gconf/dconf编程实战(1)gconf和dconf介绍
使用Canvas 实现手机端签名
shell 基础之函数编写
月薪12K,蝶变向新勇往直前,我通过转行软件测试实现月薪翻倍...
RepOptimizer学习笔记
随机推荐
MySQL:索引
pwnhome 个人博客快速索引(持续更新)
股票策略02 | 技术择时+行业因子+市值轮动
pynlpir更新license Error: unable to fetch newest license解决方案
27英寸横置大屏+实体按键,全新探险者才是安全而合理的做法
如何防止重复下单?
bug- 切换代理服务器与同步 bug
【无标题】
0-1背包问题的一维数组优化解析
便携烙铁开源系统IronOS,支持多款便携DC, QC, PD供电烙铁,支持所有智能烙铁标准功能
DOM系列之classList属性
Slider/Carousel图片切换支持触摸屏
gconf/dconf实战编程(2)利用gconf库读写配置实战以及诸多配套工具演示
MUI 做手机返回操作栏
HashCode technology insider interview must ask
HDU 2602: Bone Collector ← 0-1背包问题
尾牙宴是什么
MySQL查询上的问题
使用Canvas实现网页鼠标签名效果
80篇国产数据库实操文档汇总(含TiDB、达梦、openGauss等)