zoukankan      html  css  js  c++  java
  • 通过传id封装loading

    <script type="text/javascript">
        function SearchAnim(opts) {  
          for(var i in SearchAnim.DEFAULTS) {  
              if (opts[i] === undefined) {  
                 opts[i] = SearchAnim.DEFAULTS[i];  
              }  
          }  
          this.opts = opts;  
          this.timer = null;  
          this.elem = document.getElementById(opts.elemId); 
          this.startAnim();  
       }  
       SearchAnim.prototype.startAnim = function () {  
          this.stopAnim();  
          this.timer = setInterval(() => {  
          var startIndex = this.opts.startIndex;  
             if (startIndex == 360) {  
                this.opts.startIndex = 0;  
          }  
          this.elem.style.transform = "rotate("+(startIndex)+"deg)";  
                this.opts.startIndex += 5;  
                }, this.opts.delay);  
          
                setTimeout(() => {  
                    this.stopAnim();  
                }, this.opts.duration);  
            }  
            SearchAnim.prototype.stopAnim = function() {  
                if (this.timer != null) {  
                    clearInterval(this.timer);  
                }  
            }  
            SearchAnim.DEFAULTS = {  
                duration : 60000,  
                delay : 200,  
                direction : true,  
                startIndex : 0,  
                endIndex : 360,
            } 
            new SearchAnim({  
                elemId : "loading",  
                delay : 20,  
            });
  • 相关阅读:
    spring boot 与 spring cloud 版本映射
    Java锁
    并发编程(二)
    并发工具类和线程池
    并发编程
    Map双列集合(二)
    Map双列集合(一)
    单列集合List
    类加载
    JVM字节码与代码优化
  • 原文地址:https://www.cnblogs.com/dxt510/p/7493611.html
Copyright © 2011-2022 走看看