彈性運動框架

1、長得一樣的東西,觀察規律,看相同點和區別,會有發現。

2、世間的運動或現象,觀察並發現規律,可以嘗試用代碼描述。

3、摩擦力是爲了讓目標物體停止。

4、相同原理,數值不同出現的結果可能差別很大

5、<style>
        #div1{width:100px;height:100px;background: red;
            position: absolute;left:0;top:50px;}
    </style>
    <script>
        window.onload=function() {
            var oBtn=document.getElementById('btn1');
            var iSpeed = 0;
            oBtn.onclick=function(){
                startMove();
            };
            function startMove() {
                var oDiv = document.getElementById('div1');
                setInterval(function () {
                        iSpeed+=(300-oDiv.offsetLeft)/5;
                        iSpeed*=0.7;
                    oDiv.style.left = oDiv.offsetLeft + iSpeed + 'px';
                }, 30);
            }
        }
    </script>
</head>
<body>
<input id="btn1" type="button" value="開始運動"/>
<div id="div1"></div>
<div style="position:absolute;left:300px;width:1px;height:300px;background:#000000;"></div>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章