+ const targetBounds = element.getBoundingClientRect();
+ const pointerBounds = this.container.getBoundingClientRect();
+
+ const xTarget = Math.min(Math.max(xPosition, targetBounds.left), targetBounds.right);
+ const xOffset = xTarget - (pointerBounds.width / 2);
+ const yOffset = (targetBounds.top - pointerBounds.height) - 16;
+
+ this.container.style.left = `${xOffset}px`;
+ this.container.style.top = `${yOffset}px`;
+