Repository navigation
fix: adjust initial badge position and add scroll handler for connector - #162
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
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. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
initialBadgeXandinitialBadgeY) now accounts for the page scroll offset, ensuring the badge moves accurately even when the page is scrolled.Connector line rendering and scroll handling:
connectorScrollHandleris 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]