弹跳是不是自由落体?

// 174 ? 175 : high; callback(high); }, delay); } window.onload = function () { a = document.getElementById("a"); XDancing(aLayout, 180); b = document.getElementById("b"); XDancing(bLayout, 120); c = document.getElementById("c"); XDancing(cLayout, 90); } // ]]>

C#
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        var a;
        var b;
        var c;

        var endtime = 6;
        var g = 4.9;

        function aLayout(_high) {
            a.style.top = _high + "px";
            a.style.marginRight = 3 + "px";
            a.style.marginLeft = 5 + "px";
        }
        function bLayout(_high) {
            b.style.top = _high + "px";
            b.style.marginRight = 3 + "px";
            b.style.marginLeft = 5 + "px";
        }
        function cLayout(_high) {
            c.style.top = _high + "px";
            c.style.marginRight = 3 + "px";
            c.style.marginLeft = 5 + "px";
        }

        function XDancing(callback, delay) {
            var down = true;
            var high = 0;
            var downSpeed = 0;
            var DownOrUp = setInterval(function () {
                if (down)
                    downSpeed++;
                if (!down)
                    downSpeed--;
                if (downSpeed == endtime || downSpeed == 0)
                    down = !down;
                high = Math.ceil(g * downSpeed * downSpeed);
                high = high > 174 ? 175 : high;
                callback(high);
            }, delay);
        }

        window.onload = function () {
            a = document.getElementById("a");
            XDancing(aLayout, 180);

            b = document.getElementById("b");
            XDancing(bLayout, 120);

            c = document.getElementById("c");
            XDancing(cLayout, 90);
        }
    
    </script>
</head>
<body>
    <div style="border: 1px solid black;  120px; height: 195px;">
        <div id="a" style="float: left; background-color: Green; position: relative;">
            C#
        </div>
        <div id="b" style="float: left; background-color: Orange; position: relative;"></div>
        <div id="c" style="float: left; background-color: Blue; position: relative;"></div>
    </div>
</body>
</html>
View Code
原文地址:https://www.cnblogs.com/wjshan0808/p/3943943.html