Skip to content

Commit

Permalink
ignoreDestinationZoom when clicking bookmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
conorom committed Jun 2, 2022
1 parent b713a38 commit 691e330
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions app/views/e_pubs/show_pdf.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -872,16 +872,21 @@
// self.PDFViewerApplication.open('<%= "#{@presenter.id}/file?#{@presenter.browser_cache_breaker}" %>').then(function() {
self.pdfViewer = this.PDFViewerApplication.pdfViewer;

// this option is weird to tweak in viewer.js, it seems to very much be geared to user preferences in...
// Firefox's about:config (BasePreferences in viewer.js). Setting it here does what we want for...
// HELIO-2866/HELIO-4266 without tracking more hacks to viewer.js in Confluence.
self.PDFViewerApplication.pdfLinkService._ignoreDestinationZoom = true;

// monkeypatch the PDFLinkService to be able to track when _it_
// thinks clicks are worth of pushing onto history so we can
// tell when to push links onto history.
self.PDFViewerApplication.pdfLinkService.pdfHistory = {
pushCurrentPosition: function() { /* NO OP */ },
// ToC links, i.e. all PDF bookmarks
push: function(context) {
self.tracking.action('contents/go/link');
self._will_be_setting_zoom_to = context.explicitDest[4];
self._will_be_setting_zoom_from = self.pdfViewer.currentScaleValue;
},
// thumbnail links
pushPage: function(pageNumber) {
self.tracking.action('contents/go/link');
}
Expand Down Expand Up @@ -910,15 +915,6 @@
});
});

self.pdfViewer.eventBus.on('scalechanging', function(evt) {
var currentScaleValue = self.options.scale;
if ( self._will_be_setting_zoom_to && self._will_be_setting_zoom_from ) {
// and clear these
self._will_be_setting_zoom_to = self._will_be_setting_zoom_from = null;
self.pdfViewer.currentScaleValue = currentScaleValue;
}
});

self.PDFViewerApplication.pdfDocument.getMetadata().then(function(data) {
var metadata = {};
metadata.layout = 'pdf';
Expand Down

0 comments on commit 691e330

Please sign in to comment.