diff --git a/guacamole/src/main/webapp/app/client/directives/guacViewport.js b/guacamole/src/main/webapp/app/client/directives/guacViewport.js index 5f8269dce..d14a70a5e 100644 --- a/guacamole/src/main/webapp/app/client/directives/guacViewport.js +++ b/guacamole/src/main/webapp/app/client/directives/guacViewport.js @@ -32,8 +32,7 @@ angular.module('client').directive('guacViewport', [function guacViewport() { function guacViewportController($scope, $injector, $element) { // Required services - var $window = $injector.get('$window'); - var $document = $injector.get('$document'); + var $window = $injector.get('$window'); /** * The fullscreen container element. @@ -43,18 +42,22 @@ angular.module('client').directive('guacViewport', [function guacViewport() { var element = $element.find('.viewport')[0]; /** - * The main document object. - * - * @type Document - */ - var document = $document[0]; - - /** - * The current adjusted height of the viewport element, if any. + * The width of the browser viewport when fitVisibleArea() was last + * invoked, in pixels, or null if fitVisibleArea() has not yet been + * called. * * @type Number */ - var currentAdjustedHeight = null; + var lastViewportWidth = null; + + /** + * The height of the browser viewport when fitVisibleArea() was + * last invoked, in pixels, or null if fitVisibleArea() has not yet + * been called. + * + * @type Number + */ + var lastViewportHeight = null; /** * Resizes the container element inside the guacViewport such that @@ -63,31 +66,32 @@ angular.module('client').directive('guacViewport', [function guacViewport() { */ var fitVisibleArea = function fitVisibleArea() { - // Pull scroll properties - var scrollLeft = document.body.scrollLeft; - var scrollTop = document.body.scrollTop; - var scrollWidth = document.body.scrollWidth; - var scrollHeight = document.body.scrollHeight; - - // Calculate new height - var adjustedHeight = scrollHeight - scrollTop; - - // Only update if not in response to our own call to scrollTo() - if (scrollLeft !== scrollWidth && scrollTop !== scrollHeight - && currentAdjustedHeight !== adjustedHeight) { - - // Adjust element to fit exactly within visible area - element.style.height = adjustedHeight + 'px'; - currentAdjustedHeight = adjustedHeight; - - // Scroll to bottom - $window.scrollTo(scrollWidth, scrollHeight); + // Calculate viewport dimensions (this is NOT necessarily the + // same as 100vw and 100vh, 100%, etc., particularly when the + // on-screen keyboard of a mobile device pops open) + var viewportWidth = $window.innerWidth; + var viewportHeight = $window.innerHeight; + // Adjust element width to fit exactly within visible area + if (viewportWidth !== lastViewportWidth) { + element.style.width = viewportWidth + 'px'; + lastViewportWidth = viewportWidth; } - // Manually attempt scroll if height has not been adjusted - else if (adjustedHeight === 0) - $window.scrollTo(scrollWidth, scrollHeight); + // Adjust element height to fit exactly within visible area + if (viewportHeight !== lastViewportHeight) { + element.style.height = viewportHeight + 'px'; + lastViewportHeight = viewportHeight; + } + + // Scroll element such that its upper-left corner is exactly + // within the viewport upper-left corner, if not already there + if (element.scrollLeft || element.scrollTop) { + $window.scrollTo( + $window.pageXOffset + element.scrollLeft, + $window.pageYOffset + element.scrollTop + ); + } }; diff --git a/guacamole/src/main/webapp/app/client/styles/keyboard.css b/guacamole/src/main/webapp/app/client/styles/keyboard.css index e5bb96317..5bf38889a 100644 --- a/guacamole/src/main/webapp/app/client/styles/keyboard.css +++ b/guacamole/src/main/webapp/app/client/styles/keyboard.css @@ -19,7 +19,6 @@ .keyboard-container { - display: none; text-align: center; width: 100%; @@ -33,7 +32,3 @@ z-index: 1; } - -.keyboard-container.open { - display: block; -} \ No newline at end of file diff --git a/guacamole/src/main/webapp/app/client/styles/text-input.css b/guacamole/src/main/webapp/app/client/styles/text-input.css deleted file mode 100644 index 28e905ef4..000000000 --- a/guacamole/src/main/webapp/app/client/styles/text-input.css +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -.text-input-container { - display: none; -} - -.text-input-container.open { - display: block; -} diff --git a/guacamole/src/main/webapp/app/client/styles/viewport.css b/guacamole/src/main/webapp/app/client/styles/viewport.css index 9b43e0280..f1bf157c5 100644 --- a/guacamole/src/main/webapp/app/client/styles/viewport.css +++ b/guacamole/src/main/webapp/app/client/styles/viewport.css @@ -20,7 +20,7 @@ .viewport { position: absolute; bottom: 0; - left: 0; + right: 0; width: 100%; height: 100%; overflow: hidden; diff --git a/guacamole/src/main/webapp/app/client/templates/client.html b/guacamole/src/main/webapp/app/client/templates/client.html index 5325b478e..1270efc38 100644 --- a/guacamole/src/main/webapp/app/client/templates/client.html +++ b/guacamole/src/main/webapp/app/client/templates/client.html @@ -22,12 +22,12 @@