Prevent searching during load from breaking the find functionality

This commit is contained in:
Jonas 2013-09-05 00:25:19 +02:00
parent c5bcd7a7ef
commit 54dfe05e30
2 changed files with 14 additions and 10 deletions

View file

@ -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) {