Skip to content

Fix rotationEffect and scaleEffect on SVG - #126

Draft
Vithanco wants to merge 1 commit into
elementary-swift:mainfrom
Vithanco:svg-transforms
Draft

Vithanco wants to merge 1 commit into
elementary-swift:mainfrom
Vithanco:svg-transforms

Conversation

@Vithanco

Copy link
Copy Markdown
Contributor

Stacked on #119 — until that merges the diff here includes its commits as well. The
isolated diff for this change alone (15 files) is at Vithanco#1.

rotationEffect/scaleEffect are wrong in combination with SVG: transform-origin
resolves against the viewBox rather than the element, so rotation spins around a corner
and scaling grows away from it instead of in place. Anchored variants land off-canvas
entirely. Fixed by setting transform-box: fill-box and transform-origin: 50% 50%.

TestDOM only records the CSS we emit, and rotate(45deg) is valid in both namespaces —
so Playwright tests check the rendered geometry on all major engines.

Opening early rather than waiting for #119, because this asks for more than a bugfix: a new
CI job and a second browser-automation dependency. Worth your reaction to that before it is
finished. PerformanceBenchmarks keeps puppeteer — it drives CDP tracing, which has no
cross-engine equivalent.

@sliemeobn

Copy link
Copy Markdown
Collaborator

@Vithanco thanks for addressing this, I think the "fix" is a good idea and the implementation - while definitely a bit wild (eg: could clash with manual transform-box / transform-origin parameters) - is probably good enough for most cases.

the PR is currently carrying quite a bit of unrelated history, though. Could you rebase it onto the current main and reduce it to just the relevant transform changes?

I also like the idea of Playwright-based in-browser testing, but I’d prefer to introduce that separately after a bit more thought and planning.

For this PR, I’d be happy with a small SVG example in the Examples/Basic test app that exercises the different transform modifiers and can be checked manually in a browser.

@Vithanco
Vithanco force-pushed the svg-transforms branch 2 times, most recently from ea1c19b to 754a0a2 Compare September 2, 2026 03:56
rotationEffect and scaleEffect were wrong on SVG: transform-origin resolves
against the viewBox rather than the element and defaults to 0 0, so rotation
pivoted on the canvas corner and scaling grew away from it. The anchor's
percentage translate assumes an origin already at the centre, so anchored
variants were further out still.

SVGTransformBoxModifier sets transform-box: fill-box and transform-origin:
50% 50% on elements carrying a transform. offset is left alone - absolute pixels
are origin-independent.

SVGTransformsView in Examples/Basic draws each modifier over a dashed outline of
where the shape started, so the anchor is visible rather than inferred.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Vithanco
Vithanco marked this pull request as draft September 2, 2026 06:35

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.

2 participants