fix: サイドバーiframeの高さ追従が初回実行されずコンテンツが回り込む問題を修正
This commit is contained in:
1 parent
0533cd3896
commit
6260f99a1b
3 files changed
+21
-3
No files matched your search
@@ -181,7 +181,7 @@ a:hover {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
min-height: 600px;
|
||||
border: none;
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -753,18 +753,35 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
try {
|
||||
|
||||
const doc = sidebarFrame.contentWindow.document;
|
||||
const win = sidebarFrame.contentWindow;
|
||||
|
||||
sidebarFrame.style.height = doc.body.scrollHeight + 'px';
|
||||
const doc = win.document;
|
||||
|
||||
const h = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight);
|
||||
|
||||
sidebarFrame.style.height = h + 'px';
|
||||
|
||||
} catch (e) { /* クロスオリジン時は無視 */ }
|
||||
|
||||
};
|
||||
|
||||
// 既に読み込み完了している場合は即実行(load を取り逃がす対策)
|
||||
const sdoc = sidebarFrame.contentWindow && sidebarFrame.contentWindow.document;
|
||||
|
||||
if (sdoc && sdoc.readyState === 'complete') {
|
||||
|
||||
fitSidebar();
|
||||
|
||||
} else {
|
||||
|
||||
sidebarFrame.addEventListener('load', fitSidebar);
|
||||
|
||||
}
|
||||
|
||||
window.addEventListener('resize', fitSidebar);
|
||||
|
||||
window.addEventListener('load', fitSidebar);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@@ -16,6 +16,7 @@
|
||||
padding: 16px 12px;
|
||||
font-size: 13px;
|
||||
overflow-x: hidden;
|
||||
min-height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
Reference in new issue
Block a user