Skip to content

Commit d144d01

Browse files
committed
Simplify the animationStarted handling in the mobile-viewer/ example
(This is something that I happened to notice while working on the previous patch.) The code in the `examples/mobile-viewer/viewer.js` file is essentially copied from an older version of the default viewer, hence we can slightly simplify the `animationStarted` handling here.
1 parent 5c712f2 commit d144d01

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

examples/mobile-viewer/viewer.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,14 @@ document.addEventListener(
435435
true
436436
);
437437

438-
(function animationStartedClosure() {
439-
// The offsetParent is not set until the PDF.js iframe or object is visible.
440-
// Waiting for first animation.
441-
PDFViewerApplication.animationStartedPromise = new Promise(function (
442-
resolve
443-
) {
444-
window.requestAnimationFrame(resolve);
445-
});
446-
})();
438+
// The offsetParent is not set until the PDF.js iframe or object is visible;
439+
// waiting for first animation.
440+
const animationStarted = new Promise(function (resolve) {
441+
window.requestAnimationFrame(resolve);
442+
});
447443

448444
// We need to delay opening until all HTML is loaded.
449-
PDFViewerApplication.animationStartedPromise.then(function () {
445+
animationStarted.then(function () {
450446
PDFViewerApplication.open({
451447
url: DEFAULT_URL,
452448
});

0 commit comments

Comments
 (0)