Skip to content

Commit

Permalink
feat: select element for page navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
cguldogan committed Aug 12, 2021
1 parent ea4b3c7 commit 6115bb3
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/react/components/pages/editorPage/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,16 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
/>
}
{this.shouldShowMultiPageIndicator() &&
<p className="page-number">
Page {this.state.currentPage} of {this.state.numPages}
</p>
<div className="page-number">
<p>
Page {this.state.currentPage} of {this.state.numPages}
</p>
<select onChange={(val) => this.navigateToPageNumber(Number(val.target.value))}>
{
Array.from(Array(this.state.numPages).keys()).map(i =><option key={i+1} value={i+1}>{i+1}</option>)
};
</select>
</div>
}
{(this.props.isRunningOCRs || (this.state.ocrStatus !== OcrStatus.done && this.state.ocrStatus !== OcrStatus.failed)) &&
<div className="canvas-ocr-loading">
Expand Down Expand Up @@ -1469,6 +1476,13 @@ export default class Canvas extends React.Component<ICanvasProps, ICanvasState>
}
}

private navigateToPageNumber = async (pageNumber: number) => {
if ((this.state.pdfFile !== null || this.state.tiffImages.length !== 0) && this.state.currentPage < this.state.numPages) {
this.props.closeTableView("rest");
await this.goToPage(pageNumber);
}
}

private goToPage = async (targetPage: number) => {
if (targetPage < 1 || targetPage > this.state.numPages) {
// invalid page number, just return
Expand Down

0 comments on commit 6115bb3

Please sign in to comment.