Don't wait arbitrary long for all pages to be resolved before attempting to re-apply the initial position on load (PR 6318 follow-up)
With the current code, the location in the viewer could change *well* after the user has started to interact with the viewer (for very large and/or slow loading documents). Attempt to reduce the likelyhood of that happening, by adding an upper bound to the time spent waiting before attempting to re-apply the initial position.
This commit is contained in:
parent
3691f9cc78
commit
95a4fa25b9
15
web/app.js
15
web/app.js
@ -48,7 +48,8 @@ import { Toolbar } from './toolbar';
|
|||||||
import { ViewHistory } from './view_history';
|
import { ViewHistory } from './view_history';
|
||||||
|
|
||||||
const DEFAULT_SCALE_DELTA = 1.1;
|
const DEFAULT_SCALE_DELTA = 1.1;
|
||||||
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000; // ms
|
||||||
|
const FORCE_PAGES_LOADED_TIMEOUT = 10000; // ms
|
||||||
|
|
||||||
const DefaultExternalServices = {
|
const DefaultExternalServices = {
|
||||||
updateFindControlState(data) {},
|
updateFindControlState(data) {},
|
||||||
@ -1074,10 +1075,20 @@ let PDFViewerApplication = {
|
|||||||
if (!this.isViewerEmbedded) {
|
if (!this.isViewerEmbedded) {
|
||||||
pdfViewer.focus();
|
pdfViewer.focus();
|
||||||
}
|
}
|
||||||
return pagesPromise;
|
|
||||||
|
return Promise.race([
|
||||||
|
pagesPromise,
|
||||||
|
new Promise((resolve) => {
|
||||||
|
setTimeout(resolve, FORCE_PAGES_LOADED_TIMEOUT);
|
||||||
|
}),
|
||||||
|
]);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
// For documents with different page sizes, once all pages are resolved,
|
// For documents with different page sizes, once all pages are resolved,
|
||||||
// ensure that the correct location becomes visible on load.
|
// ensure that the correct location becomes visible on load.
|
||||||
|
// To reduce the risk, in very large and/or slow loading documents,
|
||||||
|
// that the location changes *after* the user has started interacting
|
||||||
|
// with the viewer, wait for either `pagesPromise` or a timeout above.
|
||||||
|
|
||||||
if (!initialParams.bookmark && !initialParams.hash) {
|
if (!initialParams.bookmark && !initialParams.hash) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user