移动端页面防止左右滑动出现黑色背景
来源:互联网 发布:淘宝追加评论怎么写 编辑:程序博客网 时间:2024/05/17 17:40
<meta name="full-screen" content="yes">
在head中加入如上2条代码,将页面设置成全屏模式
//监听手指滑动触发事件,设置系统对左右滑动事件不做出处理。
window.onload=function(){
var xx, yy, XX, YY, swipeX, swipeY;
var div = document.getElementsByTagName("div");
document.body.addEventListener('touchstart', function(event) {
xx = event.targetTouches[0].screenX;
yy = event.targetTouches[0].screenY;
swipeX = true;
swipeY = true;
})
document.body.addEventListener('touchmove', function(event) {
XX = event.targetTouches[0].screenX;
YY = event.targetTouches[0].screenY;
if (swipeX && Math.abs(XX - xx) - Math.abs(YY - yy) > 0) //左右滑动
{
event.stopPropagation();//组织冒泡
event.preventDefault();//阻止浏览器默认事件
swipeY = false;
//左右滑动
} else if (swipeY && Math.abs(XX - xx) - Math.abs(YY - yy) < 0) { //上下滑动
swipeX = false;
//上下滑动,使用浏览器默认的上下滑动
}
})
}
- 移动端页面防止左右滑动出现黑色背景
- 移动端、移动开发 点击事件后出现闪或者黑色背景
- android实现页面背景的左右移动
- 在滑动listview时,部分item出现背景黑色
- 关于移动端点击后出现闪或者黑色背景
- 关于移动端点击后出现闪或者黑色背景
- 关于移动端点击后出现闪或者黑色背景
- UIWebView隐藏右侧和底部滚动条,去掉滚动边界的黑色背景,禁止左右滑动
- 如何解决iphone手机微信浏览器中滑动到页面底部出现黑色背景盖住position:fixed的页面元素的问题?
- jQuery 滚动条插件之移动端 左右滑动不出现滚动条
- 手机端左右滑动,不用写js(只有页面切换到移动端可以看)
- 移动端实现导航的左右滑动
- 移动端左右上下滑动识别
- 移动端图片左右滑动效果
- 移动端按钮组左右滑动
- 页面左右滑动效果
- ListView滑动时 item出现黑色背景的问题的解决方法
- ListView滑动时 item出现黑色背景的问题的解决方法
- iconfont字体图标的使用
- 11g 单机 asm
- 深度解析CyclicBarrier源码
- Caffe学习笔记(一):Caffe架构及其模型解析
- 设置Eclipse的类文件和xml文件代码自动补全
- 移动端页面防止左右滑动出现黑色背景
- android 适配工具
- IDEA 初始配置教程
- iOS URL编码&base64编码
- 网易游戏测试工程师(QA)全天面试笔记和面试经历整理分享
- [Leetcode] Contains Duplicate
- Scala 偏函数和偏应用函数
- MySQL5.7更改密码时出现ERROR 1054 (42S22): Unknown column 'password' in 'field list'
- Android6.0动态权限申请步骤以及需要注意的一些坑