Skip to content

Commit

Permalink
Fix page not found issue on synctex during PDF refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Oct 5, 2024
1 parent 670aeaf commit 90f09d9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion viewer/components/synctex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ function callSynctex(e: MouseEvent, page: number, pageDom: HTMLElement, viewerCo
const canvas = document.getElementsByClassName('canvasWrapper')[0] as HTMLElement
const left = e.pageX - pageDom.offsetLeft + viewerContainer.scrollLeft - canvas.offsetLeft
const top = e.pageY - pageDom.offsetTop + viewerContainer.scrollTop - canvas.offsetTop
const pos = PDFViewerApplication.pdfViewer._pages[page-1].getPagePoint(left, canvasDom.offsetHeight - top)
const pos = PDFViewerApplication.pdfViewer._pages[page-1]?.getPagePoint(left, canvasDom.offsetHeight - top)
if (pos === undefined) {
return
}
void send({ type: 'reverse_synctex', pdfFileUri: utils.parseURL().pdfFileUri, pos, page, textBeforeSelection, textAfterSelection })
}

Expand Down

0 comments on commit 90f09d9

Please sign in to comment.