zoukankan      html  css  js  c++  java
  • jquery之窗口拖动




       $("#showTitle").mousedown(function (e) {
            vbool = true;
            vHeight = e.pageY;
            vWidth = e.pageX;
            cHeight = vHeight - $("#show").offset().top;
            cWdith = vWidth - $("#show").offset().left;
            //alert("divshow" + $("#show").offset().top + " divvHeight" + vHeight);
            //alert("高" + cHeight + " 宽" + cWdith);
        })
        $(document).mouseup(function () {
            vbool = false;
        })
        var showWidth = $("#show").width();
        var showHeight = $("#show").height();
        var documentWidth = $(document).width();
        var documentHeight = $(document).height();
        $(document).mousemove(function (e) {
            if (vbool) {
                var divheight = e.pageY - cHeight;//窗口要移动到的位置
                var divwidth = e.pageX - cWdith;//窗口要移动到的位置
                $("#la1").text(divheight + "w" + divwidth + "win" + showWidth + " x " + documentWidth + "" + showWidth);
                if (divwidth < 0) {
                    divwidth = 0;
                }
                if (divheight < 50) {
                    divheight = 50;
                }
                if (divwidth > documentWidth - showWidth) {
                    divwidth = documentWidth - showWidth - 5;
                }
                if (divheight > documentHeight - showHeight) {
                    divheight = documentHeight - showHeight - 5;
                }
                $("#show").css({ "left": divwidth, "top": divheight });
            }
        })




     

  • 相关阅读:
    生成器
    各种表达式
    迭代器
    闭包函数及装饰器
    名称空间及作用域
    函数的嵌套
    函数对象
    OpenSSL Heartbleed “心脏滴血”漏洞简单攻击示例
    PHP函数usort是咋回事?还能当后门?
    CVE-2017-7269—IIS 6.0 WebDAV远程代码执行漏洞分析
  • 原文地址:https://www.cnblogs.com/cxd1008/p/6372443.html
Copyright © 2011-2022 走看看