Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
underbluewaters committed Oct 9, 2023
1 parent 8a61e0e commit a4ea08c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/client/src/MeasureControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class MeasureControl extends EventEmitter {

const hasLock = this.mapContextManager.hasLock(MeasureControlLockId);
if (state !== "disabled" && !hasLock) {
console.trace("requesting lock", state);
const lock = await this.mapContextManager.requestDigitizingLock(
MeasureControlLockId,
state === "dragging" || state === "drawing"
Expand All @@ -249,6 +250,7 @@ class MeasureControl extends EventEmitter {
async (requester) => {
console.log("lock requested", requester, state);
if (this.state === "editing") {
console.log("setting state to paused");
this.setState("paused");
} else {
this.disable();
Expand All @@ -257,6 +259,7 @@ class MeasureControl extends EventEmitter {
}
);
if (!lock) {
console.log("lock request failed");
return;
}
}
Expand Down Expand Up @@ -386,6 +389,8 @@ class MeasureControl extends EventEmitter {
halo: true,
}
);
} else {
console.log("lock request denied");
}
}
}
Expand Down Expand Up @@ -513,7 +518,7 @@ class MeasureControl extends EventEmitter {
if (this.isDestroyed) {
throw new Error("MeasureControl is destroyed");
}
console.log("on mouse down point");
console.log("on mouse down point", this.state, this.draggedPointIndex);
if (this.state === "editing" && this.draggedPointIndex > -1) {
this.setState("dragging");
}
Expand Down Expand Up @@ -590,9 +595,11 @@ class MeasureControl extends EventEmitter {
throw new Error("MeasureControl is destroyed");
}
if (this.state === "drawing") {
console.log("is drawing, handle cursor move");
// update cursor
this.handleCursorMove(e);
} else if (this.state === "dragging") {
console.log("is dragging");
this.handleDragPoint(e);
}
};
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/dataLayers/MapContextManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,8 @@ class MapContextManager extends EventEmitter {
} else {
// first, check if you can release the lock
const released =
this.onLockReleaseRequested === null
this.onLockReleaseRequested === null ||
id === this.internalState.digitizingLockedBy
? true
: await this.onLockReleaseRequested(
id,
Expand Down

0 comments on commit a4ea08c

Please sign in to comment.