zoukankan      html  css  js  c++  java
  • 跟着别人学习的一个个拖动层

    <script>
            
    function objectDrapDrop(obj){
                
    var me = this;
                
    this.foo = (typeof obj == 'string'? document.getElementById(obj) : obj;
                
    this.foo.onmousedown = function(e){
                    
    var foo = me.foo;
                    e 
    = e || event;
                    
    if(e.layerX){
                        foo.oOffset 
    = {x:e.layerX, y:e.layerY};
                    } 
    else {
                        foo.oOffset 
    = {x:e.offsetX, y:e.offsetY};
                    }
                    document.onmousemove 
    = me.drag;
                    document.onmouseup 
    = me.drop;
                    document.onselectstart 
    = function(){ return false;}
                }
                
    this.drag = function(e){
                    
    var foo = me.foo;
                    e 
    = e || event;
                    foo.style.top 
    = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - foo.oOffset.y + 'px'
                    foo.style.left 
    = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - foo.oOffset.x + 'px'
                }
                
    this.drop = function(e){
                    e 
    = e || event;
                    document.onmousemove 
    = document.onmouseup = document.onselectstart = null;
                }
            }
            window.onload 
    = function(){
                
    var test1 = new objectDrapDrop('foo');
            }
            
    </script>
        
    </head>
        
    <body>
            
    <div id="foo">This is a div!</div>
        
    </body>

    没有多大实际的意思,同样里边的有些东西,没有搞懂。

  • 相关阅读:
    测试网络
    测试
    Centos6.6中VIM的编辑、退出与保存
    IP
    2018.12.24 课程更新内容到第五章 渗透测试 第4、5节
    利用GRC进行安全研究和审计 – 将无线电信号转换为数据包(转)
    我的翻译--一个针对TP-Link调试协议(TDDP)漏洞挖掘的故事
    我的翻译--针对Outernet卫星信号的逆向工程
    Sulley安装手记
    乘用车黑客手册(译)
  • 原文地址:https://www.cnblogs.com/jikey/p/1618772.html
Copyright © 2011-2022 走看看