From 59458731d8ceada84832e8ed607f45e5e1bd4613 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Thu, 2 Mar 2017 15:04:57 +0000 Subject: [PATCH] Add cell position when calculating location of cursor for tooltip Closes gh-2245, I hope, but I don't know if there's a better way to fix it. I think we need to calculate the location relative to the 'offset parent' of the tooltip. Adding one extra parent level from CodeMirror seems to work at the moment. --- notebook/static/notebook/js/tooltip.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notebook/static/notebook/js/tooltip.js b/notebook/static/notebook/js/tooltip.js index d131200d8..ba93a1d9c 100644 --- a/notebook/static/notebook/js/tooltip.js +++ b/notebook/static/notebook/js/tooltip.js @@ -274,6 +274,7 @@ define([ // do some math to have the tooltip arrow on more or less on left or right // position of the editor var cm_pos = $(this.code_mirror.getWrapperElement()).position(); + var cell_pos = $(this.code_mirror.getWrapperElement().offsetParent).position(); // anchor and head positions are local within CodeMirror element var anchor = this.code_mirror.cursorCoords(false, 'local'); @@ -286,8 +287,8 @@ define([ var arrow_left = center_left - edge_left - 24; // locate left, top within container element - var left = (cm_pos.left + edge_left) + 'px'; - var top = (cm_pos.top + head.bottom + 10) + 'px'; + var left = (cell_pos.left + cm_pos.left + edge_left) + 'px'; + var top = (cell_pos.top + cm_pos.top + head.bottom + 10) + 'px'; if (this._hidden === false) { this.tooltip.animate({