Skip to content

Commit a671562

Browse files
rahulchhabriaclaude
andcommitted
ref(orbital): Drive camera layout from matchMedia change event, not resize
Split the resize handler into two concerns: - resize: viewport geometry only (aspect ratio, renderer size) - mobileQuery change: camera position when the breakpoint crosses This means camera layout only adjusts when the device genuinely crosses the mobile/desktop threshold, not on every pixel of window resizing — avoiding false triggers from desktop window dragging. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 77c676e commit a671562

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

static/orbital.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,13 @@ document.addEventListener('visibilitychange', () => {
473473
// ── Resize ────────────────────────────────────────────────────────────────────
474474

475475
window.addEventListener('resize', () => {
476-
const mobile = mobileQuery.matches;
477476
camera.aspect = window.innerWidth / window.innerHeight;
478477
camera.updateProjectionMatrix();
479478
renderer.setSize(window.innerWidth, window.innerHeight);
480-
camera.position.set(0, mobile ? -0.65 : 0, mobile ? 8.0 : 5.6);
479+
});
480+
481+
mobileQuery.addEventListener('change', e => {
482+
camera.position.set(0, e.matches ? -0.65 : 0, e.matches ? 8.0 : 5.6);
481483
controls.update();
482484
});
483485

0 commit comments

Comments
 (0)