diff --git a/include/rfb.js b/include/rfb.js index e409217a..3e9344bb 100644 --- a/include/rfb.js +++ b/include/rfb.js @@ -614,14 +614,18 @@ var RFB; if (this._viewportDragging) { var deltaX = this._viewportDragPos.x - x; var deltaY = this._viewportDragPos.y - y; - this._viewportDragPos = {'x': x, 'y': y}; - // if there is actually viewport move, set the HasMoved flag to true - if (deltaX != 0 || deltaY != 0) { - this._viewportHasMoved = true; - } + // The goal is to trigger on a certain physical width, the + // devicePixelRatio brings us a bit closer but is not optimal. + var dragThreshold = 10 * window.devicePixelRatio; - this._display.viewportChangePos(deltaX, deltaY); + if (this._viewportHasMoved || (Math.abs(deltaX) > dragThreshold || + Math.abs(deltaY) > dragThreshold)) { + this._viewportHasMoved = true; + + this._viewportDragPos = {'x': x, 'y': y}; + this._display.viewportChangePos(deltaX, deltaY); + } // Skip sending mouse events return;