Skip to content

Commit

Permalink
Fix #6 (thanks walulula)
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonped committed May 10, 2021
1 parent eb375ca commit 0ec8fcf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions typewriter-scrolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CodeMirror.defineOption("typewriterScrolling", false, function (cm, val, old) {
if (old && old != CodeMirror.Init) {
const linesEl = cm.getScrollerElement().querySelector('.CodeMirror-lines');
linesEl.style.paddingTop = null;
linesEl.style.paddingBottom = null;
cm.off("changes", onChanges);
cm.off("cursorActivity", onCursorActivity);
cm.off("keyHandled", onKeyHandled);
Expand Down Expand Up @@ -54,6 +55,7 @@ function onRefresh(cm) {
const halfWindowHeight = cm.getWrapperElement().offsetHeight / 2;
const linesEl = cm.getScrollerElement().querySelector('.CodeMirror-lines');
linesEl.style.paddingTop = `${halfWindowHeight}px`;
linesEl.style.paddingBottom = `${halfWindowHeight}px`; // Thanks @walulula!
if (cm.getSelection().length === 0) {
cm.execCommand("scrollSelectionToCenter");
}
Expand Down

0 comments on commit 0ec8fcf

Please sign in to comment.