div.appendChild(canvas);
this.canvas = canvas;
+ var loadingIconDiv = document.createElement('div');
+ loadingIconDiv.className = 'loadingIcon';
+ div.appendChild(loadingIconDiv);
+
var textLayerDiv = null;
if (!PDFJS.disableTextLayer) {
textLayerDiv = document.createElement('div');
ctx.restore();
ctx.translate(-this.x * scale, -this.y * scale);
+ // Rendering area
+
+ var self = this;
+
+ // Display loading icon if page hasn't finished rendering after XXXX ms
+ var loadingTimer = setTimeout(function loadingTimerCallback() {
+ loadingIconDiv.classList.add('show');
+ }, 1000);
+
stats.begin = Date.now();
- this.content.startRendering(ctx,
- (function pageViewDrawCallback(error) {
- if (error)
- PDFView.error('An error occurred while rendering the page.', error);
- this.updateStats();
- if (this.onAfterDraw)
- this.onAfterDraw();
-
- cache.push(this);
- callback();
- }).bind(this), textLayer
- );
+ this.content.startRendering(ctx, function pageViewDrawCallback(error) {
+ clearTimeout(loadingTimer);
+ loadingIconDiv.classList.remove('show');
+
+ if (error)
+ PDFView.error('An error occurred while rendering the page.', error);
+
+ self.updateStats();
+ if (self.onAfterDraw)
+ self.onAfterDraw();
+
+ cache.push(self);
+ callback();
+ }, textLayer);
setupAnnotations(this.content, this.scale);
div.setAttribute('data-loaded', true);