Update and fix editor might not sync scrolling from edit mode to both mode

This commit is contained in:
Cheng-Han, Wu 2016-05-27 02:04:38 +08:00
parent e9b0ce8e04
commit d90acf88e3
2 changed files with 17 additions and 14 deletions

View File

@ -721,6 +721,7 @@ function windowResizeInner(callback) {
//refresh editor
if (loaded) {
if (editor.getOption('scrollbarStyle') === 'native') {
setTimeout(function () {
clearMap();
if (editorHasFocus()) {
syncScrollToView();
@ -730,6 +731,7 @@ function windowResizeInner(callback) {
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);
@ -1031,6 +1033,11 @@ function changeMode(type) {
syncScrollToView();
}
if (lastMode == modeType.both && currentMode != modeType.both) {
preventSyncScrollToView = false;
preventSyncScrollToEdit = false;
}
if (lastMode != modeType.edit && currentMode == modeType.edit) {
editor.refresh();
}

View File

@ -120,11 +120,7 @@ var viewScrollingDebounce = 200;
var editScrolling = false;
var editScrollingDebounce = 200;
if (editor.getOption('scrollbarStyle') === 'native') {
ui.area.codemirrorScroll.on('scroll', _.throttle(syncScrollToView, editScrollThrottle));
} else {
editor.on('scroll', _.throttle(syncScrollToView, editScrollThrottle));
}
ui.area.codemirrorScroll.on('scroll', _.throttle(syncScrollToView, editScrollThrottle));
ui.area.view.on('scroll', _.throttle(syncScrollToEdit, viewScrollThrottle));
var scrollMap, lineHeightMap, viewTop, viewBottom;