summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-06-17 15:55:27 +0800
committerCheng-Han, Wu2016-06-17 15:55:27 +0800
commit30c8420e301e912bea3d30048af4595f3dac73ec (patch)
tree8f612c7d378368e8765ff543cc089688019856a9 /public
parentfb87de74a5773d39bb999867c7f91b48a2d88a0e (diff)
Revert 85e00cb2ef4ee96b8f9a8c8b58e89292c6eb56d2, it's needed for checking if cursor related element reach the viewport edge
Diffstat (limited to 'public')
-rw-r--r--public/js/index.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/public/js/index.js b/public/js/index.js
index e2707c05..d6efbef2 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -2279,6 +2279,8 @@ function checkCursorTag(coord, ele) {
// get coord position
var left = coord.left;
var top = coord.top;
+ // get doc top offset (to workaround with viewport)
+ var docTopOffset = ui.area.codemirrorSizerInner.position().top;
// set offset
var offsetLeft = -3;
var offsetTop = defaultTextHeight;
@@ -2290,7 +2292,7 @@ function checkCursorTag(coord, ele) {
}
// flip y when element bottom bound larger than doc height
// and element top position is larger than element height
- if (top + height + offsetTop + tagBottomMargin > Math.max(editor.doc.height, editorHeight) && top > height + tagBottomMargin) {
+ if (top + docTopOffset + height + offsetTop + tagBottomMargin > Math.max(editor.doc.height, editorHeight) && top + docTopOffset > height + tagBottomMargin) {
offsetTop = -(height);
}
}
@@ -2876,6 +2878,8 @@ function checkCursorMenuInner() {
}, 'windows');
var left = coord.left;
var top = coord.top;
+ // get doc top offset (to workaround with viewport)
+ var docTopOffset = ui.area.codemirrorSizerInner.position().top;
// set offset
var offsetLeft = 0;
var offsetTop = defaultTextHeight;
@@ -2886,7 +2890,7 @@ function checkCursorMenuInner() {
offsetLeft = -(left + width - docWidth + menuRightMargin);
// flip y when element bottom bound larger than doc height
// and element top position is larger than element height
- if (top + height + offsetTop + menuBottomMargin > Math.max(editor.doc.height, editorHeight) && top > height + menuBottomMargin) {
+ if (top + docTopOffset + height + offsetTop + menuBottomMargin > Math.max(editor.doc.height, editorHeight) && top + docTopOffset > height + menuBottomMargin) {
offsetTop = -(height + menuBottomMargin);
// reverse sort menu because upSideDown
dropdown.html(reverseSortCursorMenu(dropdown));