mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-02 04:12:47 +00:00
Keep the cursor as close to the same place on the screen as possible.
This commit is contained in:
@@ -102,10 +102,15 @@ const Editor = createClass({
|
||||
|
||||
if((prevProps.isDragging !== this.props.isDragging) && (this.props.isDragging) && (this.lastCursor == undefined)) {
|
||||
this.lastCursor = this.codeEditor.current.codeMirror.getCursor();
|
||||
const lastXY = this.codeEditor.current.codeMirror.getScrollInfo();
|
||||
const lastRowPos = this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true);
|
||||
this.lastCursor.offset = Math.round(lastRowPos-lastXY.top);
|
||||
}
|
||||
|
||||
if((prevProps.isDragging !== this.props.isDragging) && (!this.props.isDragging)) {
|
||||
this.codeEditor.current.codeMirror.scrollTo(null, this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true))
|
||||
const scroll = this.codeEditor.current.codeMirror.getScrollInfo();
|
||||
this.codeEditor.current.codeMirror.scrollTo(null,
|
||||
this.codeEditor.current.codeMirror.heightAtLine(this.lastCursor.line, 'local', true) - this.lastCursor.offset);
|
||||
this.codeEditor.current.setCursorPosition(this.lastCursor.line, this.lastCursor.ch);
|
||||
this.lastCursor = undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user