• OOP无缝滚动


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>OOP无缝滚动</title>
        <style type="text/css">
            body {
                margin: 0;
                padding: 0;
            }
            div.container {
                position: relative;
                width: 815px;
                height: 160px;
                margin: 20px auto;
                border: 20px solid springgreen;
                overflow: hidden;
            }
            ul {
                position: absolute;
                margin: 0;
                padding: 0;
            }
            li {
                width: 200px;
                height: 160px;
                display: inline-block;
                list-style: none;
            }
        </style>
        <script type="text/javascript">
            function GuoMove(oDiv){
                var oUl = oDiv.getElementsByTagName("ul")[0];
                oUl.innerHTML = oUl.innerHTML + oUl.innerHTML;
                var aLi = oDiv.getElementsByTagName("li");
                oUl.style.width = aLi[0].offsetWidth * aLi.length + "px";
                this.oTimer = setInterval(function(){
                    if(oUl.offsetLeft < -oUl.offsetWidth/2)
                        oUl.style.left = oUl.offsetLeft + oUl.offsetWidth/2 + "px";
                    else
                        oUl.style.left = oUl.offsetLeft - 2 + "px";
                },30);
                var _this = this;
                oDiv.onmouseover = function(){
                    //注意变量的作用域,什么时候这些变量能在函数内部直接用,什么时候这些变量需要作为参数传递给函数后才能在函数内部使用,区分原型方法。
                    //clearInterval(_this.oTimer);
                    _this.fnOver();
                };
                oDiv.onmouseout = function(){
                    _this.fnOut(oUl);
                };
    
            }
            GuoMove.prototype.fnOver = function(){
                clearInterval(this.oTimer);
            };
            GuoMove.prototype.fnOut = function(oUl){
                this.oTimer = setInterval(function(){
                    if(oUl.offsetLeft < -oUl.offsetWidth/2)
                        oUl.style.left = oUl.offsetLeft + oUl.offsetWidth/2 + "px";
                    else
                        oUl.style.left = oUl.offsetLeft - 2 + "px";
                },30);
            };
            window.onload = function(){
                var oDiv = document.getElementsByClassName("container")[0];
                var oGuoMove = new GuoMove(oDiv);
    
            };
        </script>
    </head>
    <body>
        <div class="container">
            <ul>
                <li style="background-color: red"></li>
                <li style="background-color: yellow"></li>
                <li style="background-color: blue"></li>
                <li style="background-color: grey"></li>
            </ul>
        </div>
    </body>
    </html>
    工欲善其事 必先利其器
  • 相关阅读:
    0607pm克隆&引用类&加载类&面向对象串讲&函数重载
    0607am抽象类&接口&析构方法&tostring&小知识点
    静态
    面向对象--继承和多态
    面向对象的三个特性:封装
    ALV可输入状态下输入金额字段变小数的问题
    退出程序是跳过屏幕自检 比如 必输 EXIT-COMMAND
    ALV的报表对用户定义格式的控制(ALV I_SAVE)
    获利能力分析COPA的BAPI:BAPI_COPAACTUALS_POSTCOSTDATA 通过增强返回凭证号
    一个使用CDS VIEW 的 DEMO
  • 原文地址:https://www.cnblogs.com/fengyouqi/p/7877936.html
Copyright © 2020-2023  润新知