Fix the positioning of the progressive loadingBar
This commit is contained in:
parent
af8e96cf26
commit
4890c5d017
@ -155,15 +155,18 @@ var ProgressBar = (function ProgressBarClosure() {
|
|||||||
|
|
||||||
function ProgressBar(id, opts) {
|
function ProgressBar(id, opts) {
|
||||||
|
|
||||||
// Fetch the sub-elements for later
|
// Fetch the sub-elements for later.
|
||||||
this.div = document.querySelector(id + ' .progress');
|
this.div = document.querySelector(id + ' .progress');
|
||||||
|
|
||||||
// Get options, with sensible defaults
|
// Get the loading bar element, so it can be resized to fit the viewer.
|
||||||
|
this.bar = this.div.parentNode;
|
||||||
|
|
||||||
|
// Get options, with sensible defaults.
|
||||||
this.height = opts.height || 100;
|
this.height = opts.height || 100;
|
||||||
this.width = opts.width || 100;
|
this.width = opts.width || 100;
|
||||||
this.units = opts.units || '%';
|
this.units = opts.units || '%';
|
||||||
|
|
||||||
// Initialize heights
|
// Initialize heights.
|
||||||
this.div.style.height = this.height + this.units;
|
this.div.style.height = this.height + this.units;
|
||||||
this.percent = 0;
|
this.percent = 0;
|
||||||
}
|
}
|
||||||
@ -190,6 +193,22 @@ var ProgressBar = (function ProgressBarClosure() {
|
|||||||
this._indeterminate = isNaN(val);
|
this._indeterminate = isNaN(val);
|
||||||
this._percent = clamp(val, 0, 100);
|
this._percent = clamp(val, 0, 100);
|
||||||
this.updateBar();
|
this.updateBar();
|
||||||
|
},
|
||||||
|
|
||||||
|
setWidth: function ProgressBar_setWidth(viewer) {
|
||||||
|
if (viewer) {
|
||||||
|
var container = viewer.parentNode;
|
||||||
|
var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
|
||||||
|
if (scrollbarWidth > 0) {
|
||||||
|
this.bar.setAttribute('style', 'width: calc(100% - ' +
|
||||||
|
scrollbarWidth + 'px);');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
hide: function ProgressBar_hide() {
|
||||||
|
this.bar.classList.add('hidden');
|
||||||
|
this.bar.removeAttribute('style');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -231,9 +231,6 @@ html[dir='rtl'] #sidebarContent {
|
|||||||
left: 0;
|
left: 0;
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
.loadingInProgress #viewerContainer {
|
|
||||||
top: 39px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar {
|
.toolbar {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -746,16 +746,21 @@ var PDFView = {
|
|||||||
return support;
|
return support;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get loadingBar() {
|
||||||
|
var bar = new ProgressBar('#loadingBar', {});
|
||||||
|
Object.defineProperty(this, 'loadingBar', { value: bar,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
writable: false });
|
||||||
|
return bar;
|
||||||
|
},
|
||||||
|
|
||||||
get isHorizontalScrollbarEnabled() {
|
get isHorizontalScrollbarEnabled() {
|
||||||
var div = document.getElementById('viewerContainer');
|
var div = document.getElementById('viewerContainer');
|
||||||
return div.scrollWidth > div.clientWidth;
|
return div.scrollWidth > div.clientWidth;
|
||||||
},
|
},
|
||||||
|
|
||||||
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
initPassiveLoading: function pdfViewInitPassiveLoading() {
|
||||||
if (!PDFView.loadingBar) {
|
|
||||||
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
|
|
||||||
}
|
|
||||||
|
|
||||||
var pdfDataRangeTransport = {
|
var pdfDataRangeTransport = {
|
||||||
rangeListeners: [],
|
rangeListeners: [],
|
||||||
progressListeners: [],
|
progressListeners: [],
|
||||||
@ -857,10 +862,6 @@ var PDFView = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!PDFView.loadingBar) {
|
|
||||||
PDFView.loadingBar = new ProgressBar('#loadingBar', {});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.pdfDocument = null;
|
this.pdfDocument = null;
|
||||||
var self = this;
|
var self = this;
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
@ -1150,8 +1151,7 @@ var PDFView = {
|
|||||||
errorWrapper.setAttribute('hidden', 'true');
|
errorWrapper.setAttribute('hidden', 'true');
|
||||||
|
|
||||||
pdfDocument.dataLoaded().then(function() {
|
pdfDocument.dataLoaded().then(function() {
|
||||||
var loadingBar = document.getElementById('loadingBar');
|
PDFView.loadingBar.hide();
|
||||||
loadingBar.classList.add('hidden');
|
|
||||||
var outerContainer = document.getElementById('outerContainer');
|
var outerContainer = document.getElementById('outerContainer');
|
||||||
outerContainer.classList.remove('loadingInProgress');
|
outerContainer.classList.remove('loadingInProgress');
|
||||||
});
|
});
|
||||||
@ -1213,6 +1213,8 @@ var PDFView = {
|
|||||||
event.initCustomEvent('documentload', true, true, {});
|
event.initCustomEvent('documentload', true, true, {});
|
||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
|
|
||||||
|
PDFView.loadingBar.setWidth(container);
|
||||||
|
|
||||||
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||||
var pagePromise = pdfDocument.getPage(pageNum);
|
var pagePromise = pdfDocument.getPage(pageNum);
|
||||||
pagePromise.then(function(pdfPage) {
|
pagePromise.then(function(pdfPage) {
|
||||||
|
Loading…
Reference in New Issue
Block a user