Closed atfornes closed 7 years ago
I implemented this in the app, not in the editor component due to calculation of whether the cursor is outside of visible area requires info of the actual layout: this is code from jetpad and swellrt beta, let notice constant this.TOP_BAR_OFFSET
note: focusNode is got here from the handler's selection
parameter, but it can be retrieved from window.getSelection()
[1]
this.editor.setSelectionHandler((range, editor, selection) => {
if (selection && selection.focusNode) {
let focusParent = selection.focusNode.parentElement;
if (focusParent.getBoundingClientRect) {
let rect = focusParent.getBoundingClientRect();
if (rect.top > (window.innerHeight - this.TOP_BAR_OFFSET)) {
focusParent.scrollIntoView();
}
}
}
};
After adding a new line at the end of the screen in a SwellRT pad, the pad is not scrolled to follow the cursor. This is an unexpected behavior.
It works after adding some characters (but not when you add a line break)
see https://github.com/P2Pvalue/teem/issues/326