diff --git a/client/homebrew/editor/editor.jsx b/client/homebrew/editor/editor.jsx index 3b87c7bcc..09af827fc 100644 --- a/client/homebrew/editor/editor.jsx +++ b/client/homebrew/editor/editor.jsx @@ -158,7 +158,7 @@ const Editor = createClass({ if(!this.props.liveScroll) return; console.log("handleSourceScroll") scrollingJump = true; - this.brewJump(); + this.brewJump(this.getCurrentPage(false)); scrollingJump = false; }, @@ -184,8 +184,13 @@ const Editor = createClass({ }); //TODO: not sure if updateeditorsize needed }, - getCurrentPage : function(){ - const lines = this.props.brew.text.split('\n').slice(0, this.codeEditor.current.getCursorPosition().line + 1); + getCurrentPage : function(atCursor = true){ + let lines = this.props.brew.text.split('\n'); + if (atCursor) + lines = lines.slice(0, this.codeEditor.current.getCursorPosition().line + 1); // get cursor page + else + lines = lines.slice(0, this.codeEditor.current.getViewport().from + 1); // get view page + return _.reduce(lines, (r, line)=>{ if( (this.props.renderer == 'legacy' && line.indexOf('\\page') !== -1) @@ -357,7 +362,7 @@ const Editor = createClass({ }, brewJump : function(targetPage=this.getCurrentPage()){ - console.log('jumpbrew') + console.log(`jumpBrew to page ${targetPage}`) if(lockBrewJump) return; if(!window) return; lockSourceJump = true; diff --git a/shared/naturalcrit/codeEditor/codeEditor.jsx b/shared/naturalcrit/codeEditor/codeEditor.jsx index 1387edfee..64dab05d0 100644 --- a/shared/naturalcrit/codeEditor/codeEditor.jsx +++ b/shared/naturalcrit/codeEditor/codeEditor.jsx @@ -399,6 +399,9 @@ const CodeEditor = createClass({ getCursorPosition : function(){ return this.codeMirror.getCursor(); }, + getViewport : function(){ + return this.codeMirror.getViewport(); + }, updateSize : function(){ this.codeMirror.refresh(); },