Reverted viewport fixes due to Android regression.

This commit is contained in:
Michael Jumper
2012-04-06 13:20:46 -07:00
parent 7fde111c1b
commit 877bcfea13
3 changed files with 37 additions and 30 deletions

View File

@@ -57,20 +57,20 @@
<!-- Keyboard event target for platforms with native OSKs --> <!-- Keyboard event target for platforms with native OSKs -->
<textarea id="eventTarget"></textarea> <textarea id="eventTarget"></textarea>
<!-- Display -->
<div id="display">
<!-- Menu trigger --> <!-- Menu trigger -->
<div id="menuControl"></div> <div id="menuControl"></div>
<!-- Scrollable viewport -->
<div id="viewport">
<!-- Display -->
<div id="display"></div>
</div> </div>
<!-- On-screen keyboard --> <!-- On-screen keyboard -->
<div id="keyboardContainer"></div> <div id="keyboardContainer"></div>
<!-- Dimensional clone of viewport -->
<div id="viewportClone"/>
<!-- Dialogs --> <!-- Dialogs -->
<div class="dialogOuter"> <div class="dialogOuter">
<div class="dialogMiddle"> <div class="dialogMiddle">

View File

@@ -23,7 +23,7 @@ var GuacamoleUI = {
/* UI Elements */ /* UI Elements */
"viewport" : document.getElementById("viewport"), "viewport" : document.getElementById("viewportClone"),
"display" : document.getElementById("display"), "display" : document.getElementById("display"),
"menu" : document.getElementById("menu"), "menu" : document.getElementById("menu"),
"menuControl" : document.getElementById("menuControl"), "menuControl" : document.getElementById("menuControl"),
@@ -464,29 +464,34 @@ GuacamoleUI.attach = function(guac) {
mouse.onmousedown = mouse.onmouseup = mouse.onmousemove = mouse.onmousedown = mouse.onmouseup = mouse.onmousemove =
function(mouseState) { function(mouseState) {
// Get current viewport scroll
var scroll_x = GuacamoleUI.viewport.scrollLeft;
var scroll_y = GuacamoleUI.viewport.scrollTop;
// Determine mouse position within view // Determine mouse position within view
var mouse_view_x = mouseState.x + guac_display.offsetLeft - scroll_x; var mouse_view_x = mouseState.x + guac_display.offsetLeft - window.pageXOffset;
var mouse_view_y = mouseState.y + guac_display.offsetTop - scroll_y; var mouse_view_y = mouseState.y + guac_display.offsetTop - window.pageYOffset;
// Determine viewport dimensioins // Determine viewport dimensioins
var view_width = GuacamoleUI.viewport.offsetWidth; var view_width = GuacamoleUI.viewport.offsetWidth;
var view_height = GuacamoleUI.viewport.offsetHeight; var view_height = GuacamoleUI.viewport.offsetHeight;
// Scroll horizontally if necessary // Determine scroll amounts based on mouse position relative to document
if (mouse_view_x > view_width)
GuacamoleUI.viewport.scrollLeft += mouse_view_x - view_width;
else if (mouse_view_x < 0)
GuacamoleUI.viewport.scrollLeft += mouse_view_x;
// Scroll vertically if necessary var scroll_amount_x;
if (mouse_view_x > view_width)
scroll_amount_x = mouse_view_x - view_width;
else if (mouse_view_x < 0)
scroll_amount_x = mouse_view_x;
else
scroll_amount_x = 0;
var scroll_amount_y;
if (mouse_view_y > view_height) if (mouse_view_y > view_height)
GuacamoleUI.viewport.scrollTop += mouse_view_y - view_height; scroll_amount_y = mouse_view_y - view_height;
else if (mouse_view_y < 0) else if (mouse_view_y < 0)
GuacamoleUI.viewport.scrollTop += mouse_view_y; scroll_amount_y = mouse_view_y;
else
scroll_amount_y = 0;
// Scroll (if necessary) to keep mouse on screen.
window.scrollBy(scroll_amount_x, scroll_amount_y);
// Send mouse event // Send mouse event
guac.sendMouseState(mouseState); guac.sendMouseState(mouseState);

View File

@@ -47,7 +47,7 @@ div.dialogOuter {
display: table; display: table;
height: 100%; height: 100%;
width: 100%; width: 100%;
position: absolute; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
@@ -141,7 +141,7 @@ div.dialog p {
/* Menu */ /* Menu */
#menu { #menu {
position: absolute; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
width: 100%; width: 100%;
@@ -218,7 +218,7 @@ div#clipboardDiv textarea {
} }
div#menuControl { div#menuControl {
position: absolute; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@@ -229,21 +229,23 @@ div#menuControl {
z-index: 3; z-index: 3;
} }
/* Viewport */ /* Viewport Clone */
div#viewport { div#viewportClone {
display: table;
height: 100%; height: 100%;
width: 100%; width: 100%;
position: absolute; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
overflow: auto;
visibility: hidden;
} }
/* Keyboard event target */ /* Keyboard event target */
textarea#eventTarget { textarea#eventTarget {
position: absolute; position: fixed;
/* Hide offscreen */ /* Hide offscreen */
left: 0; left: 0;