//本来要给火狐提交bug的,发现复现不鸟,我勒个去
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<style>
html,body{
width:100%;
height:100%;
}
body{
position:relative
}
section{
position:absolute
}
.s1{
left:10px;
}
.s2{
left:40px;
}
.s3{
left:80px
}
input{
display:none;
outline:none
}
</style>
<body>
<section class="s1">
11
</section>
<section class="s2">
11
</section>
<section class="s3">
11
</section>
<input type="text">
<script>
var Drag = function( e ){
this.e = typeof e === "string" ? document.getElementById(e) : e;
this.initDrag();
}
Drag.prototype = {
zIndex : 0,
constructor : Drag,
initDrag : function(){
this.e.addEventListener("mousedown",this.ev.bind(this));
},
ev : function(e){
switch(e.type){
case "mousedown":
this.dx = e.clientX - this.e.offsetLeft;
this.dy = e.clientY - this.e.offsetTop;
this.e.zIndex = this.zIndex++;
this.fn = this.ev.bind(this);
document.addEventListener("mousemove",this.fn);
document.addEventListener("mouseup",this.fn);
break;
case "mousemove":
this.e.style.left = e.clientX - this.dx + "px";
this.e.style.top = e.clientY - this.dy + "px";
break;
case "mouseup":
document.removeEventListener("mouseup",this.fn)
document.removeEventListener("mousemove",this.fn)
break;
};
e.cancelBubble = true;
e.defaultPrevented = true;
e.stopPropagation();
e.preventDefault();
return
}
};
Array.prototype.slice.call(document.querySelectorAll("section"),null).forEach(function(e,i){
new Drag(e);
e.addEventListener("mouseup",function(){
var css = Object.create( window.getComputedStyle(e,null) ),
t = parseInt(css.top) + "px",
l = parseInt(css.left) + "px";
/************************************/
e.style.left = 0;
e.style.top = 0;
/************************************/
console.log( window.getComputedStyle(e,null).left )
console.log( window.getComputedStyle(e,null).top )
e.style.left = l
e.style.top = t
});
});
</script>
</body>
</html>

  

bugzilla_firefox的更多相关文章

随机推荐

  1. 51nod-1661 1661 黑板上的游戏(组合游戏)

    题目链接: 1661 黑板上的游戏 Alice和Bob在黑板上玩一个游戏,黑板上写了n个正整数a1, a2, ..., an,游戏的规则是这样的:1. Alice占有先手主动权.2. 每个人可以选取一 ...

  2. Android UI组件----ListView列表控件详解

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  3. JavaWeb学习----JSP脚本元素、指令元素、动作元素

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...

  4. AC日记——机器翻译 洛谷 P1540

    题目背景 小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章. 题目描述 这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义来替换.对于每个英文单词,软件会先 ...

  5. java 15 -7 ListIterator 的特有方法

    列表迭代器:  ListIterator listIterator():List集合特有的迭代器 该迭代器继承了Iterator迭代器,所以,就可以直接使用hasNext()和next()方法. 特有 ...

  6. php strcmp引起的问题

    在官方的文档有这么一端说明: Note a difference between 5.2 and 5.3 versions echo (int)strcmp('pending',array()); w ...

  7. 颗粒翻页(css3效果展示)

    用css3效果做了一个颗粒翻页效果,布局上,一张图片做底层,在这张图片上用js创建一层小的行和列各为r和c的小span,给这些span分别设置background-position:用来覆盖原来的一张 ...

  8. Maven 的 HelloWorld

    <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...

  9. flex 3 rows layout

    html,body{height:100%} .wraper{ display:flex; flex-direction:column; height:100%; flex-wrap: nowrap; ...

  10. crontab任务取消发送邮件

    1. 方式一,每一个计划任务后加上 >/dev/null 2>&1 */5 * * * * sh /web/adm/Shell/checkin_user_count_everyda ...