diff --git a/ui/client-web-view.js b/ui/client-web-view.js index b4f57ad4..75bdecf1 100644 --- a/ui/client-web-view.js +++ b/ui/client-web-view.js @@ -71,9 +71,16 @@ PageState.prototype = { }, true); // load does not bubble // Queues an update if the window changes size, e.g. if the - // user resized the window + // user resized the window. Only trigger when the width has + // changed however since the height should only change as the + // body is being loaded. + let width = window.innerWidth; window.addEventListener("resize", function(e) { - queuePreferredHeightUpdate(); + let currentWidth = window.innerWidth; + if (width != currentWidth) { + width = currentWidth; + queuePreferredHeightUpdate(); + } }, false); // load does not bubble // Queues an update when a transition has completed, e.g. if the @@ -83,7 +90,11 @@ PageState.prototype = { }, false); // load does not bubble }, getPreferredHeight: function() { - return window.document.body.scrollHeight; + // Return the scroll height of the HTML element since the BODY + // may have margin/border/padding and we want to know + // precisely how high the widget needs to be to avoid + // scrolling. + return window.document.documentElement.scrollHeight; }, getHtml: function() { return document.body.innerHTML;