Make logic for waiting for PDFs to load work in PDF.js >= 2.5.207
f96af43d added support for PDF.js >= v2.5.207 by changing an event listener to use PDF.js's internal event bus rather than DOM events. However there was another DOM event listener for the `pagesloaded` event in `src/annotator/anchoring/pdf.js` that should also have been updated but was overlooked. This didn't cause a problem in testing with the dev server because the test documents load quickly enough that they are already loaded by the time the client's anchoring logic ran. This commit updates the way that the client listens for events from PDF.js to use the event bus where available and only fall back to the DOM in versions of PDF.js that don't support it. - Use PDF.js's event bus to listen for `documentload`/`documentloaded` and `pagesloaded` events - Add a fallback method to wait for event bus to become available in versions of PDF.js which support the eventBus but don't have the `initializedPromise` API - Improve the documentation around which versions of PDF.js support different event types and event dispatch methods - Add tests to cover the behavior from different releases of PDF.js For an overview of the different versions of PDF.js that the client needs to support, see https://github.com/hypothesis/client/issues/2643.
Showing
Please register or sign in to comment