Merge pull request #10466 from Snuffleupagus/BaseViewer-update
Move/refactor the code in the `BaseViewer.update` method to reduce duplication in the extending classes
This commit is contained in:
commit
1bb5ca0588
@ -824,8 +824,28 @@ class BaseViewer {
|
||||
};
|
||||
}
|
||||
|
||||
_updateHelper(visiblePages) {
|
||||
throw new Error('Not implemented: _updateHelper');
|
||||
}
|
||||
|
||||
update() {
|
||||
throw new Error('Not implemented: update');
|
||||
const visible = this._getVisiblePages();
|
||||
const visiblePages = visible.views, numVisiblePages = visiblePages.length;
|
||||
|
||||
if (numVisiblePages === 0) {
|
||||
return;
|
||||
}
|
||||
this._resizeBuffer(numVisiblePages, visiblePages);
|
||||
|
||||
this.renderingQueue.renderHighestPriority(visible);
|
||||
|
||||
this._updateHelper(visiblePages); // Run any class-specific update code.
|
||||
|
||||
this._updateLocation(visible.first);
|
||||
this.eventBus.dispatch('updateviewarea', {
|
||||
source: this,
|
||||
location: this._location,
|
||||
});
|
||||
}
|
||||
|
||||
containsElement(element) {
|
||||
|
@ -111,23 +111,7 @@ class PDFSinglePageViewer extends BaseViewer {
|
||||
return this._getCurrentVisiblePage();
|
||||
}
|
||||
|
||||
update() {
|
||||
let visible = this._getVisiblePages();
|
||||
let visiblePages = visible.views, numVisiblePages = visiblePages.length;
|
||||
|
||||
if (numVisiblePages === 0) {
|
||||
return;
|
||||
}
|
||||
this._resizeBuffer(numVisiblePages);
|
||||
|
||||
this.renderingQueue.renderHighestPriority(visible);
|
||||
|
||||
this._updateLocation(visible.first);
|
||||
this.eventBus.dispatch('updateviewarea', {
|
||||
source: this,
|
||||
location: this._location,
|
||||
});
|
||||
}
|
||||
_updateHelper(visiblePages) { }
|
||||
|
||||
get _isScrollModeHorizontal() {
|
||||
// The Scroll/Spread modes are never used in `PDFSinglePageViewer`.
|
||||
|
@ -45,23 +45,14 @@ class PDFViewer extends BaseViewer {
|
||||
return this._getCurrentVisiblePage();
|
||||
}
|
||||
|
||||
update() {
|
||||
let visible = this._getVisiblePages();
|
||||
let visiblePages = visible.views, numVisiblePages = visiblePages.length;
|
||||
|
||||
if (numVisiblePages === 0) {
|
||||
_updateHelper(visiblePages) {
|
||||
if (this.isInPresentationMode) {
|
||||
return;
|
||||
}
|
||||
this._resizeBuffer(numVisiblePages, visiblePages);
|
||||
|
||||
this.renderingQueue.renderHighestPriority(visible);
|
||||
|
||||
let currentId = this._currentPageNumber;
|
||||
let stillFullyVisible = false;
|
||||
|
||||
for (let i = 0; i < numVisiblePages; ++i) {
|
||||
let page = visiblePages[i];
|
||||
|
||||
for (const page of visiblePages) {
|
||||
if (page.percent < 100) {
|
||||
break;
|
||||
}
|
||||
@ -70,19 +61,10 @@ class PDFViewer extends BaseViewer {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stillFullyVisible) {
|
||||
currentId = visiblePages[0].id;
|
||||
}
|
||||
if (!this.isInPresentationMode) {
|
||||
this._setCurrentPageNumber(currentId);
|
||||
}
|
||||
|
||||
this._updateLocation(visible.first);
|
||||
this.eventBus.dispatch('updateviewarea', {
|
||||
source: this,
|
||||
location: this._location,
|
||||
});
|
||||
this._setCurrentPageNumber(currentId);
|
||||
}
|
||||
|
||||
get _isScrollModeHorizontal() {
|
||||
|
Loading…
Reference in New Issue
Block a user