From 68c98d1293e048dcee57778386a4b98a6fb33551 Mon Sep 17 00:00:00 2001 From: Uwe Oestermeier Date: Fri, 19 Jul 2019 15:05:46 +0200 Subject: [PATCH] Added check for rotation by narrow distance between touch points. --- lib/interaction.js | 7 +++++-- lib/scatter.js | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/interaction.js b/lib/interaction.js index cf85729..2468842 100755 --- a/lib/interaction.js +++ b/lib/interaction.js @@ -131,15 +131,17 @@ export class InteractionDelta { * @param {*} rotate * @param {*} about * @param {*} number - number of involved pointer + * @param {*} distance - distance of farthests touch points * @memberof InteractionDelta */ - constructor(x, y, zoom, rotate, about, number) { + constructor(x, y, zoom, rotate, about, number, distance) { this.x = x this.y = y this.zoom = zoom this.rotate = rotate this.about = about this.number = number + this.distance = distance } toString() { @@ -235,7 +237,8 @@ export class InteractionPoints { zoom, alpha, cm, - csize + csize, + distance2 ) } else if ( csize == 1 && diff --git a/lib/scatter.js b/lib/scatter.js index c29c22a..3ab314e 100644 --- a/lib/scatter.js +++ b/lib/scatter.js @@ -286,6 +286,7 @@ export class AbstractScatter extends Throwable { scaleCloseThreshold = 0.1, scaleCloseBuffer = 0.05, maxRotation = Angle.degree2radian(5), + minRotationDistance = 200, useLowPassFilter = true } = {}) { if (rotationDegrees != null && rotation != null) { @@ -331,6 +332,7 @@ export class AbstractScatter extends Throwable { this.mouseZoomFactor = mouseZoomFactor this.autoBringToFront = autoBringToFront this.useLowPassFilter = useLowPassFilter + this.minRotationDistance = minRotationDistance if (useLowPassFilter) { this.rotateLPF = new LowPassFilter() this.zoomLPF = new LowPassFilter() @@ -387,7 +389,9 @@ export class AbstractScatter extends Throwable { if (this.useLowPassFilter) { rotate = this.rotateLPF.next(rotate) zoom = this.zoomLPF.next(zoom) - // console.log({rotate, zoom}) + if (delta.distance < this.minRotationDistance) { + rotate = 0 + } } this.transform(delta, zoom, rotate, delta.about) if (zoom != 1) this.interactionAnchor = delta.about