Add a threshold for viewport dragging (#600)
This commit is contained in:
parent
27e77d468f
commit
32df3fdbe1
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue