美文网首页
图标拖拽

图标拖拽

作者: _嘿嘿_ | 来源:发表于2018-06-25 12:52 被阅读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;
    };

            }

    相关文章

      网友评论

          本文标题:图标拖拽

          本文链接:https://www.haomeiwen.com/subject/agfyyftx.html