mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
[api-minor] Deprecate getGlobalEventBus
and update the "viewer components" examples accordingly
To avoid outright breaking third-party usages of the "viewer components" the `getGlobalEventBus` functionality is left intact, but a deprecation message is printed if the function is invoked. The various examples are updated to *explicitly* initialize an `EventBus` instance, and provide that when initializing the relevant viewer components.
This commit is contained in:
parent
965ebe63fd
commit
9a437a158f
16 changed files with 68 additions and 34 deletions
|
@ -35,6 +35,8 @@ var SCALE = 1.0;
|
|||
|
||||
var container = document.getElementById("pageContainer");
|
||||
|
||||
var eventBus = new pdfjsViewer.EventBus();
|
||||
|
||||
// Loading document.
|
||||
var loadingTask = pdfjsLib.getDocument({
|
||||
url: DEFAULT_URL,
|
||||
|
@ -50,6 +52,7 @@ loadingTask.promise.then(function(pdfDocument) {
|
|||
id: PAGE_TO_VIEW,
|
||||
scale: SCALE,
|
||||
defaultViewport: pdfPage.getViewport({ scale: SCALE }),
|
||||
eventBus: eventBus,
|
||||
// We can enable text/annotations layers, if needed
|
||||
textLayerFactory: new pdfjsViewer.DefaultTextLayerFactory(),
|
||||
annotationLayerFactory: new pdfjsViewer.DefaultAnnotationLayerFactory(),
|
||||
|
|
|
@ -34,22 +34,28 @@ var SEARCH_FOR = ""; // try 'Mozilla';
|
|||
|
||||
var container = document.getElementById("viewerContainer");
|
||||
|
||||
var eventBus = new pdfjsViewer.EventBus();
|
||||
|
||||
// (Optionally) enable hyperlinks within PDF files.
|
||||
var pdfLinkService = new pdfjsViewer.PDFLinkService();
|
||||
var pdfLinkService = new pdfjsViewer.PDFLinkService({
|
||||
eventBus: eventBus,
|
||||
});
|
||||
|
||||
// (Optionally) enable find controller.
|
||||
var pdfFindController = new pdfjsViewer.PDFFindController({
|
||||
eventBus: eventBus,
|
||||
linkService: pdfLinkService,
|
||||
});
|
||||
|
||||
var pdfViewer = new pdfjsViewer.PDFViewer({
|
||||
container: container,
|
||||
eventBus: eventBus,
|
||||
linkService: pdfLinkService,
|
||||
findController: pdfFindController,
|
||||
});
|
||||
pdfLinkService.setViewer(pdfViewer);
|
||||
|
||||
document.addEventListener("pagesinit", function() {
|
||||
eventBus.on("pagesinit", function() {
|
||||
// We can use pdfViewer now, e.g. let's change default scale.
|
||||
pdfViewer.currentScaleValue = "page-width";
|
||||
|
||||
|
|
|
@ -34,22 +34,28 @@ var SEARCH_FOR = ""; // try 'Mozilla';
|
|||
|
||||
var container = document.getElementById("viewerContainer");
|
||||
|
||||
var eventBus = new pdfjsViewer.EventBus();
|
||||
|
||||
// (Optionally) enable hyperlinks within PDF files.
|
||||
var pdfLinkService = new pdfjsViewer.PDFLinkService();
|
||||
var pdfLinkService = new pdfjsViewer.PDFLinkService({
|
||||
eventBus: eventBus,
|
||||
});
|
||||
|
||||
// (Optionally) enable find controller.
|
||||
var pdfFindController = new pdfjsViewer.PDFFindController({
|
||||
eventBus: eventBus,
|
||||
linkService: pdfLinkService,
|
||||
});
|
||||
|
||||
var pdfSinglePageViewer = new pdfjsViewer.PDFSinglePageViewer({
|
||||
container: container,
|
||||
eventBus: eventBus,
|
||||
linkService: pdfLinkService,
|
||||
findController: pdfFindController,
|
||||
});
|
||||
pdfLinkService.setViewer(pdfSinglePageViewer);
|
||||
|
||||
document.addEventListener("pagesinit", function() {
|
||||
eventBus.on("pagesinit", function() {
|
||||
// We can use pdfSinglePageViewer now, e.g. let's change default scale.
|
||||
pdfSinglePageViewer.currentScaleValue = "page-width";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue