Skip to content

Commit a744a73

Browse files
committed
update globe location
1 parent 43e2b86 commit a744a73

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

js/app.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ let locationData = {};
66
let AREA_DATA = {};
77
let areaToCountryCode = {}; // グローバル変数として明示的に宣言
88

9+
// ウィンドウサイズ変更時に地球儀の位置を調整
10+
function adjustGlobePosition() {
11+
const container = document.getElementById('globe-container');
12+
const membersPanel = document.getElementById('members-panel');
13+
const windowWidth = window.innerWidth;
14+
const panelWidth = membersPanel.offsetWidth;
15+
const globeWidth = windowWidth - panelWidth;
16+
17+
// 地球儀を右パネルの幅を考慮して中央に配置
18+
container.style.width = `${globeWidth}px`;
19+
container.style.left = '0';
20+
21+
// 地球儀のビューポートを更新
22+
if (globe) {
23+
globe.width(globeWidth);
24+
globe.controls().update();
25+
}
26+
}
27+
928
// アプリケーションの初期化
1029
async function initializeApp() {
1130
try {
@@ -63,6 +82,12 @@ async function initializeApp() {
6382
// UIの初期化
6483
await initGlobe();
6584
updateMembersList();
85+
86+
// 初期位置の調整
87+
adjustGlobePosition();
88+
89+
// ウィンドウサイズ変更時のイベントリスナーを追加
90+
window.addEventListener('resize', adjustGlobePosition);
6691
} catch (error) {
6792
console.error('Error initializing application:', error);
6893
}
@@ -325,11 +350,19 @@ async function initGlobe() {
325350

326351
// 地球儀の表示領域を計算(右ペインを除いた領域の中央)
327352
const globeAreaWidth = windowWidth - panelWidth;
353+
const leftOffset = 0; // 左端からの位置を0に設定
354+
328355
container.style.width = `${globeAreaWidth}px`;
329356
container.style.height = `${windowHeight}px`;
330357
container.style.position = 'absolute';
331-
container.style.left = '0';
358+
container.style.left = `${leftOffset}px`;
332359
container.style.top = '0';
360+
361+
// 地球儀のサイズを更新
362+
if (globe) {
363+
globe.width(globeAreaWidth);
364+
globe.height(windowHeight);
365+
}
333366
}
334367

335368
// 初期位置の設定
@@ -458,6 +491,13 @@ async function initGlobe() {
458491
// 初期視点を設定
459492
globe.pointOfView({ lat: 20, lng: 0, altitude: 2.5 });
460493

494+
// 地球儀の初期化が完了した後に位置を再調整
495+
setTimeout(() => {
496+
updateGlobePosition();
497+
globe.width(container.offsetWidth);
498+
globe.height(container.offsetHeight);
499+
}, 100);
500+
461501
// ウィンドウリサイズ時の処理
462502
window.addEventListener('resize', () => {
463503
updateGlobePosition();

0 commit comments

Comments
 (0)