单独再开一贴,帮我写一个类吧。。用javascript 希望要求1.javascript,no jquery2.希望面向对象做类的功能A(x1,y1) B(x2,y2) 位置不固定的从A点平移到B点调用的格式希望json格式传参,或其他也可以move( {x1:"",y1:"",x2:"",y2:""} )收藏 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一个div模块详情参见新浪博客的模拟alert提示框。。 extjs就可以啊呵呵你看下源码啊。 setTimeout 修改 div 的坐标就可以了 你都写到这样了,没理由不会自己code吧?div id=b style=position:absolute;b.style.left=val;这样不行吗? 等了这么久,结果还是要靠自己伤脑细胞,我贴出来给你们看看<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> 在线等,ExtJs4.2 viewport 显示问题,请高手帮忙看看viewport的问题出在哪里 请问下面两个语句是否等价? 求助!用jquery实现鼠标经过li则addcalss"on",移出ul 时停留on!请帮忙! 我是菜鸟,专门注册个账号问高手一个html转JS代码的问题。 关于判断响应时间问题,谢谢! 刚才看到一个数组元素过滤的问题,再来讨论一下 [求一个特效]求chinaren的点击标题栏的箭头,下面的内容层向上慢慢移动,最终隐藏 jquery中以下这个程序如何调用输出hello?? 请教 求助求助!!! 请教一个Jquery的show、hide问题 帮忙看一下onsubmit
一个div模块详情参见新浪博客的模拟alert提示框。。
div id=b style=position:absolute;
b.style.left=val;
这样不行吗?
<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>