-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlayout-debug.js
More file actions
214 lines (179 loc) ยท 8.27 KB
/
layout-debug.js
File metadata and controls
214 lines (179 loc) ยท 8.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// ๋ธ๋ผ์ฐ์ ์ฝ์์์ ์คํํ ๋ ์ด์์ ๋๋ฒ๊น
์คํฌ๋ฆฝํธ
// ์ฌ์ฉ๋ฒ: ๋ธ๋ผ์ฐ์ ์์ F12 ๊ฐ๋ฐ์ ๋๊ตฌ ์ด๊ณ Console ํญ์์ ์ด ์ฝ๋๋ฅผ ๋ณต์ฌ-๋ถ์ฌ๋ฃ๊ธฐ
console.log('๐ Layout Debug Tool Started');
console.log('================================');
function debugLayout() {
const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight;
console.log(`๐ฑ Viewport: ${viewportWidth}x${viewportHeight}`);
// ํต์ฌ ์์๋ค ๊ฐ์ ธ์ค๊ธฐ
const layout = document.querySelector('.layout');
const contentWrapper = document.querySelector('.content-wrapper');
const leftSidebar = document.querySelector('.sidebar-left');
const rightSidebar = document.querySelector('.sidebar-right');
const main = document.querySelector('.main');
if (!layout || !contentWrapper) {
console.error('โ Layout elements not found!');
return;
}
// ์คํฌ๋กค ์ ๋ณด
const scrollInfo = {
documentWidth: document.documentElement.scrollWidth,
clientWidth: document.documentElement.clientWidth,
bodyWidth: document.body.scrollWidth,
hasHorizontalScroll: document.documentElement.scrollWidth > document.documentElement.clientWidth,
overflowAmount: document.documentElement.scrollWidth - document.documentElement.clientWidth
};
console.log('\n๐ Scroll Analysis:');
console.log(` Document width: ${scrollInfo.documentWidth}px`);
console.log(` Client width: ${scrollInfo.clientWidth}px`);
console.log(` Body width: ${scrollInfo.bodyWidth}px`);
if (scrollInfo.hasHorizontalScroll) {
console.log(`โ HORIZONTAL OVERFLOW: +${scrollInfo.overflowAmount}px`);
} else {
console.log(`โ
No horizontal overflow`);
}
// CSS ๋ณ์๋ค
const layoutStyles = window.getComputedStyle(layout);
const cssVars = {
sidebarWidth: layoutStyles.getPropertyValue('--sidebar-width'),
gapMain: layoutStyles.getPropertyValue('--gap-main'),
containerPaddingX: layoutStyles.getPropertyValue('--container-padding-x'),
contentMaxWidth: layoutStyles.getPropertyValue('--content-max-width')
};
console.log('\n๐จ CSS Variables:');
Object.entries(cssVars).forEach(([key, value]) => {
console.log(` --${key.replace(/([A-Z])/g, '-$1').toLowerCase()}: ${value}`);
});
// ์ปจํ
์ด๋ ์ฟผ๋ฆฌ ์ง์ ํ์ธ
const containerQuerySupport = CSS.supports('container-type: inline-size');
console.log(`\n๐ง Container Query Support: ${containerQuerySupport ? 'โ
' : 'โ'}`);
// Content Wrapper ๋ถ์
const contentStyles = window.getComputedStyle(contentWrapper);
console.log('\n๐ฆ Content Wrapper:');
console.log(` width: ${contentStyles.width}`);
console.log(` max-width: ${contentStyles.maxWidth}`);
console.log(` display: ${contentStyles.display}`);
console.log(` gap: ${contentStyles.gap}`);
console.log(` padding-left: ${contentStyles.paddingLeft}`);
console.log(` padding-right: ${contentStyles.paddingRight}`);
console.log(` overflow-x: ${contentStyles.overflowX}`);
console.log(` container-type: ${contentStyles.containerType || 'none'}`);
console.log(` clientWidth: ${contentWrapper.clientWidth}px`);
console.log(` scrollWidth: ${contentWrapper.scrollWidth}px`);
console.log(` offsetWidth: ${contentWrapper.offsetWidth}px`);
// ์ฌ์ด๋๋ฐ ๋ถ์
console.log('\n๐๏ธ Sidebars:');
if (leftSidebar) {
const leftStyles = window.getComputedStyle(leftSidebar);
const isVisible = leftStyles.display !== 'none';
console.log(` Left Sidebar: ${isVisible ? 'โ
Visible' : 'โ Hidden'}`);
if (isVisible) {
console.log(` width: ${leftStyles.width}`);
console.log(` flex: ${leftStyles.flex}`);
console.log(` clientWidth: ${leftSidebar.clientWidth}px`);
console.log(` offsetWidth: ${leftSidebar.offsetWidth}px`);
}
}
if (rightSidebar) {
const rightStyles = window.getComputedStyle(rightSidebar);
const isVisible = rightStyles.display !== 'none';
console.log(` Right Sidebar: ${isVisible ? 'โ
Visible' : 'โ Hidden'}`);
if (isVisible) {
console.log(` width: ${rightStyles.width}`);
console.log(` flex: ${rightStyles.flex}`);
console.log(` clientWidth: ${rightSidebar.clientWidth}px`);
console.log(` offsetWidth: ${rightSidebar.offsetWidth}px`);
}
}
// ๋ฉ์ธ ์ฝํ
์ธ ๋ถ์
if (main) {
const mainStyles = window.getComputedStyle(main);
console.log('\n๐ Main Content:');
console.log(` width: ${mainStyles.width}`);
console.log(` max-width: ${mainStyles.maxWidth}`);
console.log(` flex: ${mainStyles.flex}`);
console.log(` clientWidth: ${main.clientWidth}px`);
console.log(` offsetWidth: ${main.offsetWidth}px`);
console.log(` scrollWidth: ${main.scrollWidth}px`);
}
// ๊ณ์ฐ๋ ์ด ๋๋น
let calculatedWidth = 0;
const paddingX = parseInt(contentStyles.paddingLeft) + parseInt(contentStyles.paddingRight);
const gap = parseInt(contentStyles.gap) || 0;
calculatedWidth += paddingX;
if (leftSidebar && window.getComputedStyle(leftSidebar).display !== 'none') {
calculatedWidth += leftSidebar.offsetWidth + gap;
}
if (rightSidebar && window.getComputedStyle(rightSidebar).display !== 'none') {
calculatedWidth += rightSidebar.offsetWidth + gap;
}
if (main) {
calculatedWidth += main.offsetWidth;
}
console.log('\n๐งฎ Calculated Total Width:');
console.log(` Padding: ${paddingX}px`);
console.log(` Gaps: ${gap}px (per gap)`);
console.log(` Left sidebar: ${leftSidebar && window.getComputedStyle(leftSidebar).display !== 'none' ? leftSidebar.offsetWidth : 0}px`);
console.log(` Main content: ${main ? main.offsetWidth : 0}px`);
console.log(` Right sidebar: ${rightSidebar && window.getComputedStyle(rightSidebar).display !== 'none' ? rightSidebar.offsetWidth : 0}px`);
console.log(` Total calculated: ${calculatedWidth}px`);
console.log(` Viewport width: ${viewportWidth}px`);
console.log(` Difference: ${calculatedWidth - viewportWidth}px`);
return {
viewport: { width: viewportWidth, height: viewportHeight },
scroll: scrollInfo,
cssVars,
calculatedWidth,
hasOverflow: scrollInfo.hasHorizontalScroll
};
}
// ๋ฐ์ํ ํ
์คํธ์ฉ ํจ์
function testResponsive() {
console.log('\n๐ Testing Multiple Viewport Sizes...');
console.log('=====================================');
const viewports = [
{ width: 1920, height: 1080, name: 'Desktop Large' },
{ width: 1440, height: 900, name: 'Desktop Medium' },
{ width: 1280, height: 720, name: 'Desktop Small' },
{ width: 1024, height: 768, name: 'Tablet' },
{ width: 768, height: 1024, name: 'Mobile' }
];
// ํ์ฌ ์ฐฝ ํฌ๊ธฐ ์ ์ฅ
const originalWidth = window.outerWidth;
const originalHeight = window.outerHeight;
viewports.forEach(viewport => {
console.log(`\n๐ฑ Testing ${viewport.name} (${viewport.width}x${viewport.height})`);
console.log('-'.repeat(50));
// ์ฐฝ ํฌ๊ธฐ ๋ณ๊ฒฝ (์ค์ ๋ก๋ ์๋์ผ๋ก ํด์ผ ํจ)
console.log(`๐ง Please manually resize window to ${viewport.width}x${viewport.height} and run debugLayout()`);
});
console.log('\n๐ก Manual Testing Instructions:');
console.log('1. ๋ธ๋ผ์ฐ์ ์ฐฝ ํฌ๊ธฐ๋ฅผ ์์ ๊ฐ ํฌ๊ธฐ๋ก ์๋ ์กฐ์ ');
console.log('2. ๊ฐ ํฌ๊ธฐ์์ debugLayout() ํจ์ ์คํ');
console.log('3. ๊ฐ๋ก ์คํฌ๋กค ๋ฐ์ ์ฌ๋ถ ํ์ธ');
}
// ์ค์๊ฐ ๋ฆฌ์ฌ์ด์ฆ ๋ชจ๋ํฐ๋ง
function startResizeMonitoring() {
console.log('\n๐ Starting resize monitoring...');
let resizeTimeout;
window.addEventListener('resize', () => {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(() => {
console.log('\n๐ Window resized, re-analyzing...');
debugLayout();
}, 500);
});
console.log('โ
Resize monitoring active');
}
// ์ฆ์ ์คํ
const result = debugLayout();
console.log('\n๐ ๏ธ Available Commands:');
console.log(' debugLayout() - ํ์ฌ ๋ ์ด์์ ๋ถ์');
console.log(' testResponsive() - ๋ฐ์ํ ํ
์คํธ ๊ฐ์ด๋');
console.log(' startResizeMonitoring() - ๋ฆฌ์ฌ์ด์ฆ ๋ชจ๋ํฐ๋ง ์์');
// ์ค๋ฒํ๋ก์ฐ๊ฐ ์์ผ๋ฉด ๊ฒฝ๊ณ
if (result.hasOverflow) {
console.warn('\n๐จ WARNING: Horizontal overflow detected!');
console.warn(`Consider checking the calculated width: ${result.calculatedWidth}px vs viewport: ${result.viewport.width}px`);
}