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');
    

      

  • 相关阅读:
    Mac 下的 Homebrew 简介及安装
    配置Mac打开ntfs的外设磁盘硬盘的原生读写/Mac OS上使用不同格式的磁盘
    ztree使用 (一) 递归后台的数据
    springboot整合redis 配置文件及配置类(二)
    springboot整合redis 配置文件及配置类(一)
    java登录拦截器
    获取小程序二维码
    java合成图片
    微信 获取手机号
    js+html5点击赋值到剪贴板
  • 原文地址:https://www.cnblogs.com/hfultrastrong/p/10608758.html
Copyright © 2011-2022 走看看