Add a threshold for viewport dragging (#600)

This commit is contained in:
samhed 2016-04-28 17:41:48 +02:00
parent 27e77d468f
commit 32df3fdbe1
1 changed files with 10 additions and 6 deletions

View File

@ -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) {
// 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;
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;