zoukankan      html  css  js  c++  java
  • div内容滚动,无缝滚动

      

    function startmarquee(lh, speed, delay) {
            var t;
            var oHeight = 373; /** div的高度 **/
            var p = false;
            var o = document.getElementById("comList");
            var preTop = 0;
            o.scrollTop = 0;
            function start() {
                t = setInterval(scrolling, speed);
                o.scrollTop += 1;
            }
            function scrolling() {
                if (o.scrollTop % lh != 0 && o.scrollTop % (o.scrollHeight - oHeight - 1) != 0) {
                    preTop = o.scrollTop;
                    o.scrollTop += 1;
                    if (preTop >= o.scrollHeight || preTop == o.scrollTop) {
                        o.scrollTop = 0;
                    }
                } else {
                    clearInterval(t);
                    setTimeout(start, delay);
                }
            }
            setTimeout(start, delay);

            o.onmouseover = function () {
                clearInterval(t);
            }
            o.onmouseout = function () {
                start();
            }
        }
        startmarquee(20, 40, 0);//一次滚动的高度,速度,停顿的时间秒

  • 相关阅读:
    poj 1035 字符串匹配
    拓扑排序的小总结
    POJ1018
    POJ1328详细题解
    POJ1159题解报告
    POJ1088 (滑雪)
    树状树组区间修改,单点修改模板
    spfa模板
    树状树组离散化求逆序对模板
    POJ3723(最小生成树,负权)
  • 原文地址:https://www.cnblogs.com/gylspx/p/4140266.html
Copyright © 2011-2022 走看看