summaryrefslogtreecommitdiff
path: root/public/js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js')
-rw-r--r--public/js/index.js7
-rw-r--r--public/js/syncscroll.js6
2 files changed, 12 insertions, 1 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 244b6aa5..bfb793c2 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -1596,6 +1596,12 @@ editor.on('beforeChange', function (cm, change) {
break;
}
}
+editor.on('changes', function (cm, changes) {
+ updateHistory();
+ preventSyncScroll = true;
+ var scrollInfo = editor.getScrollInfo();
+ editor.scrollTo(null, scrollInfo.top - 1);
+ editor.scrollTo(null, scrollInfo.top);
});
editor.on('focus', function (cm) {
for (var i = 0; i < onlineUsers.length; i++) {
@@ -1731,7 +1737,6 @@ function updateViewInner() {
generateToc('toc-affix');
generateScrollspy();
smoothHashScroll();
- writeHistory(ui.area.markdown);
isDirty = false;
clearMap();
buildMap();
diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js
index a9eafe48..143e668e 100644
--- a/public/js/syncscroll.js
+++ b/public/js/syncscroll.js
@@ -139,6 +139,8 @@ md.renderer.rules.code = function (tokens, idx /*, options, env */ ) {
return '<code>' + Remarkable.utils.escapeHtml(tokens[idx].content) + '</code>';
};
+var preventSyncScroll = false;
+
//var editorScrollThrottle = 100;
var buildMapThrottle = 100;
@@ -299,6 +301,10 @@ function getEditorLineNoByTop(top) {
function syncScrollToView(event, _lineNo) {
if (currentMode != modeType.both) return;
+ if (preventSyncScroll) {
+ preventSyncScroll = false;
+ return;
+ }
var lineNo, posTo;
var scrollInfo = editor.getScrollInfo();
if (!scrollMap || !lineHeightMap) {