positionIcon function
Last updated: 2026-03-01T23:25:47.108Z
Location
Metrics
LOC: 30
Complexity: 6
Params: 1
Signature
positionIcon(target: HTMLElement): : void
Source Code
function positionIcon(target: HTMLElement): void {
if (!iconElement) return;
const rect = target.getBoundingClientRect();
const iconHeight = 24;
const totalWidth = 72;
const gap = 4;
let top: number;
let left: number;
if (_iconPosition === "above") {
top = rect.top - iconHeight - gap + window.scrollY;
left = rect.right - totalWidth - gap + window.scrollX;
} else if (_iconPosition === "below") {
top = rect.bottom + gap + window.scrollY;
left = rect.right - totalWidth - gap + window.scrollX;
} else {
top = rect.top + (rect.height - iconHeight) / 2 + window.scrollY;
left = rect.right - totalWidth - gap + window.scrollX;
}
const maxLeft = window.innerWidth + window.scrollX - totalWidth - 4;
const maxTop = window.innerHeight + window.scrollY - iconHeight - 4;
left = Math.max(window.scrollX + 4, Math.min(left, maxLeft));
top = Math.max(window.scrollY + 4, Math.min(top, maxTop));
iconElement.style.top = `${top}px`;
iconElement.style.left = `${left}px`;
}
No outgoing dependencies.
Impact (Incoming)
| Source | Type |
|---|---|
| showIcon | calls |
| repositionIcon | calls |