@orbat-mapper/tactical-draw 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +14 -7
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -4377,6 +4377,7 @@ function runEdit(opts) {
|
|
|
4377
4377
|
const isAreaKind = metadata.geometry === "area";
|
|
4378
4378
|
const isTextGraphic = measure.kind === "text";
|
|
4379
4379
|
const foldsTransformIntoOptions = foldsBoxTransformOptions(measure.kind);
|
|
4380
|
+
const holdsAnchorOnFold = foldsTransformIntoOptions && metadata.maxCoordinates === 1;
|
|
4380
4381
|
const requestedModes = normaliseModes(initialModes);
|
|
4381
4382
|
const editStartPoints = measure.controlPoints.map((p) => [...p]);
|
|
4382
4383
|
const workingPoints = editStartPoints.map((p) => [...p]);
|
|
@@ -4535,7 +4536,7 @@ function runEdit(opts) {
|
|
|
4535
4536
|
const px = driver.toPixel(p);
|
|
4536
4537
|
if (px) pixels.push(px);
|
|
4537
4538
|
}
|
|
4538
|
-
return fitTransformBox(pixels,
|
|
4539
|
+
return fitTransformBox(pixels, anchoredOptionTransformInFlight() ? activeBoxDrag.lastSnapshot.box.angle : boxAngle, interactionStyle?.boxPadding ?? 0);
|
|
4539
4540
|
}
|
|
4540
4541
|
/**
|
|
4541
4542
|
* The Text footprint box (rotated rectangle hugging the rendered text),
|
|
@@ -4554,12 +4555,12 @@ function runEdit(opts) {
|
|
|
4554
4555
|
* Re-fit `box` from `lastWorkingFeatures`. A no-op while a box gesture is
|
|
4555
4556
|
* in flight — that drag paints the box rigidly from its own snapshot
|
|
4556
4557
|
* (`BoxDragSnapshot.box`) instead of a re-fit, so a corner/rotate/body drag
|
|
4557
|
-
* doesn't fight its own paint.
|
|
4558
|
-
* their anchor points stay fixed while their rendered footprint changes, so
|
|
4558
|
+
* doesn't fight its own paint. Single-anchor option-backed transforms are the
|
|
4559
|
+
* exception: their anchor points stay fixed while their rendered footprint changes, so
|
|
4559
4560
|
* the box must re-fit from that live render on every tick.
|
|
4560
4561
|
*/
|
|
4561
4562
|
function refitBox() {
|
|
4562
|
-
if (activeBoxDrag && !
|
|
4563
|
+
if (activeBoxDrag && !anchoredOptionTransformInFlight()) return;
|
|
4563
4564
|
box = fitBoxFromFeatures(lastWorkingFeatures);
|
|
4564
4565
|
}
|
|
4565
4566
|
function renderWorkingGraphic() {
|
|
@@ -4608,7 +4609,7 @@ function runEdit(opts) {
|
|
|
4608
4609
|
const features = toFeatures(buildCurrentHandleSet(), handleIdPrefix, interactionStyle);
|
|
4609
4610
|
if (modes.includes("labeldrag")) features.push(...labels.handleFeatures());
|
|
4610
4611
|
if (modes.includes("transform")) {
|
|
4611
|
-
const liveBox = activeBoxDrag && !
|
|
4612
|
+
const liveBox = activeBoxDrag && !anchoredOptionTransformInFlight() ? activeBoxDrag.lastSnapshot.box : box;
|
|
4612
4613
|
if (liveBox) {
|
|
4613
4614
|
features.push(boxOutlineFeature(liveBox, dragProjection.fromPixel, `${handleIdPrefix}:box-outline`, interactionStyle?.boxOutline));
|
|
4614
4615
|
features.push(...toFeatures(boxToHandles(liveBox, dragProjection.fromPixel), handleIdPrefix, interactionStyle));
|
|
@@ -5417,6 +5418,10 @@ function runEdit(opts) {
|
|
|
5417
5418
|
const kind = activeBoxDrag.fsm.kind;
|
|
5418
5419
|
return kind === "rotate" || kind === "scale";
|
|
5419
5420
|
}
|
|
5421
|
+
/** Whether the live option-backed gesture also holds a single anchor fixed. */
|
|
5422
|
+
function anchoredOptionTransformInFlight() {
|
|
5423
|
+
return holdsAnchorOnFold && activeOptionTransformInFlight();
|
|
5424
|
+
}
|
|
5420
5425
|
function paintBoxDragSnapshot(pixel, info, constrainRotation = false) {
|
|
5421
5426
|
if (!activeBoxDrag) return;
|
|
5422
5427
|
const resolvedPixel = translatedBoxPixel(pixel, info, activeBoxDrag);
|
|
@@ -5424,9 +5429,11 @@ function runEdit(opts) {
|
|
|
5424
5429
|
activeBoxDrag.lastSnapshot = snapshot;
|
|
5425
5430
|
if (activeOptionTransformInFlight()) {
|
|
5426
5431
|
const foldedOptions = foldOptionTransform(activeBoxDrag.preDragBox, snapshot.box, activeBoxDrag.fsm.kind, activeBoxDrag.preDragOptions);
|
|
5427
|
-
workingPoints.splice(0, workingPoints.length, ...activeBoxDrag.preDragPoints);
|
|
5428
5432
|
if (foldedOptions) workingOptions = foldedOptions;
|
|
5429
5433
|
nonGeometryDirty = true;
|
|
5434
|
+
}
|
|
5435
|
+
if (anchoredOptionTransformInFlight()) {
|
|
5436
|
+
workingPoints.splice(0, workingPoints.length, ...activeBoxDrag.preDragPoints);
|
|
5430
5437
|
renderWorkingGraphic();
|
|
5431
5438
|
renderHandlesLayer();
|
|
5432
5439
|
recomputeDirty();
|
|
@@ -5549,7 +5556,7 @@ function runEdit(opts) {
|
|
|
5549
5556
|
if (foldedOptions) workingOptions = foldedOptions;
|
|
5550
5557
|
nonGeometryDirty = true;
|
|
5551
5558
|
}
|
|
5552
|
-
const committedPoints = optionFold ? preDragPoints : finalSnapshot.points;
|
|
5559
|
+
const committedPoints = optionFold && holdsAnchorOnFold ? preDragPoints : finalSnapshot.points;
|
|
5553
5560
|
emitTransient("end", committedPoints, null);
|
|
5554
5561
|
commitGesture(committedPoints, preDragOptions, transformAmplifierPlacements(preDragAmplifierPlacements, preDragBox, finalSnapshot.box, driver), preDragBox.angle);
|
|
5555
5562
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbat-mapper/tactical-draw",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
4
4
|
"description": "Engine-agnostic draw/edit core for tactical control measures (MIL-STD-2525 / APP-6). The MapAdapter ABI and bring-your-own-engine entry point for the tactical-draw package family.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orbat Mapper",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@orbat-mapper/control-measures": "^0.
|
|
42
|
+
"@orbat-mapper/control-measures": "^0.32.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vitest": ">=4.0.0"
|