Merge pull request #11978 from ahocevar/snap-delta-optional
Add snapToPointer option
This commit is contained in:
@@ -128,6 +128,8 @@ const ModifyEventType = {
|
||||
* provided, a vector source must be provided with the `source` option.
|
||||
* @property {boolean} [wrapX=false] Wrap the world horizontally on the sketch
|
||||
* overlay.
|
||||
* @property {boolean} [snapToPointer=!hitDetection] The vertex, point or segment being modified snaps to the
|
||||
* pointer coordinate when clicked within the `pixelTolerance`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -386,6 +388,14 @@ class Modify extends PointerInteraction {
|
||||
* @type {Array<number>}
|
||||
*/
|
||||
this.delta_ = [0, 0];
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
this.snapToPointer_ =
|
||||
options.snapToPointer === undefined
|
||||
? !this.hitDetection_
|
||||
: options.snapToPointer;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1163,8 +1173,10 @@ class Modify extends PointerInteraction {
|
||||
const vertexSegments = {};
|
||||
vertexSegments[getUid(closestSegment)] = true;
|
||||
|
||||
this.delta_[0] = vertex[0] - pixelCoordinate[0];
|
||||
this.delta_[1] = vertex[1] - pixelCoordinate[1];
|
||||
if (!this.snapToPointer_) {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user