Merge pull request #10 from kasmtech/feature/KASM-1882_macos_pinch_and_zoom
KASM-1882 MacOs pinch and zoom
This commit is contained in:
commit
2336c39377
20
core/rfb.js
20
core/rfb.js
|
@ -176,12 +176,26 @@ export default class RFB extends EventTargetMixin {
|
|||
this._mousePos = {};
|
||||
this._mouseButtonMask = 0;
|
||||
this._mouseLastMoveTime = 0;
|
||||
this._mouseLastPinchAndZoomTime = 0;
|
||||
this._viewportDragging = false;
|
||||
this._viewportDragPos = {};
|
||||
this._viewportHasMoved = false;
|
||||
this._accumulatedWheelDeltaX = 0;
|
||||
this._accumulatedWheelDeltaY = 0;
|
||||
|
||||
// On MacOs we simulate the CTRL key being pressed on pinch and zoom
|
||||
// so we need to manually unselect it whenever the action is completed (500ms since last scroll)
|
||||
if (isMac()) {
|
||||
setInterval(() => {
|
||||
const timeSinceLastPinchAndZoom = Math.max(0, +new Date() - this._mouseLastPinchAndZoomTime);
|
||||
|
||||
if (timeSinceLastPinchAndZoom > 500) {
|
||||
this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", false);
|
||||
this._mouseLastPinchAndZoomTime = Infinity;
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// Gesture state
|
||||
this._gestureLastTapTime = null;
|
||||
this._gestureFirstDoubleTapEv = null;
|
||||
|
@ -1346,6 +1360,12 @@ export default class RFB extends EventTargetMixin {
|
|||
this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||
}
|
||||
|
||||
// On MacOs we need to send a CTRL key to let the remote know we are pinch and zooming
|
||||
if (isMac() && ev.ctrlKey && !this._keyboard._keyDownList["ControlLeft"]) {
|
||||
this._keyboard._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
|
||||
this._mouseLastPinchAndZoomTime = +new Date();
|
||||
}
|
||||
|
||||
// Generate a mouse wheel step event when the accumulated delta
|
||||
// for one of the axes is large enough.
|
||||
if (Math.abs(this._accumulatedWheelDeltaX) >= WHEEL_STEP) {
|
||||
|
|
Loading…
Reference in New Issue