From 8ebd61f8c1388f42071427ac3c334a37e7ee88d6 Mon Sep 17 00:00:00 2001 From: Martyanov Andrey <37772440+martyanovandrey@users.noreply.github.com> Date: Tue, 20 Sep 2022 15:07:59 +0300 Subject: [PATCH] fix(term): custom header top coordinate (#182) --- src/js/term/utils.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/term/utils.ts b/src/js/term/utils.ts index bf96b357..df405422 100644 --- a/src/js/term/utils.ts +++ b/src/js/term/utils.ts @@ -34,6 +34,7 @@ export function setDefinitionPosition( right: termRight, left: termLeft, width: termWidth, + height: termHeight, } = termElement.getBoundingClientRect(); const termParent = termParentElement(termElement); @@ -64,7 +65,7 @@ export function setDefinitionPosition( definitionElement.setAttribute('relativeX', String(termX)); definitionElement.setAttribute('relativeY', String(termY)); - const offsetTop = 25; + const offsetTop = termHeight + 5; const definitionParent = definitionElement.parentElement; if (!definitionParent) { @@ -79,7 +80,10 @@ export function setDefinitionPosition( const fitDefinitionDocument = document.body.clientWidth > definitionRightCoordinate ? 0 : definitionWidth - termWidth; - definitionElement.style.top = Number(getCoords(termElement).top + offsetTop) + 'px'; + const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop; + + definitionElement.style.top = + Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px'; definitionElement.style.left = Number( getCoords(termElement).left -