Skip to content

fix(transform): preserve origin when decomposing transforms - #1176

Open
dvd233 wants to merge 1 commit into
ecomfe:masterfrom
dvd233:codex/fix-transform-origin-decomposition
Open

dvd233 wants to merge 1 commit into
ecomfe:masterfrom
dvd233:codex/fix-transform-origin-decomposition

Conversation

@dvd233

@dvd233 dvd233 commented Oct 9, 2026

Copy link
Copy Markdown

decomposeTransform() normalizes the matrix for an element's existing origin before calling setLocalTransform(). That call resets the origin to zero, so the next update reconstructs the matrix around the wrong point and a dragged element jumps.

Restore the saved origin after decomposition. Direct setLocalTransform() calls keep their existing origin-zero behavior.

Nonzero anchors retain their separate existing translation issue during decomposition; this change addresses the origin reset only.

Validation on Node 18.20.8:

  • 87 unit tests across 13 suites passed, including 19 new cases covering rotation, nonuniform scale, skew, reflection, zero/one-axis origins, transformed parents and repeated drift. Tests check all six matrix entries and the direct setLocalTransform() contract.
  • The first regression failed before the fix: the matrix's x-translation component was 102 instead of approximately 81.289. It passes after the fix.
  • npm run lint passed.
  • A separate actual exported Rect/Group public-API reproduction confirms the original offset and corrected matrices, with and without transformed parents. This does not exercise mouse dispatch or a complete renderer workflow.
  • npm run release remains blocked by the pre-existing TS2683 at src/canvas/Painter.ts:1254 (this.dpr inside a callback). Painter, the TypeScript configuration and dependencies are unchanged; no build diagnostics were disabled.

The Windows Jest command uses the same test glob with forward slashes to avoid Jest 27's path-normalization issue with the .agent-storage parent. The test scope and TypeScript diagnostics are unchanged.

Fixes #1172.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

decomposeTransform resets originX/originY and causes transformed elements to drift

1 participant