Skip to content

Commit 370f7c4

Browse files
committed
[lint addon] Make sure tooltips don't stick out of the window width
Issue #7044
1 parent 82ce3d2 commit 370f7c4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

addon/lint/lint.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424

2525
function position(e) {
2626
if (!tt.parentNode) return CodeMirror.off(document, "mousemove", position);
27-
tt.style.top = Math.max(0, e.clientY - tt.offsetHeight - 5) + "px";
28-
tt.style.left = (e.clientX + 5) + "px";
27+
var top = Math.max(0, e.clientY - tt.offsetHeight - 5);
28+
var left = Math.max(0, Math.min(e.clientX + 5, tt.ownerDocument.defaultView.innerWidth - tt.offsetWidth));
29+
tt.style.top = top + "px"
30+
tt.style.left = left + "px";
2931
}
3032
CodeMirror.on(document, "mousemove", position);
3133
position(e);

0 commit comments

Comments
 (0)