原生javascript实现图片弹窗交互效果
【一】用var声明多个变量,比每个变量都用var快多了
varsScrollTop=document.body.scrollTop||document.documentElement.scrollTop,
sWindow_h=document.documentElement.clientHeight,
t_h=parseInt(this.getCss(this.getId('gy_photoBox_head'),'height')),
hold_h=sWindow_h-t_h-20,
width=this.nImgWidth,
height=this.nImgHeight;
【二】Dom事件优化,在window.onresize时,定义个定时器,setTimeout,可以防止事件频繁调用
windowResize:function(){
var_that=this,
_timer=null;
//函数节流
window.onresize=function(){
clearTimeout(_timer);
_timer=setTimeout(function(){
if(_that.tools.getId('gy_photoBox')){
_that.setBoxCss();
}
},100); } }
热门推荐
1 如何训练狗狗不叫
2 训练狗狗不叫
3 训练狗狗随行
4 怎么训练狗狗不叫
7 训练比熊狗狗教程
10 上海狗狗训练
11 怎么训练狗狗上厕所
12 训练狗狗趴下
13 狗狗服从训练
14 训练狗狗拒食
15 训练狗狗笑
16 训练狗狗大便
17 训练狗狗立
18 训练狗狗捡东西