文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Js滚动效果

Js滚动效果

时间:2011-04-15  来源:X龙

1.Marquee.js

http://www.popub.net/script/MSClass.html
这个js功能比较齐全,几乎所有效果都有,比较好用。
2. var scrollElem;
                    var stopscroll;
                    var stoptime;
                    var preTop;
                    var leftElem;
                    var currentTop;
                    var marqueesHeight;

                    function marque(width, height, marqueName, marqueCName)
                    {
                        try
                        {
                            marqueesHeight = height;
                            stopscroll = false;
                            scrollElem = document.getElementById(marqueName);
                            with (scrollElem)
                            {
                                style.width = width;
                                style.height = marqueesHeight;
                                style.overflow = 'hidden';
                                noWrap = true;
                            }
                            scrollElem.onmouseover = new Function('stopscroll = true');
                            scrollElem.onmouseout = new Function('stopscroll = false');
                            preTop = 0;
                            currentTop = 0;
                            stoptime = 0;
                            leftElem = document.getElementById(marqueCName);
                            scrollElem.appendChild(leftElem.cloneNode(true));

                            init_srolltext();
                        } catch (e) { }
                    }
                    function init_srolltext()
                    {
                        scrollElem.scrollTop = 0;
                        setInterval('scrollUp()', 20);
                    }
                    function scrollUp()
                    {
                        if (stopscroll) return;
                        currentTop += 1;
                        if (currentTop == marqueesHeight + 1)
                        {
                            stoptime += 1;
                            currentTop -= 1;
                            if (stoptime == (marqueesHeight) * 4)
                            {//停顿时间
                                currentTop = 0;
                                stoptime = 0;
                            }
                        } else
                        {
                            preTop = scrollElem.scrollTop;
                            scrollElem.scrollTop += 1;
                            if (preTop == scrollElem.scrollTop)
                            {
                                scrollElem.scrollTop = marqueesHeight;
                                scrollElem.scrollTop += 1;
                            }
                        }
                    }

                    // marque(810, 30, "innerul", "innerul")

3.单行滚动,一行只有一个元素。

                     function AutoScrollUp(obj){
                            $(obj).find("ul:first").animate({
                                    marginTop:"-33px"
                            },500,function(){
                                    $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
                            });
                        }
                    
                     $(document).ready(function(){
                        setInterval('AutoScrollUp("#innerul")',2000);
                     })

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载