fix: サイドバーiframeの高さ追従が初回実行されずコンテンツが回り込む問題を修正
This commit is contained in:
1 parent
0533cd3896
commit
6260f99a1b
3 files changed
+22
-4
No files matched your search
@@ -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) { /* クロスオリジン時は無視 */ }
|
||||
|
||||
};
|
||||
|
||||
sidebarFrame.addEventListener('load', fitSidebar);
|
||||
// 既に読み込み完了している場合は即実行(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);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user