From f3a4010aa1af88f74428c39deced17cd3c8c147d Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Wed, 15 Nov 2023 21:53:01 +0000 Subject: [PATCH] Still highlight annotation position if annotation no longer exists --- src/pdf/pdf-view.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pdf/pdf-view.js b/src/pdf/pdf-view.js index a21e7511..d7eed01a 100644 --- a/src/pdf/pdf-view.js +++ b/src/pdf/pdf-view.js @@ -670,24 +670,26 @@ class PDFView { this._history.save({ dest: [pageIndex, { name: 'XYZ' }, left, top, null] }); } + _highlightPosition(position) { + this._highlightedPosition = position; + this._render(); + setTimeout(() => { + this._highlightedPosition = null; + this._render(); + }, 2000); + } + navigate(location, skipHistory) { - if (location.annotationID) { + if (location.annotationID && this._annotations.find(x => x.id === location.annotationID)) { let annotation = this._annotations.find(x => x.id === location.annotationID); - if (annotation) { - this.navigateToPosition(annotation.position); - } + this.navigateToPosition(annotation.position); } else if (location.dest) { this._iframeWindow.PDFViewerApplication.pdfLinkService.goToDestination(location.dest); } else if (location.position) { this.navigateToPosition(location.position); - this._highlightedPosition = location.position; - this._render(); - setTimeout(() => { - this._highlightedPosition = null; - this._render(); - }, 2000); + this._highlightPosition(location.position); } else if (Number.isInteger(location.pageIndex)) { this._iframeWindow.PDFViewerApplication.pdfViewer.scrollPageIntoView({