Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the page switching code into set currentPageNumber in PDFViewer instead of placing it in the pagechange event handler #6140

Merged
merged 1 commit into from
Jun 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions web/pdf_viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ var PDFViewer = (function pdfViewer() {
this._currentPageNumber = val;
event.pageNumber = val;
this.container.dispatchEvent(event);

// Check if the caller is `PDFViewer_update`, to avoid breaking scrolling.
if (this.updateInProgress) {
return;
}
this.scrollPageIntoView(val);
},

/**
Expand Down Expand Up @@ -566,7 +572,7 @@ var PDFViewer = (function pdfViewer() {
};
},

update: function () {
update: function PDFViewer_update() {
var visible = this._getVisiblePages();
var visiblePages = visible.views;
if (visiblePages.length === 0) {
Expand All @@ -581,7 +587,7 @@ var PDFViewer = (function pdfViewer() {

this.renderingQueue.renderHighestPriority(visible);

var currentId = this.currentPageNumber;
var currentId = this._currentPageNumber;
var firstPage = visible.first;

for (var i = 0, ii = visiblePages.length, stillFullyVisible = false;
Expand Down
13 changes: 0 additions & 13 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ var PDFViewerApplication = {
}

var self = this;
self.loading = true;
self.downloadComplete = false;

var passwordNeeded = function passwordNeeded(updatePassword, reason) {
Expand All @@ -543,7 +542,6 @@ var PDFViewerApplication = {
getDocumentProgress).then(
function getDocumentCallback(pdfDocument) {
self.load(pdfDocument, scale);
self.loading = false;
},
function getDocumentError(exception) {
var message = exception && exception.message;
Expand Down Expand Up @@ -571,7 +569,6 @@ var PDFViewerApplication = {
message: message
};
self.error(loadingErrorMessage, moreInfo);
self.loading = false;
}
);

Expand Down Expand Up @@ -1822,16 +1819,6 @@ window.addEventListener('pagechange', function pagechange(evt) {
Stats.add(page, pageView.stats);
}
}

// checking if the this.page was called from the updateViewarea function
if (evt.updateInProgress) {
return;
}
// Avoid scrolling the first page during loading
if (this.loading && page === 1) {
return;
}
PDFViewerApplication.pdfViewer.scrollPageIntoView(page);
}, true);

function handleMouseWheel(evt) {
Expand Down