Skip to content

Commit

Permalink
fix(term): custom header top coordinate (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
martyanovandrey authored Sep 20, 2022
1 parent 07445d0 commit 8ebd61f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/js/term/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function setDefinitionPosition(
right: termRight,
left: termLeft,
width: termWidth,
height: termHeight,
} = termElement.getBoundingClientRect();

const termParent = termParentElement(termElement);
Expand Down Expand Up @@ -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) {
Expand All @@ -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 -
Expand Down

0 comments on commit 8ebd61f

Please sign in to comment.