拖拽+碰撞+重力加速度,拖拽重力加速度
滑鼠在標題處按下,然後拖動,放下的那一刻執行碰撞+重力加速度事件
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><title>拖拽+碰撞+重力加速度</title><meta name="description" content=""><meta name="keywords" content=""><style type="text/css" media="screen">*{margin:0; padding: 0;}li{list-style: none;}a{text-decoration: none; color:#333;}a:hover{color:green;}#box{position: absolute; top:100px; left:35%; background-color:#fff; width:400px; border:1px solid #ccc; -webkit-border-radius:4px; -moz-border-radius:4px; -o-border-radius:4px; border-radius:4px;}#box h2{ height: 34px; line-height:34px; padding:2px 10px; font-size:14px; color:#666; background-color: #f8f8f8; border-bottom:1px solid #ccc; -webkit-border-radius:4px 4px 0 0; -moz-border-radius:4px 4px 0 0; -o-border-radius:4px 4px 0 0; border-radius:4px 4px 0 0; cursor:move;}#box .cont{padding: 10px;}#box .cont li{ line-height: 24px; margin-bottom: 3px;}</style></head><body><script>window.onload = function(){var oDiv = document.getElementById('box');var oH = oDiv.getElementsByTagName('h2')[0];var lastX = 0;var lastY = 0;oH.onmousedown = function(e){var e = e||event;// 滑鼠與物體左側和上側的距離var disX = e.clientX - oDiv.offsetLeft; var disY = e.clientY - oDiv.offsetTop;document.onmousemove = function(e){var e = e||event;var l = e.clientX - disX;var t = e.clientY - disY;if(l <= 0){l = 0;}else if(l > document.documentElement.clientWidth - oDiv.offsetWidth){l=document.documentElement.clientWidth - oDiv.offsetWidth;}if(t<=0){t=0;}else if(t > document.documentElement.clientHeight - oDiv.offsetHeight){t = document.documentElement.clientHeight - oDiv.offsetHeight;}oDiv.style.left = l + 'px';oDiv.style.top = t + 'px';// 瞬間上次iSpeedX = l - lastX;iSpeedY = t - lastY;lastX = l;lastY = t;}document.onmouseup = function(){document.onmousemove = null;document.onmouseup = null;startmove(oDiv);}clearInterval(timer);}}// 速度var iSpeedX = 0;var iSpeedY = 0;var timer = null;function startmove(obj){clearInterval(timer);timer = setInterval(function(){// 重力加速度iSpeedY +=3;var l = obj.offsetLeft + iSpeedX;var t = obj.offsetTop + iSpeedY;if(t>=document.documentElement.clientHeight - obj.offsetHeight){iSpeedY *= - 0.8;iSpeedX *= 0.8;t=document.documentElement.clientHeight - obj.offsetHeight;}else if(t<=0){iSpeedY *= -0.8;iSpeedX *= 0.8;t = 0;}if(l>=document.documentElement.clientWidth - obj.offsetWidth){iSpeedX *= -0.8;l=document.documentElement.clientWidth - obj.offsetWidth;}else if(l<=0){iSpeedX *= -0.8;l = 0;}// 解決小數問題if(Math.abs(iSpeedX)<1){iSpeedX=0;}if(Math.abs(iSpeedY)<1){iSpeedY=0;}if(iSpeedY==0 && iSpeedX==0 && t==document.documentElement.clientHeight-obj.offsetHeight){clearInterval(timer);}obj.style.top = t + 'px';obj.style.left = l + 'px';},30);}</script> <div id="box"> <h2>瀏覽</h2> <div class="cont"> <ul> <li><a href="http://www.ruizhengyun.cn/" title="" target="_blank">網站簡介</a></li> <li><a href="http://www.ruizhengyun.cn/" title="" target="_blank">網站簡介</a></li> <li><a href="http://www.ruizhengyun.cn/" title="" target="_blank">網站簡介</a></li> <li><a href="http://www.ruizhengyun.cn/" title="" target="_blank">網站簡介</a></li> <li><a href="http://www.ruizhengyun.cn/" title="" target="_blank">網站簡介</a></li> <li><a href="http://www.ruizhengyun.cn/" title="" target="_blank">網站簡介</a></li> </ul> </div> </div></body></html>
重力與重力加速度有什聯絡?
加速度是9.8米每二次方秒的加速度產生的原因是受到了地球以每千克的物體受9.8牛的力作用的結果,也就是說:給每千克的物體9.8牛的力,那這物體就以9.8米每二次方秒的加速度向力的方向前進.所以兩個量是從不同的方向來定義的.
重力加速度的9.8米每二次方秒就是地球上的g----9.8N/kg.
一個物體受到的合力為水平向右5N,那麼它的加速度不可以確定,因為不知道它的品質,對於一顆灰塵,加速度會非常的大,但對於一輛大車,它的速度要慢慢的增大----加速度不大.
重力加速度是什?是哪個?
地球表面附近的物體因受重力產生的加速度叫做重力加速度,也叫自由落體加速度,用g表示。
重力加速度g的方向總是豎直向下的。在同一地區的同一高度,任何物體的重力加速度都是相同的。重力加速度的數值隨海拔高度增大而減小。當物體距地面高度遠遠小於地球半徑時,g變化不大。而離地面高度較大時,重力加速度g數值顯著減小,此時不能認為g為常數
距離面同一高度的重力加速度,也會隨著緯度的升高而變大。由於重力是萬有引力的一個分力,萬有引力的另一個分力提供了物體繞地軸作圓周運動所需要的向心力。物體所處的地理位置緯度越高,圓周運動軌道半徑越小,需要的向心力也越小,重力將隨之增大,重力加速度也變大。地理南北兩極處的圓周運動軌道半徑為0,需要的向心力也為0,重力等於萬有引力,此時的重力加速度也達到最大。
由於g隨緯度變化不大,因此國際上將在緯度45°的海平面精確測得物體的重力加速度g=9.80665m/s^2;作為重力加速度的標準值。在解決地球表面附近的問題中,通常將g作為常數,在一般計算中可以取g=9.80m/s^2。理論分析及精確實驗都表明,隨緯度增大,重力加速度g的數值逐漸增大。如:
赤道g=9.780m/s^2
廣州g=9.788m/s^2
武漢g=9.794m/s^2
上海g=9.794m/s^2
東京g=9.798m/s^2
北京g=9.801m/s^2
紐約g=9.803m/s^2
莫斯科g=9.816m/s^2
北極地區g=9.832m/s^2
註:月球面的重力加速度約為1.62 m/s^2,約為地球重力的六分之一。