图标拖拽

2018-06-25  本文已影响0人  _嘿嘿_

/* 图标功能加载*/
nav : function () {
var posX;
var posY;
var fwuss = $(".quick-nav")[0];
fwuss.onmousedown = function(e) {
//鼠标聚焦
fwuss.setCapture && fwuss.setCapture();
var disX = (e || event).clientX;
var disY = (e || event).clientY;
posX = disX - fwuss.offsetLeft;//获得横坐标x
posY = disY - fwuss.offsetTop;//获得纵坐标y
//监听拖拽线高
document.onmousemove = function(ev) {
//鼠标距离
var iT = (ev || event).clientX - posX;
var eT = (ev || event).clientY - posY;
fwuss.style.margin = 0;
fwuss.style.left = iT + "px";
fwuss.style.right = "auto";
fwuss.style.top = eT + "px";
return false
}
document.onmouseup = function() {
document.onmousemove = null;
document.onmouseup = null;
fwuss.releaseCapture && fwuss.releaseCapture();
};
return false;
};

        }
上一篇下一篇

猜你喜欢

热点阅读