Skip to content

Commit 1bb6bb8

Browse files
numachangclaude
andauthored
fix: honor an explicit zero rotation origin for keys (#175)
Keys with a rotation (r != 0) whose origin rx/ry is explicitly 0 were pivoted around each key's own corner instead of the layout origin (0,0), scrambling rotated clusters on boards that rotate about the origin. `(rx || x)` collapsed a legitimate 0 back to the key's own x; switching to `(rx ?? x)` keeps an explicit 0 as 0. Fixes #97 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 67c9c3d commit 1bb6bb8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/keyboard/PhysicalLayout.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ function scalePosition(
5656
const transformStyle = "preserve-3d";
5757

5858
if (r) {
59-
let transformX = ((rx || x) - x) * oneU;
60-
let transformY = ((ry || y) - y) * oneU;
59+
// Use `??` so an explicit rotation origin of 0 is honored; `rx || x`
60+
// collapsed a legitimate 0 back to the key's own position, pivoting the
61+
// key around its own corner instead of the layout origin (#97).
62+
let transformX = ((rx ?? x) - x) * oneU;
63+
let transformY = ((ry ?? y) - y) * oneU;
6164
transformOrigin = `${transformX}px ${transformY}px`;
6265
transform = `rotate(${r}deg)`;
6366
}

0 commit comments

Comments
 (0)