mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 10:02:43 +00:00
Use BoundingRect.bottom to determine page
This commit is contained in:
@@ -189,18 +189,20 @@ const Editor = createClass({
|
|||||||
sourceJump : function(targetLine=null){
|
sourceJump : function(targetLine=null){
|
||||||
if(this.isText() || (this.isStyle() && targetLine == 0)) {
|
if(this.isText() || (this.isStyle() && targetLine == 0)) {
|
||||||
if(targetLine == null) {
|
if(targetLine == null) {
|
||||||
const brewPosition = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).scrollTop;
|
|
||||||
const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page');
|
|
||||||
|
|
||||||
let currentPage = 0;
|
|
||||||
let currentPagePosition = 0;
|
|
||||||
while (currentPagePosition < brewPosition && currentPage < pageCollection.length) {
|
|
||||||
currentPagePosition = currentPagePosition + pageCollection[currentPage].getBoundingClientRect().bottom;
|
|
||||||
currentPage++;
|
|
||||||
};
|
|
||||||
|
|
||||||
targetLine = 0;
|
targetLine = 0;
|
||||||
|
|
||||||
|
const pageCollection = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('page');
|
||||||
|
const brewRendererHeight = window.frames['BrewRenderer'].contentDocument.getElementsByClassName('brewRenderer').item(0).getBoundingClientRect().height;
|
||||||
|
|
||||||
|
let currentPage = 1;
|
||||||
|
for (const page of pageCollection) {
|
||||||
|
if(page.getBoundingClientRect().bottom > (brewRendererHeight / 2)) {
|
||||||
|
const pageId = page.id;
|
||||||
|
currentPage = parseInt(pageId.slice(1, pageId.length)) || 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(currentPage > 1){
|
if(currentPage > 1){
|
||||||
const textString = this.props.brew.text.split('\\page').slice(0, currentPage-1).join('\\page');
|
const textString = this.props.brew.text.split('\\page').slice(0, currentPage-1).join('\\page');
|
||||||
const textPosition = textString.length;
|
const textPosition = textString.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user