mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 10:12:41 +00:00
Remove a loop from sourceJump
This commit is contained in:
@@ -180,6 +180,7 @@ const Editor = createClass({
|
|||||||
|
|
||||||
brewJump : function(targetPage=this.getCurrentPage()){
|
brewJump : function(targetPage=this.getCurrentPage()){
|
||||||
if(!window || this.isMeta()) return;
|
if(!window || this.isMeta()) return;
|
||||||
|
// console.log(`Scroll to: p${targetPage}`);
|
||||||
window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'smooth', block: 'start' });
|
window.frames['BrewRenderer'].contentDocument.getElementById(`p${targetPage}`).scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||||
// const hashPage = (page != 1) ? `p${page}` : '';
|
// const hashPage = (page != 1) ? `p${page}` : '';
|
||||||
// window.location.hash = hashPage;
|
// window.location.hash = hashPage;
|
||||||
@@ -198,15 +199,15 @@ const Editor = createClass({
|
|||||||
currentPage++;
|
currentPage++;
|
||||||
};
|
};
|
||||||
|
|
||||||
const textArray = this.props.brew.text.split('\n');
|
targetLine = 0;
|
||||||
let lineCount = 0;
|
|
||||||
let linePosition = 0;
|
if(currentPage > 1){
|
||||||
while (linePosition < currentPage-1 && lineCount < textArray.length) {
|
const textString = this.props.brew.text.split('\\page').slice(0, currentPage-1).join('\\page');
|
||||||
// console.log(`${lineCount}: ${textArray[lineCount].toString()}`);
|
const textPosition = textString.length;
|
||||||
if(textArray[lineCount].toString().includes('\\page')) { linePosition++; }
|
const lineCount = textString.slice(0, textPosition).split('\n').length;
|
||||||
lineCount++;
|
|
||||||
|
targetLine = lineCount;
|
||||||
}
|
}
|
||||||
targetLine = lineCount;
|
|
||||||
}
|
}
|
||||||
// Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length);
|
// Math.floor(target.scrollTop / target.scrollHeight * prevState.pages.length);
|
||||||
this.refs.codeEditor.setCursorPosition(targetLine, 0);
|
this.refs.codeEditor.setCursorPosition(targetLine, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user