美文网首页
getBoundingClientRect

getBoundingClientRect

作者: jh2k15 | 来源:发表于2018-05-18 20:10 被阅读0次

((win)=>{

var tid,
      refreshWidth = () => {
        var cliR = win.document.documentElement.getBoundingClientRect()   //
        var width=cliR.width
        var height=cliR.height
        win.clearTimeout(tid);
        tid=win.setTimeout(console.log(width),300)
}

win.addEventListener('resize',()=>{
    refreshWidth()
})
win.addEventListener('pageshow',(e) => {  //onload 之后 初始化显示
    if(e.persisted){          //从缓存加载
        refreshWidth()
    }
})

})(window)

相关文章

网友评论

      本文标题:getBoundingClientRect

      本文链接:https://www.haomeiwen.com/subject/bfrndftx.html