From f56757c0a909b45e83a126cc6d117fbfb9916ca7 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 20 May 2014 16:23:09 -0700 Subject: [PATCH] GUAC-705: Only call window.scrollTo() when absolutely necessary. --- .../src/main/webapp/scripts/client-ui.js | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/guacamole/src/main/webapp/scripts/client-ui.js b/guacamole/src/main/webapp/scripts/client-ui.js index 8f02c2ac7..607b3dd38 100644 --- a/guacamole/src/main/webapp/scripts/client-ui.js +++ b/guacamole/src/main/webapp/scripts/client-ui.js @@ -1583,26 +1583,32 @@ GuacUI.Client.attach = function(guac) { * Reflow layout and send size events on resize/scroll */ - var last_scroll_top = 0; - var last_scroll_left = 0; - var last_width = 0; - var last_height = 0; + var last_scroll_left = 0; + var last_scroll_top = 0; + var last_scroll_width = 0; + var last_scroll_height = 0; + var last_window_width = 0; + var last_window_height = 0; function __update_layout() { - // Reset scroll and reposition document such that it's on-screen - window.scrollTo(document.body.scrollWidth, document.body.scrollHeight); - // Only reflow if size or scroll have changed - if (document.body.scrollTop != last_scroll_top - || document.body.scrollLeft != last_scroll_left - || window.innerWidth != last_width - || window.innerHeight != last_height) { + if (document.body.scrollLeft !== last_scroll_left + || document.body.scrollTop !== last_scroll_top + || document.body.scrollWidth !== last_scroll_width + || document.body.scrollHeight !== last_scroll_height + || window.innerWidth !== last_window_width + || window.innerHeight !== last_window_height) { - last_scroll_top = document.body.scrollTop; - last_scroll_left = document.body.scrollLeft; - last_width = window.innerWidth; - last_height = window.innerHeight; + last_scroll_top = document.body.scrollTop; + last_scroll_left = document.body.scrollLeft; + last_scroll_width = document.body.scrollWidth; + last_scroll_height = document.body.scrollHeight; + last_window_width = window.innerWidth; + last_window_height = window.innerHeight; + + // Reset scroll and reposition document such that it's on-screen + window.scrollTo(document.body.scrollWidth, document.body.scrollHeight); // Determine height of bottom section (currently only text input) var bottom = GuacUI.Client.text_input.container;