asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
<script type="text/javascript">
<!--
var o = document.getElementById("ddd");
Move({
  obj : o,
  Begin : { top : o.offsetTop, left : o.offsetLeft, width : o.offsetWidth, height : o.offsetHeight},
  End : { top : 20, left : 100, width : 300 ,height : 400}
      });
function Move(o) {
 if (o.obj.t) clearTimeout(o.obj.t);
 var goon = false;
 var Time = o.Time || 10;
 for (var i in o.End) {
  var step = 0, neg = false;
  var temp = o.End[i] - o.Begin[i];
  if (temp == 0) continue;
  if (temp < 0) {
   neg = true;
   temp = -temp;
  }
  step = temp >> 2;
  if (step == 0) continue;
  if (neg) step = -step;
  o.obj.style[i] = (o.Begin[i] += step) + "px";
  goon = true;
 }
 if (!goon) {
  o.obj.t = null;
  o.obj = null;
  o = null;
  return;
 }
 o.obj.t = setTimeout(function() {
  Move(o);
 }, Time)
}
//-->
</script>
posted on 2008-10-06 18:07 汪杰 阅读(207) 评论(1)  编辑 收藏 引用 所属分类: javascript

FeedBack:
# re: animation test
2008-10-06 23:56 | 汪杰
<div onmouseover="eval(str);" onmouseout="eval(str2);" id="ddd" style="border: 1px solid green; position: absolute; left: 100px; top: 10px; width: 100px; height: 30px; background: yellow;">

</div>
<script type="text/javascript">
<!--
var o = document.getElementById("ddd");
var str ='Move({\
obj: o,\
Begin: { top : o.offsetTop, left : o.offsetLeft, width : o.offsetWidth, height : o.offsetHeight},\
End: { top : o.offsetTop, left : o.offsetLeft, width : 300 ,height : 200}\
})';
var old = {width: o.offsetWidth, height: o.offsetHeight};
var str2 ='Move({\
obj: o,\
Begin: { top : o.offsetTop, left : o.offsetLeft, width : o.offsetWidth, height : o.offsetHeight},\
End: { top : o.offsetTop, left : o.offsetLeft, width : old.width ,height : old.height}\
})';
function Move(o) {
if(o.obj.t) clearTimeout(o.obj.t);
var goon = false;
var Time = o.Time || 10;
for (var i in o.End) {
var step = 0, neg = false;
var temp = o.End[i] - o.Begin[i];
if (temp == 0) continue;
if (temp < 0) {
neg = true;
temp = -temp;
}
step = temp < 4 ? 1 : temp >> 2;
if (step == 0){
o.obj.style[i] = o.End[i] + "px";
continue;
}
if (neg) step = -step;
o.obj.style[i] = (o.Begin[i] += step) + "px";
goon = true;
}
if (!goon) {
o.obj.t = null;
o.obj = null;
o = null;
return;
}
o.obj.t = setTimeout(function() {
Move(o);
}, Time)
}
//-->
</script>   回复  更多评论
  
只有注册用户登录后才能发表评论。

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 466814
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜