博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js 可拖动div 调整大小
阅读量:4700 次
发布时间:2019-06-09

本文共 2009 字,大约阅读时间需要 6 分钟。

 

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

  

转载于:https://www.cnblogs.com/hfultrastrong/p/10608758.html

你可能感兴趣的文章
excel 去掉 空单元格
查看>>
为Endnote中的期刊名称添加缩写期刊名
查看>>
pdf转换成jpg不清晰怎么办
查看>>
myeclipse An internal error occurred during: "Initialize metrics".
查看>>
WINGIDE 激活失败
查看>>
python安装 错误 “User installations are disabled via policy on the machine”
查看>>
sql server 2008 自动备份
查看>>
Android Studio 开发
查看>>
Oracle 拆分列为多行 Splitting string into multiple rows in Oracle
查看>>
Jsp编写的页面如何适应手机浏览器页面
查看>>
python里面双向队列,列表的属性和方法
查看>>
BZOJ1803Spoj1487 Query on a tree III——主席树
查看>>
C# DataTable和DataRelation
查看>>
关于slf4j+logback整合提供完善log记录的一些总结
查看>>
sqlalchemy根据数据库结构生成映射的实体
查看>>
环形数组的组最大字数组求法
查看>>
SQL命令建表
查看>>
图片上传预览 支持html5的浏览器
查看>>
开源框架收集
查看>>
[恢]hdu 2027
查看>>