希望要求1.javascript,no jquery2.希望面向对象做类的功能A(x1,y1)   B(x2,y2)  位置不固定的从A点平移到B点调用的格式希望json格式传参,或其他也可以move( {x1:"",y1:"",x2:"",y2:""} )收藏

解决方案 »

  1.   


    一个div模块详情参见新浪博客的模拟alert提示框。。
      

  2.   

    extjs就可以啊呵呵你看下源码啊。
      

  3.   

    setTimeout 修改 div 的坐标就可以了
      

  4.   

    你都写到这样了,没理由不会自己code吧?
    div id=b style=position:absolute;
    b.style.left=val;
    这样不行吗?
      

  5.   

    等了这么久,结果还是要靠自己伤脑细胞,我贴出来给你们看看<html>
    <body>
    <div id="mydiv" style="width:100px;height:50px;border:1px solid red;position:absolute;left:0;top:0"></div>
    <script>
    function MoveDiv()
    {
    this.moveRightDown=this.freemoveRightDown;
    }
    MoveDiv.prototype={
    //右下情况1 —— (y2-y1)>(x2-x1) 时有效.
    freemoveRightDown:function(dom,json){
    this._dom=dom;
    this._o=json;
    this._oleft=this._o.x1;
        this._otop=this._o.y1;
    this.speed=3;
    this.rotation=Math.atan((this._o.y2-this._o.y1)/(this._o.x2-this._o.x1))*180/Math.PI;
    var _this=this;
    var int=setInterval(
    function(){
    _this._oleft=parseFloat(_this._oleft)+Math.sin(_this.rotation * Math.PI / 180)*(_this.speed);
    _this._dom.style.left = _this._oleft+"px";
    _this._otop=parseFloat(_this._otop)+Math.cos(_this.rotation * Math.PI / 180)*(_this.speed);
    _this._dom.style.top = _this._otop+"px";
    if(_this._oleft>_this._o.x2||_this._otop>_this._o.y2)
    {
    int=window.clearInterval(int);
    }
    },20);
    }
    }
    var drag=new MoveDiv();
    drag.moveRightDown(document.getElementById("mydiv"),{x1:"0",y1:"0",x2:"400",y2:"500"});
    </script>
    </body>
    </html>