元のフォームを維持するための 1 つのソリューションが存在する
var time = 300;
var resizeDelay = 100;
var savedWidth = $('img').width();
var savedHeigth = $('img').height();
var savedWindowWidth = $(window).width();
var savedWindowHeight = $(window).height();
function resize(newWinWidth, newWinHeight) {
var newImgWidth = 0;
var newImgHeight = 0;
newImgWidth = (newWinWidth * savedWidth) / savedWindowWidth;
if($(window).height< savedWindowHeight){
newImgHeight = (newWinHeight * savedHeigth) / savedWindowHeight;
}
if (savedWindowWidth === $j(window).width()) {
$('img').mapster('resize', savedWidth, savedHeigth, time);
}
else {
$('img').mapster('resize', newImgWidth, newImgHeight, time);
}
}
function onWindowResize() {
var curWidth = $j(window).width(),
curHeight = $(window).height(),
checking = false;
if (checking) {
return;
}
checking = true;
window.setTimeout(function () {
var newWidth = $(window).width(),
newHeight = $(window).height();
if (newWidth === curWidth &&
newHeight === curHeight) {
resize(newWidth, newHeight);
}
checking = false;
}, resizeDelay);
}
$(window).bind('resize', onWindowResize);