From 3ab04d4f025ebbd1a10f47e0c05647f3dc8a228d Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Fri, 25 Sep 2015 18:34:03 +0800 Subject: Fixed saveInfo and restoreInfo might not get correct window size --- public/js/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'public/js') 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; -- cgit v1.2.3