From d144d01afe91e025621af7627645abaafdca9e87 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 12 Mar 2021 17:19:58 +0100 Subject: [PATCH] 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. --- examples/mobile-viewer/viewer.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/examples/mobile-viewer/viewer.js b/examples/mobile-viewer/viewer.js index b4f837d53..18b28688c 100644 --- a/examples/mobile-viewer/viewer.js +++ b/examples/mobile-viewer/viewer.js @@ -435,18 +435,14 @@ document.addEventListener( true ); -(function animationStartedClosure() { - // The offsetParent is not set until the PDF.js iframe or object is visible. - // Waiting for first animation. - PDFViewerApplication.animationStartedPromise = new Promise(function ( - resolve - ) { - window.requestAnimationFrame(resolve); - }); -})(); +// The offsetParent is not set until the PDF.js iframe or object is visible; +// waiting for first animation. +const animationStarted = new Promise(function (resolve) { + window.requestAnimationFrame(resolve); +}); // We need to delay opening until all HTML is loaded. -PDFViewerApplication.animationStartedPromise.then(function () { +animationStarted.then(function () { PDFViewerApplication.open({ url: DEFAULT_URL, });