zoukankan      html  css  js  c++  java
  • js 可拖动div 调整大小

    dragBorder: function (parent, right, bottom, bottomRight) {
        var isDownRight = false;
        var isDownBottom = false;
    
        var doc = $(document);
        var p = $('#' + parent);
        var r = $('#' + right);
        var b = $('#' + bottom);
        var br = $('#' + bottomRight);
    
        var mouseStartPos = {};
    
        r.mousedown(function (e) {
            isDownRight = true;
            mouseStartPos.x = e.clientX;
            mouseStartPos.y = e.clientY;
        });
        b.mousedown(function (e) {
            isDownBottom = true;
            mouseStartPos.x = e.clientX;
            mouseStartPos.y = e.clientY;
        });
        br.mousedown(function (e) {
            isDownBottom = true;
            isDownRight = true;
            mouseStartPos.x = e.clientX;
            mouseStartPos.y = e.clientY;
        });
    
        var opw = p.width();
        doc.mousemove(function (e) {
            // right
            if (isDownRight) {
                var l = e.clientX - mouseStartPos.x;
                var w = parseInt(l) + parseInt(opw);
                p.width(w);
            }
        });
        var oph = p.height();
        doc.mousemove(function (e) {
            // bottom
            if (isDownBottom) {
                var t = e.clientY - mouseStartPos.y;
                var h = parseInt(t) + parseInt(oph);
                p.height(h);
            }
        });
        doc.mousemove(function (e) {
            // bottomRight
            if (isDownBottom) {
                var l = e.clientX - mouseStartPos.x;
                var w = parseInt(l) + parseInt(opw);
                p.weight(w);
                var t = e.clientY - mouseStartPos.y;
                var h = parseInt(t) + parseInt(oph);
                p.height(h);
            }
        });
    
        r.mouseup(function () {
            isDownRight = false;
            opw = p.width();
        });
        b.mouseup(function () {
            isDownBottom = false;
            oph = p.height();
        });
        br.mouseup(function () {
            isDownBottom = false;
            isDownRight = false;
            opw = p.width();
            oph = p.height();
        });
    }
    

      

    this.dragBorder('chatWindow', 'chatRightGragClass', 'chatBottomGragClass', 'chatblockGragClass');
    

      

  • 相关阅读:
    实线矢量元素提取
    matlab写txt文件
    matlab之boundary()函数
    matlab之flipud()函数
    matlab unique()函数
    KD-tree
    matlab之细胞数组
    matlab的代码注释
    matlab中的try...catch...end
    (转)MySQL 加锁处理分析
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/10608758.html
Copyright © 2011-2022 走看看