mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Move additional code/methods into BaseViewer
and have the extending classes override/extend methods as necessary
This attempts to provide more "default" methods in the base class, in order to reduce unnecessary duplication and to improve self-documentation of the `BaseViewer` class slightly. The following changes are made (in no particular order): - Have `BaseViewer` implement the `_scrollIntoView` method, and *extend* it as necessary in `PDFViewer`/`PDFSinglePageViewer`. - Simply inline the `BaseViewer._resizeBuffer` method, in `BaseViewer.update`, since there's only one call-site at this point. - Provide a default implementation of `_isScrollModeHorizontal` in `BaseViewer`, and have `PDFSinglePageViewer` override it. - Provide a default implementation of `_getVisiblePages`, and have `PDFViewer` extend it and `PDFSinglePageViewer` override it.
This commit is contained in:
parent
9128335c4d
commit
06cda4c2e7
3 changed files with 24 additions and 38 deletions
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
import { BaseViewer } from './base_viewer';
|
||||
import { scrollIntoView } from './ui_utils';
|
||||
import { shadow } from 'pdfjs-lib';
|
||||
|
||||
class PDFSinglePageViewer extends BaseViewer {
|
||||
|
@ -87,7 +86,7 @@ class PDFSinglePageViewer extends BaseViewer {
|
|||
let previousLocation = this._location;
|
||||
this._ensurePageViewVisible();
|
||||
|
||||
scrollIntoView(pageDiv, pageSpot);
|
||||
super._scrollIntoView({ pageDiv, pageSpot, pageNumber, });
|
||||
|
||||
// Since scrolling is tracked using `requestAnimationFrame`, update the
|
||||
// scroll direction during the next `this._scrollUpdate` invocation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue