zoukankan      html  css  js  c++  java
  • 缓存布局信息

     1 ;(function(global){
     2         var wind = document.getElementById("wind"), count = 0;
     3 
     4         function marque(){
     5             console.log("wind.offsetTop:",wind.offsetTop,"wind.offsetLeft::",wind.offsetLeft);
     6 
     7 
     8             /*wind.style.left = 12 + wind.offsetLeft + "px";
     9             wind.style.top = 1 + wind.offsetTop + "px";
    10             console.log("wind.offsetTop:",wind.offsetTop,"wind.offsetLeft::",wind.offsetLeft);*/
    11 
    12             // 上面会不停得计算 offsetLeft offsetTop ,不停得查询,导致浏览器刷新渲染而不利于优化
    13             // 就是 缓存布局信息啦
    14             count++;
    15             wind.style.top = count + "px";
    16             wind.style.left = count + "px";
    17 
    18             if(wind.offsetTop >= 200){
    19                 //stopAnimation();
    20                 console.log(111)
    21                 
    22                 clearInterval(timer);
    23             }
    24         }
    25 
    26         timer = setInterval(marque,20);
    27         console.log(wind.offsetTop)
    28         
    29     })(this)
    疯癫不成狂,有酒勿可尝;世间良辰美,终成水墨白。
  • 相关阅读:
    微信开发 缓存处理
    ASP.NET MVC 开发日常笔记
    微信开发笔记
    Kindeditor 编辑代码过滤
    PS 使用技巧
    Javascript 日常开发用到的小知识点
    C# 下载文件
    Javascript 笔记一
    C# 知识巩固三
    文献笔记(五)
  • 原文地址:https://www.cnblogs.com/chuyu/p/3317189.html
Copyright © 2011-2022 走看看