Skip to content

Enable dragging popup panels via touch on mobile#30

Merged
dnkats merged 1 commit into
mainfrom
fix/mobile-draggable-panels
Jun 2, 2026
Merged

Enable dragging popup panels via touch on mobile#30
dnkats merged 1 commit into
mainfrom
fix/mobile-draggable-panels

Conversation

@dnkats

@dnkats dnkats commented Jun 2, 2026

Copy link
Copy Markdown
Member

Summary

The draggable popup panels (ElemCo input, orbital controls, XYZ editor, preferences, xtb) could be moved by dragging their headers on desktop and in the Electron app, but not on touch devices.

Cause

makeDraggable in js/ui.js only registered mousedown/mousemove/mouseup, which don't fire for touch interactions.

Fix

Added matching touchstart/touchmove/touchend/touchcancel handlers that share the existing drag logic, plus a small getPoint() helper that reads coordinates from e.touches[0] (touch) or e.clientX/Y (mouse). touchmove uses { passive: false } and preventDefault() so the page doesn't scroll while a panel is being dragged.

Applies to all five panels since they share the same helper. No CSS changes.

Testing

On a phone (or browser device emulation), open the ElemCo panel and drag it by its header — it now moves just like on desktop.

🤖 Generated with Claude Code

The draggable panels only listened for mouse events, so they could
not be moved on touch devices. Add matching touchstart/touchmove/
touchend handlers and read coordinates from either event type.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 2, 2026 06:59
@dnkats dnkats merged commit 446dac5 into main Jun 2, 2026
1 check passed
@dnkats dnkats deleted the fix/mobile-draggable-panels branch June 2, 2026 06:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds touch input support to the existing draggable popup panel system so panels can be repositioned on mobile/touch devices, aligning behavior between desktop/Electron and the browser/mobile experience.

Changes:

  • Registers touchstart/touchmove/touchend/touchcancel handlers alongside existing mouse drag handlers.
  • Introduces a getPoint() helper to share coordinate extraction logic between mouse and touch events.
  • Prevents page scrolling during an active touch drag via preventDefault() and non-passive touchmove.

Comment thread js/ui.js
Comment on lines 35 to 41
if (e.target === header) {
isDragging = true;
// Prevent the page from scrolling while dragging on touch.
if (e.type === 'touchstart') {
e.preventDefault();
}
}
Comment thread js/ui.js
Comment on lines +16 to +20
// Touch support so panels can be dragged on mobile devices too.
header.addEventListener('touchstart', dragStart, { passive: false });
document.addEventListener('touchmove', drag, { passive: false });
document.addEventListener('touchend', dragEnd);
document.addEventListener('touchcancel', dragEnd);
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