当前位置:网站首页>JS Touch
JS Touch
2022-06-10 18:51:00 【SeriousLose】
$("body").on("touchstart", function(e) {
e.preventDefault();
startX = e.originalEvent.changedTouches[0].pageX,
startY = e.originalEvent.changedTouches[0].pageY;
});
$("body").on("touchmove", function(e) {
e.preventDefault();
moveEndX = e.originalEvent.changedTouches[0].pageX,
moveEndY = e.originalEvent.changedTouches[0].pageY,
X = moveEndX - startX,
Y = moveEndY - startY;
if ( Math.abs(X) > Math.abs(Y) && X > 0 ) {
alert("left 2 right");
}
else if ( Math.abs(X) > Math.abs(Y) && X < 0 ) {
alert("right 2 left");
}
else if ( Math.abs(Y) > Math.abs(X) && Y > 0) {
alert("top 2 bottom");
}
else if ( Math.abs(Y) > Math.abs(X) && Y < 0 ) {
alert("bottom 2 top");
}
else{
alert("just touch");
}
});
边栏推荐
猜你喜欢

Vcsa7u3c installation tutorial

二叉树之Morris遍历

Adobe Premiere Foundation (animation production - Flexible animation) (VIII)

Adobe Premiere基础(动画制作-弹性动画)(八)

The value of Bi in the enterprise: business analysis and development decision

Stream流的常用方法-Lambder

5. golang generics and reflection

Adobe Premiere基础(视频的最后一步字幕添加)(六)

数据处理时代,数据分析成为基础建设

基础提升---树形DP补充
随机推荐
位运算题目
阵列信号处理仿真之四——Z变换分析阵列多项式
ETL的使用过程中遇到的坑(ETL中文乱码)
Db2 SQL PL简介
AFL fuzzy multithreading
AGI基础,不确定性推理,主观逻辑一书ppt2
VMware vCenter 各版本号对照表
Three ways generated by stream lambda
Adobe Premiere基础(轨道相关)(五)
Adobe Premiere基础-工具使用(选择工具,剃刀工具,等常用工具)(三)
商业智能BI的价值,可视化报表等于商业智能BI吗?
Wireshark学习笔记(一)常用功能案例和技巧
Adobe Premiere basic special effects (card point and transition) (IV)
Adobe Premiere基础-介绍,配置,快捷键,创建项目,创建序列(一)
After the qtmqtt source code compilation is set to keepalive, the Ping package timeout error does not return a problem repair (qmqtt:: mqttnopingresponse, qmqtt:: clientprivate:: onpingtimeo)
&& 与 ||
IBOX系统开发核心功能和部分核心源码
[kuangbin] topic 12 basic DP1
单调栈结构
Vcsa7u3c installation tutorial