mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-11 19:09:20 +00:00
Resizing a rotated element from an NW/NE/SW handle made it jump/lag and left the selection box detached from the element (empty gap when shrinking); the SE handle was fine. Root cause: the anchor translation that keeps the opposite corner fixed was computed from the axis-aligned bounding-box delta (originWidth − measuredWidth) and pushed through GSAP x/y. GSAP x/y is a screen-space translate, but a rotated element grows about its transform-origin in its LOCAL frame, so its real corners move along rotated axes — the AABB delta then slid the fixed corner every frame (drift ∝ drag distance, up to ~10px at −4° on a 640×360 image; zero only when unrotated, which is why SE and axis-aligned elements looked correct). Fix: pin the actual (rotation-aware) fixed corner. New elementCornerOverlayPoints() transforms the element's border-box corners through its live transform matrix into overlay coords; startGesture captures the fixed corner (opposite the grabbed handle) at gesture start; the pointermove anchor is now (fixedStart − fixedAfterSize), the exact screen shift needed to return that corner home. Falls back to the old AABB delta only when the live DOM can't be measured. The box left/top is re-read from the element's post-anchor AABB so it hugs the true bounds every frame. Verified live in Studio against a rotated (−4°) image via the shipped functions: fixed-corner drift 0.00px on every sampled frame for NW/NE/SW (was up to 10.58px), and 0.00px across 0°/−4°/30°.