mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Force preview to scroll to the end
fixes #958, fixes #535 - If the cursor is within the last 5 lines, then scroll to the end of the preview window, rather than using a ratio
This commit is contained in:
parent
545fc6e911
commit
72b4e3bf4d
2 changed files with 7 additions and 0 deletions
|
@ -81,6 +81,9 @@
|
|||
$(document).trigger('markdownEditorChange');
|
||||
});
|
||||
},
|
||||
isCursorAtEnd: function () {
|
||||
return codemirror.getCursor('end').line > codemirror.lineCount() - 5;
|
||||
},
|
||||
value: function () {
|
||||
return codemirror.getValue();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
ratio = previewHeight / markdownHeight,
|
||||
previewPosition = $markdownViewPort.scrollTop() * ratio;
|
||||
|
||||
if (markdown.isCursorAtEnd()) {
|
||||
previewPosition = previewHeight + 30;
|
||||
}
|
||||
|
||||
// apply new scroll
|
||||
$previewViewPort.scrollTop(previewPosition);
|
||||
}, 10);
|
||||
|
|
Loading…
Add table
Reference in a new issue