自由落体运动
来源:互联网 发布:javascript 页面刷新 编辑:程序博客网 时间:2024/05/18 00:38
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#box{width:100px;height:100px;background:red;position: absolute;left:0;top:30px;}
</style>
<script type="text/javascript">
window.onload=function()
{
var oDiv=document.getElementById("box");
var btn=document.getElementById("btn");
var timer=null;
var speed=0;
btn.onclick=function()
{
startMove();
};
function startMove()
{
clearInterval(timer);
timer=setInterval(function()
{
speed+=3;//不断的加速度
var T=oDiv.offsetTop+speed;
if(T>document.documentElement.clientHeight-oDiv.offsetHeight)//如果接触到浏览器底部或超过
{
T=document.documentElement.clientHeight-oDiv.offsetHeight;//就设置节点接触浏览器底部
speed*=-1;//速度取反
speed*=0.75;//重力摩擦
}
oDiv.style.top=T+"px";//执行
},30)
}
}
</script>
</head>
<body>
<button id="btn">点击</button>
<div id="box"></div>
</body>
</html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style type="text/css">
#box{width:100px;height:100px;background:red;position: absolute;left:0;top:30px;}
</style>
<script type="text/javascript">
window.onload=function()
{
var oDiv=document.getElementById("box");
var btn=document.getElementById("btn");
var timer=null;
var speed=0;
btn.onclick=function()
{
startMove();
};
function startMove()
{
clearInterval(timer);
timer=setInterval(function()
{
speed+=3;//不断的加速度
var T=oDiv.offsetTop+speed;
if(T>document.documentElement.clientHeight-oDiv.offsetHeight)//如果接触到浏览器底部或超过
{
T=document.documentElement.clientHeight-oDiv.offsetHeight;//就设置节点接触浏览器底部
speed*=-1;//速度取反
speed*=0.75;//重力摩擦
}
oDiv.style.top=T+"px";//执行
},30)
}
}
</script>
</head>
<body>
<button id="btn">点击</button>
<div id="box"></div>
</body>
</html>
0 0
- 自由落体运动
- VPython - example - 模拟自由落体运动
- android动画自由落体运动
- javascript---之自由落体运动实现
- 案例-小球自由落体运动
- jquery自由落体运动(弹簧运动)
- unity 自由落体运动的物理学知识
- [Box2D]二.让乌龟做自由落体运动
- js 实现拖动效果 __按回车键,方块还能做自由落体运动。
- 力学现象动画演示——真空状态下的自由落体运动
- 【VC++游戏开发#七】2D篇 —— 物理建模(二) 重力模拟:让愤怒的小鸟来感受一次自由落体运动
- SharedPreference注册OnSharedPreferenceChangeListener问题
- HttpClient 教程 (一)
- MySQL索引背后的数据结构及算法原理
- c++遍历创建文件目录
- Dijkstra算法(单元点最短路径)
- 自由落体运动
- inno setup制作网页ocx控件发布程序执行包
- PostgreSQL change unlogged table to logged table
- 关于Android在线支付Alipay(支付宝)开发的经验分享
- 复杂链表的复制
- LINUX select()函数的应用
- Libnids中tcp流处理"tcp.c"
- math.random()
- xcode更改SVN地址