diff options
author | Samuel Mannehed <samuel@cendio.se> | 2019-01-14 22:29:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-14 22:29:47 +0100 |
commit | 099c4199967c6bd612e58918a1fbaed22b73d909 (patch) | |
tree | 85367b43194c0ab02da2fc886e5cabd59d030c97 | |
parent | b4819c2558497e5261f877f5966ce1f21bd460d9 (diff) | |
parent | ef64917a9091a9a12e8245099d6b0b0fbac2f6e5 (diff) | |
download | novnc-099c4199967c6bd612e58918a1fbaed22b73d909.tar.gz |
Merge pull request #1182 from novnc/scrollbarsfortouch
Enable scrollbars for all touch devices aside from Android and iOS
-rw-r--r-- | app/ui.js | 14 | ||||
-rw-r--r-- | core/util/browser.js | 31 |
2 files changed, 25 insertions, 20 deletions
@@ -8,7 +8,8 @@ import * as Log from '../core/util/logging.js'; import _, { l10n } from './localization.js'; -import { isTouchDevice, dragThreshold } from '../core/util/browser.js'; +import { isTouchDevice, isSafari, isIOS, isAndroid, dragThreshold } + from '../core/util/browser.js'; import { setCapture, getPointerEvent } from '../core/util/events.js'; import KeyTable from "../core/input/keysym.js"; import keysyms from "../core/input/keysymdef.js"; @@ -31,7 +32,6 @@ const UI = { controlbarMouseDownClientY: 0, controlbarMouseDownOffsetY: 0, - isSafari: false, lastKeyboardinput: null, defaultKeyboardinputLen: 100, @@ -56,10 +56,6 @@ const UI = { // Render default UI and initialize settings menu start(callback) { - // Setup global variables first - UI.isSafari = (navigator.userAgent.indexOf('Safari') !== -1 && - navigator.userAgent.indexOf('Chrome') === -1); - UI.initSettings(); // Translate the DOM @@ -117,7 +113,7 @@ const UI = { initFullscreen() { // Only show the button if fullscreen is properly supported // * Safari doesn't support alphanumerical input while in fullscreen - if (!UI.isSafari && + if (!isSafari() && (document.documentElement.requestFullscreen || document.documentElement.mozRequestFullScreen || document.documentElement.webkitRequestFullscreen || @@ -1248,8 +1244,8 @@ const UI = { // Can't be clipping if viewport is scaled to fit UI.forceSetting('view_clip', false); UI.rfb.clipViewport = false; - } else if (isTouchDevice) { - // Touch devices usually have shit scrollbars + } else if (isIOS() || isAndroid()) { + // iOS and Android usually have shit scrollbars UI.forceSetting('view_clip', true); UI.rfb.clipViewport = true; } else { diff --git a/core/util/browser.js b/core/util/browser.js index 32e101e..026a31a 100644 --- a/core/util/browser.js +++ b/core/util/browser.js @@ -53,6 +53,26 @@ export function isMac() { return navigator && !!(/mac/i).exec(navigator.platform); } +export function isWindows() { + return navigator && !!(/win/i).exec(navigator.platform); +} + +export function isIOS() { + return navigator && + (!!(/ipad/i).exec(navigator.platform) || + !!(/iphone/i).exec(navigator.platform) || + !!(/ipod/i).exec(navigator.platform)); +} + +export function isAndroid() { + return navigator && !!(/android/i).exec(navigator.userAgent); +} + +export function isSafari() { + return navigator && (navigator.userAgent.indexOf('Safari') !== -1 && + navigator.userAgent.indexOf('Chrome') === -1); +} + export function isIE() { return navigator && !!(/trident/i).exec(navigator.userAgent); } @@ -65,14 +85,3 @@ export function isFirefox() { return navigator && !!(/firefox/i).exec(navigator.userAgent); } -export function isWindows() { - return navigator && !!(/win/i).exec(navigator.platform); -} - -export function isIOS() { - return navigator && - (!!(/ipad/i).exec(navigator.platform) || - !!(/iphone/i).exec(navigator.platform) || - !!(/ipod/i).exec(navigator.platform)); -} - |