Skip to content

Commit

Permalink
Improve navigation to annotation by id (annotationKey)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Aug 6, 2021
1 parent 7108427 commit 05da34b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/annotator.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ const Annotator = React.forwardRef((props, ref) => {
}

let navigate = (location) => {

let id = location.id || location.annotationKey;
let annotation = id && annotationsRef.current.find(x => x.id === id);
if (annotation) {
// selectAnnotation(id, true, false, true, true);
makeBlink(annotation.position);
scrollTo({ id, position: annotation.position }, true, true);
return;
}

if (Number.isInteger(location.pageIndex)) {
window.PDFViewerApplication.pdfViewer.scrollPageIntoView({
pageNumber: location.pageIndex + 1
Expand All @@ -207,14 +217,6 @@ const Annotator = React.forwardRef((props, ref) => {
return;
}

let annotation = location.id && annotationsRef.current.find(x => x.id === location.id);
if (annotation) {
selectAnnotation(location.id, true, false, true, true);
if (!location.position) {
location.position = annotation.position;
}
}

makeBlink(location.position);
scrollTo(location, true, true);
};
Expand Down

0 comments on commit 05da34b

Please sign in to comment.