summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
authorWu Cheng-Han2015-09-25 18:34:03 +0800
committerWu Cheng-Han2015-09-25 18:34:03 +0800
commit3ab04d4f025ebbd1a10f47e0c05647f3dc8a228d (patch)
tree61593f171bbe0fc87373ce0e7dd7de548bfba6bf /public/js
parente0ff2876525099c2a39c494985641b7ea35b5c8a (diff)
Fixed saveInfo and restoreInfo might not get correct window size
Diffstat (limited to 'public/js')
-rw-r--r--public/js/index.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 6b269d10..c151b533 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1685,8 +1685,8 @@ editor.on('blur', function (cm) {
function saveInfo() {
var scrollbarStyle = editor.getOption('scrollbarStyle');
- var left = $(document.body).scrollLeft();
- var top = $(document.body).scrollTop();
+ var left = $(window).scrollLeft();
+ var top = $(window).scrollTop();
switch (currentMode) {
case modeType.edit:
if (scrollbarStyle == 'native') {
@@ -1716,12 +1716,11 @@ function restoreInfo() {
var line = lastInfo.edit.cursor.line;
var ch = lastInfo.edit.cursor.ch;
editor.setCursor(line, ch);
-
switch (currentMode) {
case modeType.edit:
if (scrollbarStyle == 'native') {
- $(document.body).scrollLeft(lastInfo.edit.scroll.left);
- $(document.body).scrollTop(lastInfo.edit.scroll.top);
+ $(window).scrollLeft(lastInfo.edit.scroll.left);
+ $(window).scrollTop(lastInfo.edit.scroll.top);
} else {
var left = lastInfo.edit.scroll.left;
var top = lastInfo.edit.scroll.top;
@@ -1730,8 +1729,8 @@ function restoreInfo() {
}
break;
case modeType.view:
- $(document.body).scrollLeft(lastInfo.view.scroll.left);
- $(document.body).scrollTop(lastInfo.view.scroll.top);
+ $(window).scrollLeft(lastInfo.view.scroll.left);
+ $(window).scrollTop(lastInfo.view.scroll.top);
break;
case modeType.both:
var left = lastInfo.edit.scroll.left;