设备监控
This commit is contained in:
@@ -1,34 +1,12 @@
|
||||
// (function (doc, win) {
|
||||
// var docEl = doc.documentElement
|
||||
// var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
|
||||
// var recalc = function () {
|
||||
// var clientWidth = docEl.clientWidth
|
||||
// if (!clientWidth) return
|
||||
// docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px'
|
||||
// document.body.style.display = 'block'
|
||||
// }
|
||||
// if (!doc.addEventListener) return win.addEventListener(resizeEvt, recalc, false)
|
||||
// doc.addEventListener('DOMContentLoaded', recalc, false)
|
||||
// })(document, window)
|
||||
|
||||
(function () {
|
||||
var _self = this
|
||||
_self.width = 1920
|
||||
_self.fontSize = 100
|
||||
_self.widthProportion = function () {
|
||||
var p = ((document.body && document.body.clientWidth) || document.getElementsByTagName('html')[0].offsetWidth) / _self.width
|
||||
return p
|
||||
(function (doc, win) {
|
||||
var docEl = doc.documentElement
|
||||
var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
|
||||
var recalc = function () {
|
||||
var clientWidth = docEl.clientWidth
|
||||
if (!clientWidth) return
|
||||
docEl.style.fontSize = 100 * (clientWidth / 1920) + 'px'
|
||||
document.body.style.display = 'block'
|
||||
}
|
||||
_self.changePage = function () {
|
||||
document.getElementsByTagName('html')[0].setAttribute('style', 'font-size:' + _self.widthProportion() * _self.fontSize + 'px')
|
||||
}
|
||||
_self.changePage()
|
||||
window.addEventListener('resize', function () {
|
||||
let clientWidth = ((document.body && document.body.clientWidth) || document.getElementsByTagName('html')[0].offsetWidth)
|
||||
if (clientWidth >= 1550) {
|
||||
_self.changePage()
|
||||
} else {
|
||||
document.getElementsByTagName('html')[0].setAttribute('style', 'font-size:' + 1550 / _self.width * _self.fontSize + 'px')
|
||||
}
|
||||
}, false)
|
||||
})()
|
||||
if (!doc.addEventListener) return win.addEventListener(resizeEvt, recalc, false)
|
||||
doc.addEventListener('DOMContentLoaded', recalc, false)
|
||||
})(document, window)
|
||||
|
||||
Reference in New Issue
Block a user