다음 코드를 사용하여 스테이지를 가운데에 맞춰 크기를 조정하여 창에 맞출 수 있습니다. 크기를 조정하고 싶지 않고 가운데 맞추기 만하면 크기 조정 부분을 간단히 제거 할 수 있습니다. 이 코드를 스테이지 구성 요소의 window.resize 이벤트에 붙여 넣을 수 있습니다 (윈도우> 코드> 스테이지> 이벤트> 크기 조정).
var stageHeight = $("#Stage").height();
var stageWidth = $("#Stage").width();
// console.log("stageHeight " + stageHeight);
// console.log("stageWidth " + stageWidth);
var ratio = stageWidth/stageHeight;
var bodyHeight = $(window).height();
var bodyWidth = $(window).width();
// console.log("bodyHeight " + bodyHeight);
// console.log("bodyWidth " + bodyWidth);
var bodyRatio = bodyWidth/bodyHeight;
var newStageHeight = bodyHeight;
var newStageWidth = bodyWidth;
var leftPos = 0;
var topPos = 0;
// fit width
if (bodyRatio < ratio) {
newStageWidth = bodyWidth;
newStageHeight = newStageWidth/ratio;
topPos = 0.5 * (bodyHeight - newStageHeight);
}
// fit height
else if (ratio < bodyRatio) {
newStageHeight = bodyHeight;
newStageWidth = newStageHeight * ratio;
leftPos = 0.5 * (bodyWidth - newStageWidth);
}
// console.log("newStageHeight " + newStageHeight);
// console.log("newStageWidth " + newStageWidth);
$("#Stage").height(newStageHeight);
$("#Stage").width(newStageWidth);
$("#Stage").css("left", leftPos + 'px');
$("#Stage").css("top", topPos + 'px');
출처
2013-11-06 16:48:53
Ena
안녕하세요. Ena, 의견을 보내 주셔서 감사합니다. 그러나 저에게는 효과가 없습니다. 나에서 다음 testpage에서 봐 주시기 바랍니다 : http://openoffice.funpic.de/Test_002/test002.html 당신은 전체 조성 (에지 애니메이션 소스 파일 포함) 다운로드 할 수 있습니다 : http://openoffice.funpic.de/Test_002/Test_002.rar – Ronny
브라우저 창 크기를 조정하면 코드가 실제로 작동한다는 것을 알 수 있습니다.] 페이지로드시 문제가 남아 있습니다. 이벤트가 발생하지 않습니다. compositionReady (윈도우> 코드> 스테이지> 이벤트> CompositionReady)에도 똑같은 코드를 추가하십시오. – Ena
안녕하세요 - 맞습니다 -이 시도 : 그것은 단지 들여 쓰기가 있지만 가로로 가운데에 있지 않습니다. 그리고 여전히 페이지 상단에 있습니다. http://openoffice.funpic.de/Test_004/test004.html http://openoffice.funpic.de/Test_004/Test_004.rar 또한하시기 바랍니다 : 내 시험이 버전에서 좀 걸릴 수 있습니다 버전 003 봐 .... 나는 다른 코드를 시도하고 이것은 완벽하게 Firefox (수평 및 수직 중심)하지만 인터넷 익스플로러와 함께 작동하지 : ( – Ronny