加入收藏 | 设为首页 | RSS
您当前的位置:首页 > 网页特效

弹性十足的横向弹出菜单特效代码

时间:2012-04-20 08:03:52  来源:  作者:

            .co2{ background:#028fbc}

        </style>

        <script type="text/javascript">

            window.onload = function() {

                var oUl = document.getElementById("nav");

                var aLi = oUl.getElementsByTagName("li");

                var i = 0;

                for (i = 0; i < aLi.length; i++) {

                    aLi[i].timer = null;

                    aLi[i].speed = 0;

                    aLi[i].onmouseover = function() {

                        startMove(this, 250);

                    };

                    aLi[i].onmouseout = function() {

                        startMove2(this, 100);

                    };

                }

            };

 

            function startMove(obj, iTarget) {

                if (obj.timer) {

                    clearInterval(obj.timer);

                }

                obj.timer = setInterval(function() {

                    doMove(obj, iTarget);

                }, 30)

            };

 

            function doMove(obj, iTarget) {

                obj.speed += 3;

                if (Math.abs(iTarget - obj.offsetWidth) < 1 && Math.abs(obj.speed) < 1) {

                    clearInterval(obj.timer);

                    obj.timer = null;

                }

                else {

                    if (obj.offsetWidth + obj.speed >= iTarget) {

                        obj.speed *= -0.7;

                        obj.style.width = iTarget + "px";

                    }

                    else {

                        obj.style.width = obj.offsetWidth + obj.speed + "px";

                    }

                }

            };

 

            function startMove2(obj, iTarget) {

                if (obj.timer) {

                    clearInterval(obj.timer);

                }

                obj.timer = setInterval(function() {

                    doMove2(obj, iTarget);

                }, 30)

            };

 

            function doMove2(obj, iTarget) {

                obj.speed -= 3;

                if (Math.abs(iTarget - obj.offsetWidth) < 1 && Math.abs(obj.speed) < 1) {

                    clearInterval(obj.timer);

                    obj.timer = null;


来顶一下
返回首页
返回首页
推荐资讯
10步征服web2.0链轮第四步,决定链轮模式
10步征服web2.0链轮第
10步征服web2.0链轮第三步,消除“电子足迹”
10步征服web2.0链轮第
10步征服web2.0链轮第一步,理解链轮的概念
10步征服web2.0链轮第
小贺店铺
小贺店铺
相关文章
    无相关信息
栏目更新
栏目热门