/*
* noVNC: HTML5 VNC client
- * Copyright 2018 Pierre Ossman for noVNC
+ * Copyright (C) 2019 The noVNC Authors
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
*/
import { supportsCursorURIs, isTouchDevice } from './browser.js';
-const useFallback = !supportsCursorURIs() || isTouchDevice;
+const useFallback = !supportsCursorURIs || isTouchDevice;
export default class Cursor {
- constructor(container) {
+ constructor() {
this._target = null;
this._canvas = document.createElement('canvas');
}
_showCursor() {
- if (this._canvas.style.visibility === 'hidden')
+ if (this._canvas.style.visibility === 'hidden') {
this._canvas.style.visibility = '';
+ }
}
_hideCursor() {
- if (this._canvas.style.visibility !== 'hidden')
+ if (this._canvas.style.visibility !== 'hidden') {
this._canvas.style.visibility = 'hidden';
+ }
}
// Should we currently display the cursor?
// different cursor set)
_shouldShowCursor(target) {
// Easy case
- if (target === this._target)
+ if (target === this._target) {
return true;
+ }
// Other part of the DOM?
- if (!this._target.contains(target))
+ if (!this._target.contains(target)) {
return false;
+ }
// Has the child its own cursor?
// FIXME: How can we tell that a sub element has an
// explicit "cursor: none;"?
- if (window.getComputedStyle(target).cursor !== 'none')
+ if (window.getComputedStyle(target).cursor !== 'none') {
return false;
+ }
return true;
}
_updateVisibility(target) {
- if (this._shouldShowCursor(target))
+ if (this._shouldShowCursor(target)) {
this._showCursor();
- else
+ } else {
this._hideCursor();
+ }
}
_updatePosition() {