touch.js2
2016-07-13 19:26
447 查看
<!DOCTYPE html>
<html>
<head>
<meta
charset="UTF-8">
<title></title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=0">
<style
type="text/css">
body
{
color: deeppink;
background-color:
#222222;
}
/* 给光点加上像光点的样式 */
.spot
{
position:
absolute;
width:
70px;
height:
70px;
border-radius:
50%;
background-color: ghostwhite;
box-shadow:
0px
0px 40px
#fff;
opacity:
0.8;
}
</style>
</head>
<body>
点击预览
<script
type="text/javascript">
var
spot = null;
document.addEventListener("touchstart",
function(ev) {
ev.preventDefault();
// 阻止默认事件
// 创建小div
if(spot) {
return;
}
else {
spot
= document.createElement("div");
spot.className
= "spot";
spot.style.left
= event.touches[0].pageX
- 35 +
"px";
spot.style.top
= event.touches[0].pageY
- 35 +
"px";
document.body.appendChild(spot);
}
document.addEventListener("touchmove",
function(ev) {
if
(spot) {
spot.style.left
= ev.touches[0].pageX
- 35 + "px";
spot.style.top
= event.touches[0].pageY
- 35 +
"px";
}
},
false);
}, false);
document.addEventListener("touchend",
function(ev) {
ev.preventDefault();
// 阻止默认事件
// 删除div
if(spot) {
document.body.removeChild(spot);
spot
= null;
}
}, false);
</script>
</body>
</html>
<html>
<head>
<meta
charset="UTF-8">
<title></title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=0">
<style
type="text/css">
body
{
color: deeppink;
background-color:
#222222;
}
/* 给光点加上像光点的样式 */
.spot
{
position:
absolute;
width:
70px;
height:
70px;
border-radius:
50%;
background-color: ghostwhite;
box-shadow:
0px
0px 40px
#fff;
opacity:
0.8;
}
</style>
</head>
<body>
点击预览
<script
type="text/javascript">
var
spot = null;
document.addEventListener("touchstart",
function(ev) {
ev.preventDefault();
// 阻止默认事件
// 创建小div
if(spot) {
return;
}
else {
spot
= document.createElement("div");
spot.className
= "spot";
spot.style.left
= event.touches[0].pageX
- 35 +
"px";
spot.style.top
= event.touches[0].pageY
- 35 +
"px";
document.body.appendChild(spot);
}
document.addEventListener("touchmove",
function(ev) {
if
(spot) {
spot.style.left
= ev.touches[0].pageX
- 35 + "px";
spot.style.top
= event.touches[0].pageY
- 35 +
"px";
}
},
false);
}, false);
document.addEventListener("touchend",
function(ev) {
ev.preventDefault();
// 阻止默认事件
// 删除div
if(spot) {
document.body.removeChild(spot);
spot
= null;
}
}, false);
</script>
</body>
</html>
相关文章推荐
- Android的Touch事件处理机制介绍
- 一天一个shell命令 linux文本操作系列-touch命令用法
- js的touch事件的实际引用
- javascript移动开发中touch触摸事件详解
- Android判断touch事件点是否在view范围内的方法
- Android Touch事件分发深入了解
- Android Touch事件分发过程详解
- Sench Touch 监听滚动事件
- Secnha Commands 3 使用详解(从创建到打包)
- sencha touch 彩色图标按钮(button+ico)
- 一天一个shell命令 linux文本操作系列-touch命令用法
- 谁说3D Touch仅是鸡肋? 苹果正在靠它下一盘大旗
- 指尖下的js ——多触式web前端开发之一:对于Touch的处理
- Android 编程下 Touch 事件的分发和消费机制
- Linux下查看 && 修改文件的时间属性
- linux 命令-- touch
- 随记:关于linux setUID
- shell命令find删除修改后带尾巴的重复的文件
- shell命令find删除修改后带尾巴的重复的文件