window.Base = window.Base || function () {};
//不同区域刷新
Base.prototype.resizeStackLock = false;
Base.prototype.resizeStack = [];
Base.prototype.resizeChangeScreen = function () {
var resizeTimer;
var perWinWidth = $(window).width();
var getLevel = function (w) {
if (w <= 750) {
return 0;
} else if (w <= 1200) {
return 1;
} else {
return 2;
}
}
$(window).on("resize", function () {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
var winw = $(window).width()
if (Math.abs(winw - perWinWidth) > 30) {
if (getLevel(perWinWidth) != getLevel(winw)) {
location.reload();
} else {
this.resizeStackLock = true
$.each(this.resizeStack, function (idx, val) {
if (val && val.fn) {
val.fn.apply(this, val.params);
}
})
this.resizeStackLock = false
}
perWinWidth = $(window).width();
}
}, 200);
})
}
var baseLib = new Base();
baseLib.resizeChangeScreen(); //刷新
网友评论