Workaround editor might have wrong doc height and wrong simple scroll bar knob position when editor height changed

This commit is contained in:
Cheng-Han, Wu 2016-04-20 16:17:24 +08:00
parent b996f801cc
commit b347ea5414
1 changed files with 8 additions and 0 deletions

View File

@ -786,10 +786,18 @@ function checkEditorStyle() {
if (scrollbarStyle == 'overlay' || currentMode == modeType.both) { if (scrollbarStyle == 'overlay' || currentMode == modeType.both) {
ui.area.codemirrorScroll.css('height', desireHeight + 'px'); ui.area.codemirrorScroll.css('height', desireHeight + 'px');
ui.area.codemirrorScroll.css('min-height', ''); ui.area.codemirrorScroll.css('min-height', '');
// workaround simple scroll bar knob
// will get wrong position when editor height changed
var scrollInfo = editor.getScrollInfo();
preventSyncScroll = true;
editor.scrollTo(null, scrollInfo.top - 1);
editor.scrollTo(null, scrollInfo.top);
} else if (scrollbarStyle == 'native') { } else if (scrollbarStyle == 'native') {
ui.area.codemirrorScroll.css('height', ''); ui.area.codemirrorScroll.css('height', '');
ui.area.codemirrorScroll.css('min-height', desireHeight + 'px'); ui.area.codemirrorScroll.css('min-height', desireHeight + 'px');
} }
// workaround editor will have wrong doc height when editor height changed
editor.setSize(null, ui.area.edit.height());
//make editor resizable //make editor resizable
ui.area.edit.resizable({ ui.area.edit.resizable({
handles: 'e', handles: 'e',