Merge pull request #2613 from yurydelendik/wait-animation
Wait for animation frame before displaying stuff
This commit is contained in:
commit
7bd8887860
@ -59,7 +59,13 @@ function getFileName(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function scrollIntoView(element, spot) {
|
function scrollIntoView(element, spot) {
|
||||||
|
// Assuming offsetParent is available (it's not available when viewer is in
|
||||||
|
// hidden iframe or object). We have to scroll: if the offsetParent is not set
|
||||||
|
// producing the error. See also animationStartedClosure.
|
||||||
var parent = element.offsetParent, offsetY = element.offsetTop;
|
var parent = element.offsetParent, offsetY = element.offsetTop;
|
||||||
|
if (!parent) {
|
||||||
|
error('offsetParent is not set -- cannot scroll');
|
||||||
|
}
|
||||||
while (parent.clientHeight == parent.scrollHeight) {
|
while (parent.clientHeight == parent.scrollHeight) {
|
||||||
offsetY += parent.offsetTop;
|
offsetY += parent.offsetTop;
|
||||||
parent = parent.offsetParent;
|
parent = parent.offsetParent;
|
||||||
@ -1286,7 +1292,8 @@ var PDFView = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// outline and initial view depends on destinations and pagesRefMap
|
// outline and initial view depends on destinations and pagesRefMap
|
||||||
var promises = [pagesPromise, destinationsPromise, storePromise];
|
var promises = [pagesPromise, destinationsPromise, storePromise,
|
||||||
|
PDFView.animationStartedPromise];
|
||||||
PDFJS.Promise.all(promises).then(function() {
|
PDFJS.Promise.all(promises).then(function() {
|
||||||
pdfDocument.getOutline().then(function(outline) {
|
pdfDocument.getOutline().then(function(outline) {
|
||||||
self.outline = new DocumentOutlineView(outline);
|
self.outline = new DocumentOutlineView(outline);
|
||||||
@ -3321,6 +3328,21 @@ window.addEventListener('afterprint', function afterPrint(evt) {
|
|||||||
window.addEventListener('webkitfullscreenchange', fullscreenChange, false);
|
window.addEventListener('webkitfullscreenchange', fullscreenChange, false);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
(function animationStartedClosure() {
|
||||||
|
// The offsetParent is not set until the pdf.js iframe or object is visible.
|
||||||
|
// Waiting for first animation.
|
||||||
|
var requestAnimationFrame = window.requestAnimationFrame ||
|
||||||
|
window.mozRequestAnimationFrame ||
|
||||||
|
window.webkitRequestAnimationFrame ||
|
||||||
|
window.oRequestAnimationFrame ||
|
||||||
|
window.msRequestAnimationFrame ||
|
||||||
|
function startAtOnce(callback) { callback(); };
|
||||||
|
PDFView.animationStartedPromise = new PDFJS.Promise();
|
||||||
|
requestAnimationFrame(function onAnimationFrame() {
|
||||||
|
PDFView.animationStartedPromise.resolve();
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
//#if B2G
|
//#if B2G
|
||||||
//window.navigator.mozSetMessageHandler('activity', function(activity) {
|
//window.navigator.mozSetMessageHandler('activity', function(activity) {
|
||||||
// var url = activity.source.data.url;
|
// var url = activity.source.data.url;
|
||||||
|
Loading…
Reference in New Issue
Block a user