Always drag using pointer location, not vertex location

This commit is contained in:
Andreas Hocevar
2020-12-06 17:47:19 +01:00
parent 0e15720f2e
commit b6eb429f77
2 changed files with 7 additions and 7 deletions

View File

@@ -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

View File

@@ -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