fix(web): PDF rect-edge adjust — a start-edge drag pins the far edge

The left-edge drag kept the rect width instead of anchoring the opposite
edge, so shrinking from the left silently dragged the right edge along
and the recomputed text grew words at the far end (found by the Android
device test of the app leg). Same fix for the top edge / bottom pin.
The end-edge branches were already correct.
This commit is contained in:
John O'Keefe committed 2026-10-10 11:47:41 -04:00
1 parent 4d1fb05e49
commit 361fdaab39
1 file changed
+10 -2
+10 -2
View File
@@ -1896,7 +1896,12 @@ document.addEventListener("alpine:init", () => {
}
if (best === null) return;
if (isStart) {
r[0] = Math.min(Math.max(best, 0), r[0] + r[2] - MIN);
// A start-edge drag pins the FAR edge: shrink the size by the
// same amount the left moves (keeping the size would drag the
// rect's right edge along — found by device test).
const far = r[0] + r[2];
r[0] = Math.min(Math.max(best, 0), far - MIN);
r[2] = far - r[0];
} else {
r[2] = Math.min(Math.max(best - r[0], MIN), 1 - r[0]);
}
@@ -1913,7 +1918,10 @@ document.addEventListener("alpine:init", () => {
}
}
if (grab.edge === "top") {
r[1] = Math.min(Math.max(best, 0), r[1] + r[3] - MIN);
// Mirror of the left edge: a top-edge drag pins the bottom.
const bottom = r[1] + r[3];
r[1] = Math.min(Math.max(best, 0), bottom - MIN);
r[3] = bottom - r[1];
} else {
r[3] = Math.min(Math.max(best - r[1], MIN), 1 - r[1]);
}