From b0740de6e7c6adf0c512ad7d6d5dc122618252b8 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 5 Apr 2020 18:06:32 +0200 Subject: [PATCH] make iframe dynamic height --- UI/GeneralUI.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 9e37493..06de97f 100644 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -42,6 +42,7 @@ export class GeneralUI } this.bindHref(e); + this.bindIframe(e); this.bindLazyLoad(e); this.bindInput(e); }; @@ -81,6 +82,27 @@ export class GeneralUI } }; + /** + * Bind & rebind UI element. + * + * @param {Object} [e] Element id + * + * @return {void} + * + * @since 1.0.0 + */ + bindIframe (e) + { + e = e !== null ? e : document.getElementsByTagName('iframe'); + const length = e.length; + + for (let i = 0; i < length; ++i) { + e[i].addEventListener('load', function() { + this.height = this.contentWindow.document.body.scrollHeight + 25; + }); + } + } + /** * Bind & rebind UI element. *