Keep text and images in place when resized on defense (#227)

* Keep text and images in place when resized on defense

On defense a text box or image mirrors attack, so it hangs from its
bottom-right corner. Dragging the right-hand resize handle moved the
left edge instead, and because the width was measured from that moving
edge, the box ran away from the pointer.

A resize now pins the box's on-screen top-left, and on release stores
the size together with the canonical position that keeps it there.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Move the resize pin with a mid-drag side switch

Switching sides while holding a resize handle left the pin at the old
side's screen position, and release read it on the new side, so the
stored position landed hundreds of pixels off. The pin now moves to
where the box shows on the new side.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Keep the resize width tracking the pointer after a side switch

A side switch mid-resize mirrors the box away from the held pointer, and
the next drag update measured the width from the new left edge, so the
box jumped hundreds of pixels wide. The builders now remember how far
the left edge moved and measure from where it was.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Store a resize when it is released, not a frame later

A resize waited one frame after release before storing, so the final
size was laid out. A page switch inside that frame could land the
resize on the next page's copy of the item, which keeps the same id.

Pointer events arrive between frames, and a frame builds and lays out
together. So on release the box on screen always matches the size it
was last built at. Storing that size with the rendered box makes the
commit synchronous and exact. A final move the frame never drew is
dropped, so the box stays where the user last saw it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Keep a quick resize's last movement and write only to its own item

Storing the size last drawn at release dropped movement that arrived
after the last frame: a quick drag could be lost entirely. Go back to
storing the final size one frame after release, when it is laid out.
Write it only if the text or image being resized is still loaded. A page
switch in that frame loads the next page's copy, which keeps the same
id, so the resize can no longer land on it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Store a resize's size on release and settle its position a frame later

With the write deferred a frame, a page save right after release still
read the old size, and the page switch then replaced the item, so the
resize was lost. Store the size, and a position from the current
layout, as soon as the handle is released. Hold the pin one more frame,
then store the position again if the final layout moved it, only while
the same item is still loaded. Normally that second write finds nothing
to change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
d8f2a2d33aDara Adedeji committed on 9/29/2026, 6:43:24 AM· committed by GitHubparent3724d85
8 files changedLine totals unavailable