From d90acf88e3f73dd00e85ee9435ddc4263acfcfbb Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Fri, 27 May 2016 02:04:38 +0800 Subject: Update and fix editor might not sync scrolling from edit mode to both mode --- public/js/index.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'public/js/index.js') diff --git a/public/js/index.js b/public/js/index.js index 832e0d15..8671af46 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -721,15 +721,17 @@ function windowResizeInner(callback) { //refresh editor if (loaded) { if (editor.getOption('scrollbarStyle') === 'native') { - clearMap(); - if (editorHasFocus()) { - syncScrollToView(); - } else { - syncScrollToEdit(); - } - updateScrollspy(); - if (callback && typeof callback === 'function') - callback(); + setTimeout(function () { + clearMap(); + if (editorHasFocus()) { + syncScrollToView(); + } else { + syncScrollToEdit(); + } + updateScrollspy(); + if (callback && typeof callback === 'function') + callback(); + }, 1); } else { // force it load all docs at once to prevent scroll knob blink editor.setOption('viewportMargin', Infinity); @@ -1030,6 +1032,11 @@ function changeMode(type) { preventSyncScrollToEdit = 2; syncScrollToView(); } + + if (lastMode == modeType.both && currentMode != modeType.both) { + preventSyncScrollToView = false; + preventSyncScrollToEdit = false; + } if (lastMode != modeType.edit && currentMode == modeType.edit) { editor.refresh(); -- cgit v1.2.3