1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

scroll selected line to middle of the editor

This commit is contained in:
Nguyễn Việt Hưng
2019-01-23 00:20:50 +07:00
parent a2e050b8c5
commit 5d38937f34

View File

@@ -835,6 +835,9 @@ export default class CodeEditor extends React.Component {
ch: 1
}
this.editor.setCursor(cursor)
const top = this.editor.charCoords({line: num, ch: 0}, 'local').top
const middleHeight = this.editor.getScrollerElement().offsetHeight / 2
this.editor.scrollTo(null, top - middleHeight - 5)
}
focus () {