mirror of
https://github.com/status-im/codimd.git
synced 2025-02-17 11:47:19 +00:00
Fix view scroll position might lost when editor changes the last line and might get wrong knob position
This commit is contained in:
parent
197ac5d5fb
commit
f693399c76
@ -783,12 +783,7 @@ 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
|
checkEditorScrollbar();
|
||||||
// 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');
|
||||||
@ -806,6 +801,15 @@ function checkEditorStyle() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkEditorScrollbar() {
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
function checkTocStyle() {
|
function checkTocStyle() {
|
||||||
//toc right
|
//toc right
|
||||||
var paddingRight = parseFloat(ui.area.markdown.css('padding-right'));
|
var paddingRight = parseFloat(ui.area.markdown.css('padding-right'));
|
||||||
@ -2216,6 +2220,7 @@ editor.on('changes', function (cm, changes) {
|
|||||||
viewportMargin = newViewportMargin;
|
viewportMargin = newViewportMargin;
|
||||||
windowResize();
|
windowResize();
|
||||||
}
|
}
|
||||||
|
checkEditorScrollbar();
|
||||||
});
|
});
|
||||||
editor.on('focus', function (cm) {
|
editor.on('focus', function (cm) {
|
||||||
for (var i = 0; i < onlineUsers.length; i++) {
|
for (var i = 0; i < onlineUsers.length; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user