Skip to content

Commit

Permalink
fix(tooltip): remove redundant scroll offset
Browse files Browse the repository at this point in the history
window.scrollY is already account for which means document.body.scrollTop incorrectly offsets the tooltip vertically.
The same is not true for horizontal position.
  • Loading branch information
csholmq authored Oct 19, 2023
1 parent 33a5fc4 commit 1912f24
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/mermaid/src/diagrams/flowchart/flowDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ const setupToolTips = function (element) {
tooltipElem
.text(el.attr('title'))
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
.style('top', window.scrollY + rect.top - 14 + 'px');
tooltipElem.html(tooltipElem.html().replace(/&lt;br\/&gt;/g, '<br/>'));
el.classed('hover', true);
})
Expand Down

0 comments on commit 1912f24

Please sign in to comment.