缓存布局信息

 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)

 

转载于:https://www.cnblogs.com/chuyu/p/3317189.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值