搜索
查看
编辑修改
首页
UNITY
NODEJS
PYTHON
AI
GIT
PHP
GO
CEF3
JAVA
HTML
CSS
搜索
凡人多烦事01
这个屌丝很懒,什么也没留下!
关注作者
热门标签
jquery
HTML
CSS
PHP
ASP
PYTHON
GO
AI
C
C++
C#
PHOTOSHOP
UNITY
iOS
android
vue
xml
爬虫
SEO
LINUX
WINDOWS
JAVA
MFC
CEF3
CAD
NODEJS
GIT
Pyppeteer
article
热门文章
1
鸿蒙开发-工具_鸿蒙4.0 开发ide
2
【支持API调用】一键创建知识库专属大模型 AI 问答助手_模型外挂知识库
3
Vue+element-ui轮播图+放大预览_elementui里面的轮播图组件 缩略图 大图
4
mysql报错日志查看
5
Linux内核源码分析--详谈NAPI原理机制(超详细)_napi_complete
6
描述老师给了小乐乐一个正整数序列,要求小乐乐把这个序列去重后按从小到大排序。但是老师给出的序列太长了,小乐乐没办法耐心的去重并排序,请你帮助他。_在正整数序列中找到最长的由小到大的序列
7
AIGC重塑教育:AI大模型驱动的教育变革与实践_《aigc重塑教育》 pdf
8
hidl开发实践记录_hidl语法
9
Android SDK安全码组成:SHA1+包名_android平台的发布版sha1 包名都是啥
10
HTTP客户端之使用request方法向其他网站请求数据_request请求网站
当前位置:
article
> 正文
js多点触摸touch事件_document.addeventlistener('touchmove', this.touchf
作者:凡人多烦事01 | 2024-03-17 03:05:54
赞
踩
document.addeventlistener('touchmove', this.touchfunction, {
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width , initial-scale=1 , maximum-scale=1 , user-scalable=no">
<style>
body{background-color:#222;}
.spot{position:absolute; width:70px; height:70px; border-radius:35px; box-shadow:0px 0px 40px #fff; background-color:#fff; opacity:.7;}
</style>
</head>
<body>
<script>
var spots = {} , touches , timer;
document.addEventListener('touchstart',function(e){
e.preventDefault();
[].forEach.call(e.targetTouches,function(touch){
//对每一根触摸在屏幕上的手指都生成一个元素,并且用touch.identifier作为该元素的唯一标识,触摸结束后清除引用的元素
if(spots[touch.identifier]){
return;
}
var spot = spots[touch.identifier] = document.createElement('div');
spot.classList.add('spot');
spot.style.top = touch.pageY - 35;
spot.style.left = touch.pageX - 35;
document.body.appendChild(spot);
})
timer = setInterval(function() {
renderTouches(touches);
},16);
},false);
document.addEventListener('touchmove',function(e){
e.preventDefault();
touches = e.touches;
});
function renderTouches(touches){
if(!touches){
return;
};
[].forEach.call(touches,function(touch){
var spot = spots[touch.identifier];
if(spot){
spot.style.top = touch.pageY - 35;
spot.style.left = touch.pageX - 35;
}
})
}
document.addEventListener('touchend',function(e){
e.preventDefault();
[].forEach.call(e.changedTouches,function(touch){
var spot = spots[touch.identifier];
if(spot){
document.body.removeChild(spot);
delete spots[touch.indentifier];
}
})
if(e.changedTouches.length === 0){
clearInterval(timer);
}
})
//touches:表示当前位于屏幕上的所有手指动作的列表,是一个TouchList类型的对象,TouchList是一个类数组对象,它里面装的是Touch对象
//targetTouches:位于当前DOM元素上的手指动作的TouchList列表
//changedTouches:涉当前事件的手指动作的列表,例如,在一个touchend事件中,这将是移开的那根手指
//touchstart等事件在触发时是允许多个手指同时触摸屏幕的,每一根手指都会产生一个Touch对象,包含以下属性:identifier一个数字,用于唯一标识触摸会话中的当前手指,target作为动作目标的DOM元素,及坐标相关clientX/Y等
</script>
</body>
</html>
声明:
本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:
https://www.wpsshop.cn/w/凡人多烦事01/article/detail/253638
推荐阅读
article
Android
应用通过
JNI
调用
ioctl
操作设备驱动_
android
touch
jni
...
前提背景:1. 底层设备驱动已经实现
ioctl
相关操作接口2. 本篇主要讲如何实现
JNI
层和应用层的
ioctl
相关内容3...
赞
踩
article
文本
分类《Multilingual Hierarchical
attention
networks ...
Motivation:在多语言的
文本
分类问题上一般都面临两个问题:一是计算成本会随着语言数量的增加而线性增加;模型缺乏不...
赞
踩
article
无法找到打印机
microsoft
xps
document
writer
_
instaling
pri...
今天打开PPT文件时,出现了无法找到打印机
microsoft
xps
document
writer
这个提示。 出现这个...
赞
踩
article
HTC
Touch
Pro2
手机
安装
XDAndroid
2.2
Final
方法(自己尝试了一下,留个...
1.下载
XDAndroid
包 进入这个网站: http://htcandroid.xland.cz/ 找到以XDANDR...
赞
踩
article
signature
=
118e844de9fea3f1fc98782813f19425
,Documen...
ExhibitCONTACT:FOR IMMEDIATE RELEASEBryan R. McKeagJuly 23, ...
赞
踩
article
移动
互联网终端的
touch
事件,
touch
start,
touch
end,
touch
move...
前言 如果我们允许用户在页面上用类似桌面浏览器鼠标手势的方式来控制WEB APP,这个页面上肯定是有很多可点击区域的,如...
赞
踩
相关标签
android
java
linux
ioctl
文本分类
分层注意力
microsoft
扩展
htc
手机
磁盘
电话
浏览器
signature=118e844de9fea3f1fc98782813f19425
移动互联网终端
touch事件
touchstart
touchend
touchmove