Skip to content

Commit 30c8420

Browse files
committed
Revert 85e00cb, it's needed for checking if cursor related element reach the viewport edge
1 parent fb87de7 commit 30c8420

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

public/js/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,6 +2279,8 @@ function checkCursorTag(coord, ele) {
22792279
// get coord position
22802280
var left = coord.left;
22812281
var top = coord.top;
2282+
// get doc top offset (to workaround with viewport)
2283+
var docTopOffset = ui.area.codemirrorSizerInner.position().top;
22822284
// set offset
22832285
var offsetLeft = -3;
22842286
var offsetTop = defaultTextHeight;
@@ -2290,7 +2292,7 @@ function checkCursorTag(coord, ele) {
22902292
}
22912293
// flip y when element bottom bound larger than doc height
22922294
// and element top position is larger than element height
2293-
if (top + height + offsetTop + tagBottomMargin > Math.max(editor.doc.height, editorHeight) && top > height + tagBottomMargin) {
2295+
if (top + docTopOffset + height + offsetTop + tagBottomMargin > Math.max(editor.doc.height, editorHeight) && top + docTopOffset > height + tagBottomMargin) {
22942296
offsetTop = -(height);
22952297
}
22962298
}
@@ -2876,6 +2878,8 @@ function checkCursorMenuInner() {
28762878
}, 'windows');
28772879
var left = coord.left;
28782880
var top = coord.top;
2881+
// get doc top offset (to workaround with viewport)
2882+
var docTopOffset = ui.area.codemirrorSizerInner.position().top;
28792883
// set offset
28802884
var offsetLeft = 0;
28812885
var offsetTop = defaultTextHeight;
@@ -2886,7 +2890,7 @@ function checkCursorMenuInner() {
28862890
offsetLeft = -(left + width - docWidth + menuRightMargin);
28872891
// flip y when element bottom bound larger than doc height
28882892
// and element top position is larger than element height
2889-
if (top + height + offsetTop + menuBottomMargin > Math.max(editor.doc.height, editorHeight) && top > height + menuBottomMargin) {
2893+
if (top + docTopOffset + height + offsetTop + menuBottomMargin > Math.max(editor.doc.height, editorHeight) && top + docTopOffset > height + menuBottomMargin) {
28902894
offsetTop = -(height + menuBottomMargin);
28912895
// reverse sort menu because upSideDown
28922896
dropdown.html(reverseSortCursorMenu(dropdown));

0 commit comments

Comments
 (0)