Backout of #3513 (except formatting)
This commit is contained in:
parent
387132c842
commit
bea2e41e45
@ -251,45 +251,28 @@ var PDFView = {
|
|||||||
}, true);
|
}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPageTop: function pdfViewGetPageTop(id) {
|
setScale: function pdfViewSetScale(val, resetAutoSettings, noScroll) {
|
||||||
return (this.pages[id - 1].el.offsetTop + this.pages[id - 1].el.clientTop);
|
if (val == this.currentScale)
|
||||||
},
|
|
||||||
|
|
||||||
setScale: function pdfViewSetScale(value, resetAutoSettings, noScroll) {
|
|
||||||
if (this.currentScale === value) {
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var pages = this.pages, page = this.page;
|
var pages = this.pages;
|
||||||
var currentPage = pages[page - 1], dest = null;
|
for (var i = 0; i < pages.length; i++)
|
||||||
if (!noScroll && !this.isPresentationMode) {
|
pages[i].update(val * CSS_UNITS);
|
||||||
// Obtain the current scroll position before resizing the pages.
|
|
||||||
var topLeft = currentPage.getPagePoint(this.container.scrollLeft,
|
|
||||||
(this.container.scrollTop - this.getPageTop(page)));
|
|
||||||
dest = [null, { name: 'XYZ' }, Math.round(topLeft[0]),
|
|
||||||
Math.round(topLeft[1]), null];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < pages.length; i++) {
|
if (!noScroll && this.currentScale != val)
|
||||||
pages[i].update(value * CSS_UNITS);
|
this.pages[this.page - 1].scrollIntoView();
|
||||||
}
|
this.currentScale = val;
|
||||||
this.currentScale = value;
|
|
||||||
|
|
||||||
if (!noScroll) {
|
|
||||||
currentPage.scrollIntoView(dest);
|
|
||||||
}
|
|
||||||
|
|
||||||
var event = document.createEvent('UIEvents');
|
var event = document.createEvent('UIEvents');
|
||||||
event.initUIEvent('scalechange', false, false, window, 0);
|
event.initUIEvent('scalechange', false, false, window, 0);
|
||||||
event.scale = value;
|
event.scale = val;
|
||||||
event.resetAutoSettings = resetAutoSettings;
|
event.resetAutoSettings = resetAutoSettings;
|
||||||
window.dispatchEvent(event);
|
window.dispatchEvent(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
parseScale: function pdfViewParseScale(value, resetAutoSettings, noScroll) {
|
parseScale: function pdfViewParseScale(value, resetAutoSettings, noScroll) {
|
||||||
if ('custom' === value) {
|
if ('custom' == value)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var scale = parseFloat(value);
|
var scale = parseFloat(value);
|
||||||
this.currentScaleValue = value;
|
this.currentScaleValue = value;
|
||||||
@ -1062,14 +1045,14 @@ var PDFView = {
|
|||||||
} else if (storedHash) {
|
} else if (storedHash) {
|
||||||
this.setHash(storedHash);
|
this.setHash(storedHash);
|
||||||
} else if (scale) {
|
} else if (scale) {
|
||||||
this.parseScale(scale, true, true);
|
this.parseScale(scale, true);
|
||||||
this.page = 1;
|
this.page = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFView.currentScale === UNKNOWN_SCALE) {
|
if (PDFView.currentScale === UNKNOWN_SCALE) {
|
||||||
// Scale was not initialized: invalid bookmark or scale was not specified.
|
// Scale was not initialized: invalid bookmark or scale was not specified.
|
||||||
// Setting the default one.
|
// Setting the default one.
|
||||||
this.parseScale(DEFAULT_SCALE, true, true);
|
this.parseScale(DEFAULT_SCALE, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1394,28 +1377,15 @@ var PDFView = {
|
|||||||
|
|
||||||
enterPresentationMode: function pdfViewEnterPresentationMode() {
|
enterPresentationMode: function pdfViewEnterPresentationMode() {
|
||||||
this.isPresentationMode = true;
|
this.isPresentationMode = true;
|
||||||
this.parseScale('page-fit', true);
|
|
||||||
// Since 'resize' events are fired when entering presentation mode,
|
|
||||||
// add this call to the end of the rendering queue to prevent
|
|
||||||
// the page from being scrolled partially out of view.
|
|
||||||
setTimeout(function() {
|
|
||||||
this.page = this.presentationModeArgs.page;
|
this.page = this.presentationModeArgs.page;
|
||||||
}.bind(this), 0);
|
this.parseScale('page-fit', true);
|
||||||
|
|
||||||
this.showPresentationControls();
|
this.showPresentationControls();
|
||||||
},
|
},
|
||||||
|
|
||||||
exitPresentationMode: function pdfViewExitPresentationMode() {
|
exitPresentationMode: function pdfViewExitPresentationMode() {
|
||||||
this.isPresentationMode = false;
|
this.isPresentationMode = false;
|
||||||
var currentPage = this.pages[this.page - 1];
|
this.parseScale(this.presentationModeArgs.previousScale);
|
||||||
this.parseScale(this.presentationModeArgs.previousScale, true, true);
|
this.page = this.page;
|
||||||
// Since 'resize' events are fired when exiting from presentation mode,
|
|
||||||
// add this call to the end of the rendering queue to make sure
|
|
||||||
// that the current page is scrolled into view properly.
|
|
||||||
setTimeout(function() {
|
|
||||||
currentPage.scrollIntoView();
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
this.clearMouseScrollState();
|
this.clearMouseScrollState();
|
||||||
this.hidePresentationControls();
|
this.hidePresentationControls();
|
||||||
this.presentationModeArgs = null;
|
this.presentationModeArgs = null;
|
||||||
@ -1469,9 +1439,14 @@ var PDFView = {
|
|||||||
this.renderHighestPriority();
|
this.renderHighestPriority();
|
||||||
|
|
||||||
var currentPage = this.pages[this.page - 1];
|
var currentPage = this.pages[this.page - 1];
|
||||||
if (currentPage) {
|
if (!currentPage) {
|
||||||
currentPage.scrollIntoView();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for presentation mode to take effect
|
||||||
|
setTimeout(function() {
|
||||||
|
currentPage.scrollIntoView();
|
||||||
|
}, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user