Skip to content

Commit c995694

Browse files
committed
refactor: simplify connector management in draggable methods
1 parent 8957129 commit c995694

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/view/frontend/web/js/inspector/draggable.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export const draggableMethods = {
123123

124124
document.body.appendChild(svg);
125125
this.connectorSvg = svg;
126+
this.connectorLine = line;
127+
this.connectorDot = dot;
126128

127129
// Update line on scroll (SVG is fixed, coordinates are viewport-relative)
128130
this.connectorScrollHandler = () => this.updateConnector();
@@ -142,6 +144,8 @@ export const draggableMethods = {
142144
if (this.connectorSvg) {
143145
this.connectorSvg.remove();
144146
this.connectorSvg = null;
147+
this.connectorLine = null;
148+
this.connectorDot = null;
145149
}
146150
// Restore static arrow if it exists (for next time)
147151
if (this.infoBadge) {
@@ -173,15 +177,13 @@ export const draggableMethods = {
173177
const targetY = targetRect.top + targetRect.height / 2;
174178

175179
// Update line
176-
const line = this.connectorSvg.querySelector('line');
177-
line.setAttribute('x1', badgeX);
178-
line.setAttribute('y1', badgeY);
179-
line.setAttribute('x2', targetX);
180-
line.setAttribute('y2', targetY);
180+
this.connectorLine.setAttribute('x1', badgeX);
181+
this.connectorLine.setAttribute('y1', badgeY);
182+
this.connectorLine.setAttribute('x2', targetX);
183+
this.connectorLine.setAttribute('y2', targetY);
181184

182185
// Update dot
183-
const dot = this.connectorSvg.querySelector('circle');
184-
dot.setAttribute('cx', targetX);
185-
dot.setAttribute('cy', targetY);
186+
this.connectorDot.setAttribute('cx', targetX);
187+
this.connectorDot.setAttribute('cy', targetY);
186188
},
187189
};

0 commit comments

Comments
 (0)