Skip to content

fix: adjust initial badge position and add scroll handler for connector - #162

Merged
dermatz merged 1 commit into
mainfrom
fix/inspector-scroll-handler
Apr 11, 2026
Merged

dermatz merged 1 commit into
mainfrom
fix/inspector-scroll-handler

Conversation

@dermatz

@dermatz dermatz commented Apr 11, 2026 •

Copy link
Copy Markdown
Member

This pull request improves the drag-and-drop functionality of the Mageforge Inspector overlay, especially in scenarios where the page is scrolled. The most important changes are grouped below by theme.

Drag-and-drop accuracy and behavior:

  • The initial position of the draggable badge (initialBadgeX and initialBadgeY) now accounts for the page scroll offset, ensuring the badge moves accurately even when the page is scrolled.

Connector line rendering and scroll handling:

  • A new connectorScrollHandler is introduced to update the connector line position when the window is scrolled, keeping the connector accurately attached to the badge. The handler is added when the connector is created and removed when the connector is destroyed to prevent memory leaks. [1] [2]

Copilot AI review requested due to automatic review settings April 11, 2026 14:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the MageForge Inspector badge drag-and-drop behavior and keeps the badge-to-element connector line accurate during page scrolling.

Changes:

  • Fixes drag start positioning by storing the badge’s initial coordinates in document space (accounting for window.scrollX/Y).
  • Adds a scroll event handler to recompute connector line coordinates while scrolling, and cleans it up when the connector is removed.
  • Extends the Alpine component state to track the new handler references.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/view/frontend/web/js/inspector/draggable.js Adjusts initial drag position for scroll offset; adds/removes a window scroll handler to keep the fixed SVG connector aligned.
src/view/frontend/web/js/inspector.js Adds state fields for dragStartHandler and connectorScrollHandler to support lifecycle-safe event listener management.

@dermatz
dermatz merged commit 84baaf0 into main Apr 11, 2026
17 checks passed
@dermatz
dermatz deleted the fix/inspector-scroll-handler branch April 11, 2026 14:29
@github-actions github-actions Bot mentioned this pull request Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants