Skip to content

feat: move hotspots between screens via drag#8

Merged
trmquang93 merged 1 commit intomainfrom
feat/move-hotspot-between-screens
Mar 17, 2026
Merged

feat: move hotspots between screens via drag#8
trmquang93 merged 1 commit intomainfrom
feat/move-hotspot-between-screens

Conversation

@trmquang93
Copy link
Copy Markdown
Collaborator

Summary

  • Add cross-screen hotspot repositioning: drag a hotspot beyond its source screen and drop it onto a different screen to transfer it
  • Ghost preview (dashed rectangle) follows cursor during drag showing the exact drop location, while the original hotspot stays in place until release
  • All connections originating from the hotspot automatically update their fromScreenId to the new screen
  • Single undo step via existing captureDragSnapshot/commitDragSnapshot pattern

Changes

  • canvasMath.js: Add worldToScreenPct() to convert world coordinates to percentage position within a screen's image area
  • useScreenManager.js: Add moveHotspotToScreen() that atomically transfers a hotspot and updates connections
  • useCanvasMouseHandlers.js: Reposition drag now tracks world cursor without moving the hotspot live; mouseup computes final position via worldToScreenPct for both within-screen and cross-screen cases
  • Drawd.jsx: Wire moveHotspotToScreen, render ghost preview rectangle during reposition drag
  • canvasMath.test.js: 4 new tests for worldToScreenPct

Test plan

  • Upload 2+ screens with images
  • Draw a hotspot on screen A, connect it to screen B
  • Select the hotspot, click again to start reposition
  • Verify ghost preview follows cursor during drag
  • Drag cursor onto screen C and release — hotspot appears on screen C at ghost position
  • Verify connection line now originates from screen C
  • Cmd+Z — hotspot returns to screen A, connection restored
  • Drag within same screen — reposition still works, hotspot lands at ghost position
  • Drag to empty canvas — hotspot stays at original position (no change)
  • Mouse leaves canvas during drag — interaction cancels cleanly
  • npm test passes (233 tests)
  • npm run lint clean

Allow users to reposition a hotspot from one screen to another by
dragging it beyond the source screen and releasing on a target screen.
The hotspot stays at its original position during drag while a ghost
preview follows the cursor showing the drop location. On release,
the hotspot transfers to the target screen and all associated
connections update their fromScreenId atomically. Single undo step
via existing captureDragSnapshot/commitDragSnapshot pattern.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flow-forge Ready Ready Preview, Comment Mar 17, 2026 7:30am

@trmquang93 trmquang93 merged commit 0df4a3f into main Mar 17, 2026
3 checks passed
@github-actions github-actions Bot deleted the feat/move-hotspot-between-screens branch March 17, 2026 07:40
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.

1 participant