阅读背景:

PC端拖拽功能_码世界的博客_pc端拖拽

来源:互联网 
/**
 * @description: 拖动功能
 * @param {type} 
 * @return {type} 
 * @author: dhl
 */

function draggable(model) {
    var _move, _x, _y;
    $(model).click(function () {
        //alert("click");//点击(松开后触发)
        $(this).css({
            cursor: 'pointer'
        });
    }).mousedown(function (e) {
        _move = true;
        _x = e.pageX - parseInt($(model).css("left"));
        _y = e.pageY - parseInt($(model).css("top"));
        // $(model).fadeTo(20, 0.25);//点击后开始拖动并透明显示
    });
    $(document).mousemove(function (e) {
        if (_move) {
            var x = e.pageX - _x;//移动时根据鼠标位置计算控件左上角的绝对位置
            var y = e.pageY - _y;
            $(model).css({ top: y, left: x });//控件新位置
        }
    }).mouseup(function () {
        _move = false;
        // $("#formula_modal").fadeTo("fast", 1);//松开鼠标后停止移动并恢复成不透明
    });
};

draggable('#ggListSuccess');/**
 * @description: 拖动功能
 * @param {type} 
 * 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: