zoukankan      html  css  js  c++  java
  • DIV 实现可拖拽 功能(留档)

    //可拖拽 功能

    $.fn.extend({
        //用法:$(element).jqDrag();
        //element需要具备定位属性,需要手动调整层叠样式,这里只是修改鼠标拖动效果
        jqDrag: function () {

            var _drag = false, _self, _x, _y, cw, ch, sw, sh, dragBar, DragCnt,
                vxw = window, vxd = document, vxe = vxd.documentElement, vxg = vxd.getElementsByTagName('body')[0],
                //dragContent = (typeof dragContent == "undefined") ? dragControl : dragContent;
            _self = this;
            DragCnt = $(_self);
            DragBar = $(".dragbar", DragCnt);

            DragBar.mouseup(function (e) {
                _drag = false;
                document.body.releaseCapture && this.releaseCapture();;
            }).mousedown(function (e) {
                _drag = true;
                _x = e.pageX - parseInt(DragCnt.css("left"));
                _y = e.pageY - parseInt(DragCnt.css("top"));
                winW = vxw.innerWidth || vxe.clientWidth || vxg.clientWidth;
                winH = vxw.innerHeight || vxe.clientHeight || vxg.clientHeight;
                cw = winW;
                ch = winH;
                sw = parseInt(DragCnt.outerWidth());
                sh = parseInt(DragCnt.outerHeight());
                window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
                document.body.setCapture && this.setCapture();
                $(document).mousemove(function (e) {
                    DragCnt.attr("posit", _x + "" + e.pageX);
                    if (_drag) {
                        var x = e.pageX - _x;
                        var y = e.pageY - _y;
                        x = x < 0 ? x = 0 : x < (cw - sw) ? x : (cw - sw);
                        y = y < 0 ? y = 0 : y < (ch - sh) ? y : (ch - sh);

                        DragCnt.css({ top: y, left: x });
                        DragCnt.attr("posit", x + "_" + y);
                    }
                });
            });
        }
    });

  • 相关阅读:
    MD5,SHA1,SHA256,SHA512等常用加密算法
    Encoding.GetEncoding 编码列表
    Form开发小技巧
    全国分河流水系流域边界及河流数据水系及主要流域分界图
    建筑物轮廓自然保护区城市AOI水土保持水资源水文建成区生态功能分区矢量数据shptabdwgcdr
    坐标转换一些
    mysql 查询语言使用 lisoaring
    lisoaring python 字符串 编码
    全国各省乡镇街道边界行政区划矢量地图shpmapinfocad最新20101112131415 161718
    写第一篇 随笔
  • 原文地址:https://www.cnblogs.com/evablog/p/3591619.html
Copyright © 2011-2022 走看看