Skip to content

Commit

Permalink
Merge 9607ee0 into d57b6fe
Browse files Browse the repository at this point in the history
  • Loading branch information
georgios-uber committed Apr 6, 2019
2 parents d57b6fe + 9607ee0 commit d4dd420
Show file tree
Hide file tree
Showing 10 changed files with 3,117 additions and 95 deletions.
807 changes: 807 additions & 0 deletions examples/deck/yarn.lock

Large diffs are not rendered by default.

32 changes: 13 additions & 19 deletions modules/layers/src/mode-handlers/snappable-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ export class SnappableHandler extends ModeHandler {
const updatedFeature = updatedData.features[selectedIndex];

const { positionIndexes, featureIndex } = pickedHandle;
if (selectedIndex >= 0 && featureIndex !== selectedIndex) return;

const { coordinates } = updatedFeature.geometry;
// $FlowFixMe
(pickedHandle || {}).position = positionIndexes.reduce(
(a: any[], b: number) => a[b],
coordinates
);
if (selectedIndex >= 0 && featureIndex === selectedIndex) {
const { coordinates } = updatedFeature.geometry;
// $FlowFixMe
pickedHandle.position = positionIndexes.reduce(
(a: any[], b: number) => a[b],
coordinates
);
}
}
}
}
Expand All @@ -115,7 +115,7 @@ export class SnappableHandler extends ModeHandler {
// selected feature. If a snap handle has been picked, display said snap handle
// along with all snappable points on all non-selected features.
getEditHandles(picks?: Array<Object>, groundCoords?: Position): any[] {
const { enableSnapping } = this._modeConfig;
const { enableSnapping } = this._modeConfig || {};
const handles = this._handler.getEditHandles(picks, groundCoords);

if (!enableSnapping) return handles;
Expand All @@ -137,18 +137,12 @@ export class SnappableHandler extends ModeHandler {
return handles.filter(Boolean);
}

_shouldPerformSnap() {
if (!this._editHandlePicks) return false;
const { pickedHandle, potentialSnapHandle } = this._editHandlePicks || {};
return pickedHandle && potentialSnapHandle;
}

_performSnapIfRequired() {
if (this._isSnapped || !this._editHandlePicks || !this._shouldPerformSnap()) return;
if (this._isSnapped) return;
const { pickedHandle, potentialSnapHandle } = this._editHandlePicks || {};
if (!pickedHandle || !potentialSnapHandle) return;

this._isSnapped = true;
if (pickedHandle && potentialSnapHandle) {
this._isSnapped = true;
}
}

// Unsnapping only occurs after the user snaps two polygons but continues to drag the
Expand Down
Loading

0 comments on commit d4dd420

Please sign in to comment.