From b6eb429f7775c09d2970e6041b8c618c074eed44 Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Sun, 6 Dec 2020 17:47:19 +0100 Subject: [PATCH] Always drag using pointer location, not vertex location --- src/ol/interaction/Modify.js | 4 ++-- test/spec/ol/interaction/modify.test.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ol/interaction/Modify.js b/src/ol/interaction/Modify.js index 573f1ddbd7..58b6178553 100644 --- a/src/ol/interaction/Modify.js +++ b/src/ol/interaction/Modify.js @@ -1163,8 +1163,8 @@ class Modify extends PointerInteraction { const vertexSegments = {}; vertexSegments[getUid(closestSegment)] = true; - this.delta_[0] = hitPointGeometry ? vertex[0] - pixelCoordinate[0] : 0; - this.delta_[1] = hitPointGeometry ? vertex[1] - pixelCoordinate[1] : 0; + this.delta_[0] = vertex[0] - pixelCoordinate[0]; + this.delta_[1] = vertex[1] - pixelCoordinate[1]; if ( node.geometry.getType() === GeometryType.CIRCLE && node.index === CIRCLE_CIRCUMFERENCE_INDEX diff --git a/test/spec/ol/interaction/modify.test.js b/test/spec/ol/interaction/modify.test.js index bc7f314076..386869d593 100644 --- a/test/spec/ol/interaction/modify.test.js +++ b/test/spec/ol/interaction/modify.test.js @@ -498,7 +498,7 @@ describe('ol.interaction.Modify', function () { simulateEvent('pointerdrag', 30, -5, null, 0); simulateEvent('pointerup', 30, -5, null, 0); - expect(circleFeature.getGeometry().getRadius()).to.equal(25); + expect(circleFeature.getGeometry().getRadius()).to.roughlyEqual(25, 0.1); expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]); // Increase radius along y axis @@ -508,7 +508,7 @@ describe('ol.interaction.Modify', function () { simulateEvent('pointerdrag', 5, -35, null, 0); simulateEvent('pointerup', 5, -35, null, 0); - expect(circleFeature.getGeometry().getRadius()).to.equal(30); + expect(circleFeature.getGeometry().getRadius()).to.roughlyEqual(30, 0.1); expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]); }); @@ -553,7 +553,7 @@ describe('ol.interaction.Modify', function () { .getGeometry() .clone() .transform(userProjection, viewProjection); - expect(geometry2.getRadius()).to.roughlyEqual(25, 1e-9); + expect(geometry2.getRadius()).to.roughlyEqual(25, 0.1); expect(geometry2.getCenter()).to.eql([5, 5]); // Increase radius along y axis @@ -567,7 +567,7 @@ describe('ol.interaction.Modify', function () { .getGeometry() .clone() .transform(userProjection, viewProjection); - expect(geometry3.getRadius()).to.roughlyEqual(30, 1e-9); + expect(geometry3.getRadius()).to.roughlyEqual(30, 0.1); expect(geometry3.getCenter()).to.eql([5, 5]); }); }); @@ -1084,7 +1084,7 @@ describe('ol.interaction.Modify', function () { simulateEvent('pointerdrag', 30, -5, null, 0); simulateEvent('pointerup', 30, -5, null, 0); - expect(circleFeature.getGeometry().getRadius()).to.equal(25); + expect(circleFeature.getGeometry().getRadius()).to.roughlyEqual(25, 1e9); expect(circleFeature.getGeometry().getCenter()).to.eql([5, 5]); // Increase radius along y axis