first commit
This commit is contained in:
20
h5/js/utils/rem.js
Normal file
20
h5/js/utils/rem.js
Normal file
@@ -0,0 +1,20 @@
|
||||
!(function(win, doc) {
|
||||
function setFontSize() {
|
||||
var winWidth = window.innerWidth;
|
||||
doc.documentElement.style.fontSize = (winWidth / 750) * 100 + 'px';
|
||||
}
|
||||
var evt = 'onorientationchange' in win ? 'orientationchange' : 'resize';
|
||||
var timer = null;
|
||||
win.addEventListener(evt, function() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(setFontSize, 300);
|
||||
}, false);
|
||||
win.addEventListener("pageshow", function(e) {
|
||||
if (e.persisted) {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(setFontSize, 300);
|
||||
}
|
||||
}, false);
|
||||
//初始化
|
||||
setFontSize();
|
||||
}(window, document));
|
||||
Reference in New Issue
Block a user