resize only comments iframe, prevent to resize iframe by comments info

This commit is contained in:
Pavel Mineev
2021-03-14 04:16:33 -05:00
committed by Umputun
parent 4325a3c249
commit 682758a58e
+5 -3
View File
@@ -33,10 +33,10 @@
}
})();
</script>
<!-- TODO: we have to move styles in css file -->
<style>
html,
body {
height: 100%;
margin: 0;
padding: 0;
-webkit-font-smoothing: antialiased;
@@ -44,7 +44,6 @@
}
body {
height: 100%;
padding: 6px;
}
@@ -128,9 +127,12 @@
</script>
<% } %>
<script>
// TODO: we must stop using `setInterval` for resize iframe
// TODO: we must use more efficient way to change iframe height
// TODO: we must open comments widget and user-info widget on different pages (now iframe.html opens both of widgets)
var lastHeight = 0;
setInterval(function () {
if (document.body.offsetHeight !== lastHeight && document.body.offsetHeight > 10) {
if (document.body.offsetHeight !== lastHeight && document.body.offsetHeight > 22) {
lastHeight = document.body.offsetHeight;
window.parent.postMessage(JSON.stringify({ remarkIframeHeight: lastHeight }), '*');
}