mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-08 18:16:44 +02:00
when window scroll, the tooltip show incorrect position coz its missing offset of window.scrollXY
This commit is contained in:
@@ -272,8 +272,8 @@ const setupToolTips = function(element) {
|
|||||||
.style('opacity', '.9');
|
.style('opacity', '.9');
|
||||||
tooltipElem
|
tooltipElem
|
||||||
.html(el.attr('title'))
|
.html(el.attr('title'))
|
||||||
.style('left', rect.left + (rect.right - rect.left) / 2 + 'px')
|
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
|
||||||
.style('top', rect.top - 14 + document.body.scrollTop + 'px');
|
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
|
||||||
el.classed('hover', true);
|
el.classed('hover', true);
|
||||||
})
|
})
|
||||||
.on('mouseout', function() {
|
.on('mouseout', function() {
|
||||||
|
@@ -324,6 +324,7 @@ const setupToolTips = function(element) {
|
|||||||
.on('mouseover', function() {
|
.on('mouseover', function() {
|
||||||
const el = select(this);
|
const el = select(this);
|
||||||
const title = el.attr('title');
|
const title = el.attr('title');
|
||||||
|
|
||||||
// Dont try to draw a tooltip if no data is provided
|
// Dont try to draw a tooltip if no data is provided
|
||||||
if (title === null) {
|
if (title === null) {
|
||||||
return;
|
return;
|
||||||
@@ -336,8 +337,8 @@ const setupToolTips = function(element) {
|
|||||||
.style('opacity', '.9');
|
.style('opacity', '.9');
|
||||||
tooltipElem
|
tooltipElem
|
||||||
.html(el.attr('title'))
|
.html(el.attr('title'))
|
||||||
.style('left', rect.left + (rect.right - rect.left) / 2 + 'px')
|
.style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')
|
||||||
.style('top', rect.top - 14 + document.body.scrollTop + 'px');
|
.style('top', window.scrollY + rect.top - 14 + document.body.scrollTop + 'px');
|
||||||
el.classed('hover', true);
|
el.classed('hover', true);
|
||||||
})
|
})
|
||||||
.on('mouseout', function() {
|
.on('mouseout', function() {
|
||||||
|
Reference in New Issue
Block a user