@@ -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 );
@@ -3321,6 +3328,21 @@ window.addEventListener('afterprint', function afterPrint(evt) {
3321
3328
window .addEventListener ('webkitfullscreenchange' , fullscreenChange , false );
3322
3329
})();
3323
3330
3331
+ (function animationStartedClosure () {
3332
+ // The offsetParent is not set until the pdf.js iframe or object is visible.
3333
+ // Waiting for first animation.
3334
+ var requestAnimationFrame = window .requestAnimationFrame ||
3335
+ window .mozRequestAnimationFrame ||
3336
+ window .webkitRequestAnimationFrame ||
3337
+ window .oRequestAnimationFrame ||
3338
+ window .msRequestAnimationFrame ||
3339
+ function startAtOnce (callback ) { callback (); };
3340
+ PDFView .animationStartedPromise = new PDFJS .Promise ();
3341
+ requestAnimationFrame (function onAnimationFrame () {
3342
+ PDFView .animationStartedPromise .resolve ();
3343
+ });
3344
+ })();
3345
+
3324
3346
//#if B2G
3325
3347
//window.navigator.mozSetMessageHandler('activity', function(activity) {
3326
3348
// var url = activity.source.data.url;
0 commit comments