mirror of
https://github.com/acid-info/lsd.git
synced 2025-01-12 10:04:24 +00:00
feat: broadcast height to parents - useful when iframed
This commit is contained in:
parent
55d4bda014
commit
31c2c9ea91
23
packages/lsd-react/.storybook/preview-head.html
Normal file
23
packages/lsd-react/.storybook/preview-head.html
Normal file
@ -0,0 +1,23 @@
|
||||
<script>
|
||||
function sendHeightToParent() {
|
||||
const height =
|
||||
document.documentElement.scrollHeight || document.body.scrollHeight
|
||||
window.parent.postMessage(
|
||||
{
|
||||
type: 'iframeResize',
|
||||
height: height,
|
||||
},
|
||||
'*',
|
||||
)
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
// Send initial height.
|
||||
sendHeightToParent()
|
||||
|
||||
// Ensure the interval is set only once.
|
||||
if (!window.heightIntervalSet) {
|
||||
window.heightIntervalSet = setInterval(sendHeightToParent, 1000)
|
||||
}
|
||||
})
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user