Skip to content

Commit

Permalink
Merge pull request novnc#1182 from novnc/scrollbarsfortouch
Browse files Browse the repository at this point in the history
Enable scrollbars for all touch devices aside from Android and iOS
  • Loading branch information
samhed authored Jan 14, 2019
2 parents b4819c2 + ef64917 commit 099c419
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
14 changes: 5 additions & 9 deletions app/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -31,7 +32,6 @@ const UI = {
controlbarMouseDownClientY: 0,
controlbarMouseDownOffsetY: 0,

isSafari: false,
lastKeyboardinput: null,
defaultKeyboardinputLen: 100,

Expand All @@ -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
Expand Down Expand Up @@ -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 ||
Expand Down Expand Up @@ -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 {
Expand Down
31 changes: 20 additions & 11 deletions core/util/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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));
}

0 comments on commit 099c419

Please sign in to comment.