@@ -59,7 +59,13 @@ function getFileName(url) {
59
59
}
60
60
61
61
function scrollIntoView (element , spot ) {
62
+ // Assuming offsetParent is available (it's not available when viewer is in
63
+ // hidden iframe or object). We have to scroll: if the offsetParent is not set
64
+ // producing the error. See also animationStartedClosure.
62
65
var parent = element .offsetParent , offsetY = element .offsetTop ;
66
+ if (!parent ) {
67
+ error ('offsetParent is not set -- cannot scroll' );
68
+ }
63
69
while (parent .clientHeight == parent .scrollHeight ) {
64
70
offsetY += parent .offsetTop ;
65
71
parent = parent .offsetParent ;
@@ -1286,7 +1292,8 @@ var PDFView = {
1286
1292
});
1287
1293
1288
1294
// outline and initial view depends on destinations and pagesRefMap
1289
- var promises = [pagesPromise , destinationsPromise , storePromise ];
1295
+ var promises = [pagesPromise , destinationsPromise , storePromise ,
1296
+ PDFView .animationStartedPromise ];
1290
1297
PDFJS .Promise .all (promises ).then (function () {
1291
1298
pdfDocument .getOutline ().then (function (outline ) {
1292
1299
self .outline = new DocumentOutlineView (outline );
@@ -3311,6 +3318,21 @@ window.addEventListener('afterprint', function afterPrint(evt) {
3311
3318
window .addEventListener ('webkitfullscreenchange' , fullscreenChange , false );
3312
3319
})();
3313
3320
3321
+ (function animationStartedClosure () {
3322
+ // The offsetParent is not set until the pdf.js iframe or object is visible.
3323
+ // Waiting for first animation.
3324
+ var requestAnimationFrame = window .requestAnimationFrame ||
3325
+ window .mozRequestAnimationFrame ||
3326
+ window .webkitRequestAnimationFrame ||
3327
+ window .oRequestAnimationFrame ||
3328
+ window .msRequestAnimationFrame ||
3329
+ function startAtOnce (callback ) { callback (); };
3330
+ PDFView .animationStartedPromise = new PDFJS .Promise ();
3331
+ requestAnimationFrame (function onAnimationFrame () {
3332
+ PDFView .animationStartedPromise .resolve ();
3333
+ });
3334
+ })();
3335
+
3314
3336
//#if B2G
3315
3337
//window.navigator.mozSetMessageHandler('activity', function(activity) {
3316
3338
// var url = activity.source.data.url;
0 commit comments