aetherx-ui-inspector 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/core.js +40 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aetherx-ui-inspector",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Universal dev-only UI inspector with live editing and feedback clipboard",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/src/core.js CHANGED
@@ -76,6 +76,35 @@ export function init() {
76
76
  document.body.style.marginRight = width + 'px'
77
77
  }
78
78
 
79
+ // Hides hover overlay and resets selected badge back to its default top position
80
+ function hideHoverOverlay() {
81
+ hoverOverlay.style.display = 'none'
82
+ const selBadge = overlay.querySelector('.di-overlay-badge')
83
+ if (selBadge) {
84
+ selBadge.style.top = '-22px'
85
+ selBadge.style.borderRadius = '4px 4px 0 0'
86
+ }
87
+ }
88
+
89
+ // Repositions both badges so they never collide when elements are above/below each other
90
+ function repositionBadges(hovEl) {
91
+ if (!selectedEl || !hovEl) return
92
+ const sR = selectedEl.getBoundingClientRect()
93
+ const hR = hovEl.getBoundingClientRect()
94
+ const hovAbove = (hR.top + hR.bottom) / 2 < (sR.top + sR.bottom) / 2
95
+
96
+ const hovBadge = hoverOverlay.querySelector('.di-overlay-badge')
97
+ if (hovBadge) {
98
+ hovBadge.style.top = hovAbove ? '-22px' : 'calc(100% + 2px)'
99
+ hovBadge.style.borderRadius = hovAbove ? '4px 4px 0 0' : '0 0 4px 4px'
100
+ }
101
+ const selBadge = overlay.querySelector('.di-overlay-badge')
102
+ if (selBadge) {
103
+ selBadge.style.top = hovAbove ? 'calc(100% + 2px)' : '-22px'
104
+ selBadge.style.borderRadius = hovAbove ? '0 0 4px 4px' : '4px 4px 0 0'
105
+ }
106
+ }
107
+
79
108
  // Animates overlay position updates over `ms` to cover CSS transition duration
80
109
  function animateOverlayUpdate(ms = 260) {
81
110
  if (!selectedEl) return
@@ -103,7 +132,7 @@ export function init() {
103
132
  selectedOriginals = null
104
133
  activeTab = 'element'
105
134
  overlay.style.display = 'none'
106
- hoverOverlay.style.display = 'none'
135
+ hideHoverOverlay()
107
136
  hideSpacing(spacingContainer)
108
137
  setElementBar(null)
109
138
  stopInspect(true)
@@ -114,7 +143,7 @@ export function init() {
114
143
  inspecting = true
115
144
  cog.classList.add('active')
116
145
  document.body.classList.add('di-inspect-mode')
117
- hoverOverlay.style.display = 'none'
146
+ hideHoverOverlay()
118
147
  hideSpacing(spacingContainer)
119
148
  // Mark re-inspect button as active if panel is open
120
149
  const reinspectBtn = document.getElementById('di-reinspect-btn')
@@ -143,7 +172,7 @@ export function init() {
143
172
  function selectElement(el) {
144
173
  textEditCleanup()
145
174
  activeTab = 'element'
146
- hoverOverlay.style.display = 'none'
175
+ hideHoverOverlay()
147
176
  hideSpacing(spacingContainer)
148
177
 
149
178
  // Stop inspect mode without hiding the selected-element overlay
@@ -458,30 +487,32 @@ export function init() {
458
487
  document.addEventListener('mousemove', (e) => {
459
488
  if (inspecting || !selectedEl) {
460
489
  if (hoverOverlay.style.display !== 'none') {
461
- hoverOverlay.style.display = 'none'
490
+ hideHoverOverlay()
462
491
  hideSpacing(spacingContainer)
463
492
  }
464
- tooltip.style.display = 'none'
493
+ // Don't touch the tooltip here — inspect-mode handler owns it when inspecting
494
+ if (!inspecting) tooltip.style.display = 'none'
465
495
  return
466
496
  }
467
497
  const el = e.target
468
498
  if (isInspectorElement(el)) {
469
- hoverOverlay.style.display = 'none'
499
+ hideHoverOverlay()
470
500
  hideSpacing(spacingContainer)
471
501
  tooltip.style.display = 'none'
472
502
  return
473
503
  }
474
504
  if (el === selectedEl) {
475
505
  // Hovering the selected element itself — show its tooltip, no spacing lines
476
- hoverOverlay.style.display = 'none'
506
+ hideHoverOverlay()
477
507
  hideSpacing(spacingContainer)
478
508
  const styles = getElementStyles(el)
479
509
  renderTooltip(tooltip, styles, e.clientX, e.clientY)
480
510
  return
481
511
  }
482
- // Hovering a different element — show spacing measurements, hide tooltip
512
+ // Hovering a different element — show spacing measurements, reposition badges
483
513
  updateHoverOverlay(hoverOverlay, el)
484
514
  updateSpacing(spacingContainer, selectedEl, el)
515
+ repositionBadges(el)
485
516
  tooltip.style.display = 'none'
486
517
  })
487
518
 
@@ -529,7 +560,7 @@ export function init() {
529
560
  hideBoxModel(bm)
530
561
  }
531
562
  // Clear hover overlay, spacing, and tooltip on scroll (positions are stale)
532
- hoverOverlay.style.display = 'none'
563
+ hideHoverOverlay()
533
564
  hideSpacing(spacingContainer)
534
565
  tooltip.style.display = 'none'
535
566
  }, true)