/*
*JS垂直落体回弹原理
*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#div1{ width:100px; height:100px; position:absolute; background:red;}
</style> <script type="text/javascript">
window.onload = function(){
var oBtn = document.getElementById("btn");
oBtn.onclick = function (){
startMove("div1",15);
}
function startMove(id,n1){
var oDiv = document.getElementById(id);
var iSpeed = 0;
setInterval(function (){
iSpeed +=n1;
var t = oDiv.offsetTop + iSpeed;
document.title = t + " , " + iSpeed;
console.log(iSpeed);
if(t > document.documentElement.clientHeight - oDiv.offsetHeight){
t = document.documentElement.clientHeight - oDiv.offsetHeight;
iSpeed *= -1;
iSpeed *=0.75;
}
oDiv.style.top = t + "px";
},30);
}
}
</script> </head> <body> <input type="button" value="运动" id="btn" />
<div id="div1"></div> </body>
</html>

最新文章

  1. 「标准」的 JS风格
  2. Lucene 工作原理 之倒排索引
  3. P4基函数
  4. C# Activex开发、打包、签名、发布
  5. iOS之UIview动画
  6. vijosP1159 岳麓山上打水
  7. wince下GetManifestResourceStream得到的Stream是null的解决
  8. jquery mobile Checkbox动态添加刷新及事件绑定
  9. Unity3D 中材质球(Material)预制体打包成AB(AssetBundle)出现材质丢失问题的解决方案
  10. 在eclispe的类中快速打出main方法
  11. 3167: [Heoi2013]Sao [树形DP]
  12. BP神经网络(原理及MATLAB实现)
  13. vue 之iview
  14. js之获取元素最终css属性
  15. python3 re.compile中含有变量
  16. 【PAT】B1077 互评成绩计算(20 分)
  17. webpack config
  18. linux命令返回值的妙用
  19. 14款超时尚的HTML5时钟动画
  20. BZOJ3668:[NOI2014]起床困难综合症——题解

热门文章

  1. dfs序与求子树子节点(染了色)的个数
  2. Java进阶学习(3)之对象容器(上)
  3. Windows 10下一步一步创建 Scrapy框架的项目
  4. 聊聊Redis的持久化
  5. python匿名函数与三元运算
  6. 大数据计算引擎之Flink Flink CEP复杂事件编程
  7. Django - Form嵌套的Meta类 + 为什么type()能创建类
  8. 《如何写好商业计划书》---创业学习---训练营第三课---HHR---
  9. Qt应用程序的打包
  10. ARG 构建参数----Dockerfle文件的重用