Merge pull request #3607 from Snuffleupagus/issue-3604
Prevent searching during load from breaking the find functionality
This commit is contained in:
commit
7cf8b8d70c
@ -64,6 +64,8 @@ var PDFFindController = {
|
||||
|
||||
integratedFind: false,
|
||||
|
||||
firstPagePromise: new PDFJS.Promise(),
|
||||
|
||||
initialize: function(options) {
|
||||
if(typeof PDFFindBar === 'undefined' || PDFFindBar === null) {
|
||||
throw 'PDFFindController cannot be initialized ' +
|
||||
@ -172,15 +174,17 @@ var PDFFindController = {
|
||||
this.state = e.detail;
|
||||
this.updateUIState(FindStates.FIND_PENDING);
|
||||
|
||||
this.extractText();
|
||||
this.firstPagePromise.then(function() {
|
||||
this.extractText();
|
||||
|
||||
clearTimeout(this.findTimeout);
|
||||
if (e.type === 'find') {
|
||||
// Only trigger the find action after 250ms of silence.
|
||||
this.findTimeout = setTimeout(this.nextMatch.bind(this), 250);
|
||||
} else {
|
||||
this.nextMatch();
|
||||
}
|
||||
clearTimeout(this.findTimeout);
|
||||
if (e.type === 'find') {
|
||||
// Only trigger the find action after 250ms of silence.
|
||||
this.findTimeout = setTimeout(this.nextMatch.bind(this), 250);
|
||||
} else {
|
||||
this.nextMatch();
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
updatePage: function(idx) {
|
||||
|
@ -162,8 +162,6 @@ var Settings = (function SettingsClosure() {
|
||||
var cache = new Cache(CACHE_SIZE);
|
||||
var currentPageNumber = 1;
|
||||
|
||||
// TODO: Enable the FindBar *AFTER* the pagesPromise in the load function
|
||||
// got resolved
|
||||
//#include pdf_find_bar.js
|
||||
//#include pdf_find_controller.js
|
||||
//#include pdf_history.js
|
||||
@ -941,6 +939,8 @@ var PDFView = {
|
||||
pagePromises.push(pagePromise);
|
||||
}
|
||||
|
||||
PDFFindController.firstPagePromise.resolve();
|
||||
|
||||
PDFJS.Promise.all(pagePromises).then(function(pages) {
|
||||
pagesPromise.resolve(pages);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user