Skip to content

Commit 3d9fcf2

Browse files
committed
fix hover tooltip position with non-original div position
1 parent 132c8ea commit 3d9fcf2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/traces/sankey/plot.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,14 @@ module.exports = function plot(gd, calcData) {
125125

126126
var linkHoverFollow = function(element, d) {
127127

128+
var rootBBox = gd.getBoundingClientRect();
128129
var boundingBox = element.getBoundingClientRect();
129130
var hoverCenterX = boundingBox.left + boundingBox.width / 2;
130131
var hoverCenterY = boundingBox.top + boundingBox.height / 2;
131132

132133
var tooltip = Fx.loneHover({
133-
x: hoverCenterX + window.scrollX,
134-
y: hoverCenterY + window.scrollY,
134+
x: hoverCenterX - rootBBox.left + window.scrollX,
135+
y: hoverCenterY - rootBBox.top + window.scrollY,
135136
name: d3.format(d.valueFormat)(d.link.value) + d.valueSuffix,
136137
text: [
137138
d.link.label,
@@ -173,10 +174,11 @@ module.exports = function plot(gd, calcData) {
173174
var nodeHoverFollow = function(element, d) {
174175

175176
var nodeRect = d3.select(element).select('.nodeRect');
177+
var rootBBox = gd.getBoundingClientRect();
176178
var boundingBox = nodeRect.node().getBoundingClientRect();
177-
var hoverCenterX0 = boundingBox.left - 2;
178-
var hoverCenterX1 = boundingBox.right + 2;
179-
var hoverCenterY = boundingBox.top + boundingBox.height / 4;
179+
var hoverCenterX0 = boundingBox.left - 2 - rootBBox.left;
180+
var hoverCenterX1 = boundingBox.right + 2 - rootBBox.left;
181+
var hoverCenterY = boundingBox.top + boundingBox.height / 4 - rootBBox.top;
180182

181183
var tooltip = Fx.loneHover({
182184
x0: hoverCenterX0 + window.scrollX,

0 commit comments

Comments
 (0)