diff --git a/src/index.ts b/src/index.ts index cef69ed..d61321e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,6 +81,17 @@ export class HoverPosition { const originalDisplay = options.target.style.display; options.target.style.display = 'block'; + if (options.anchor instanceof HTMLElement) { + let parent = options.anchor.parentElement; + + while (parent !== null && parent.tagName !== "BODY") { + this._anchorDims.top -= parent.scrollTop; + this._anchorDims.left -= parent.scrollLeft; + + parent = parent.parentElement; + } + } + this._hoverBoxDims = { height: options.target.offsetHeight, width: options.target.offsetWidth,