原生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); } }
热门推荐
10 香港老妈结婚祝福语简短
11 毕业立体贺卡祝福语简短
12 简短新年年会祝福语
13 评论小品祝福语大全简短
14 恭喜师兄结婚祝福语简短
15 员工集体辞职祝福语简短
16 高中新生祝福语 简短
17 装修祝福语男生搞笑简短
18 生日开业蛋糕祝福语简短