File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ var PDFFindController = {
6464
6565 integratedFind : false ,
6666
67+ firstPagePromise : new PDFJS .Promise (),
68+
6769 initialize : function (options ) {
6870 if (typeof PDFFindBar === 'undefined' || PDFFindBar === null ) {
6971 throw 'PDFFindController cannot be initialized ' +
@@ -172,15 +174,17 @@ var PDFFindController = {
172174 this .state = e .detail ;
173175 this .updateUIState (FindStates .FIND_PENDING );
174176
175- this .extractText ();
177+ this .firstPagePromise .then (function () {
178+ this .extractText ();
176179
177- clearTimeout (this .findTimeout );
178- if (e .type === 'find' ) {
179- // Only trigger the find action after 250ms of silence.
180- this .findTimeout = setTimeout (this .nextMatch .bind (this ), 250 );
181- } else {
182- this .nextMatch ();
183- }
180+ clearTimeout (this .findTimeout );
181+ if (e .type === 'find' ) {
182+ // Only trigger the find action after 250ms of silence.
183+ this .findTimeout = setTimeout (this .nextMatch .bind (this ), 250 );
184+ } else {
185+ this .nextMatch ();
186+ }
187+ }.bind (this ));
184188 },
185189
186190 updatePage : function (idx ) {
Original file line number Diff line number Diff line change @@ -162,8 +162,6 @@ var Settings = (function SettingsClosure() {
162162var cache = new Cache (CACHE_SIZE );
163163var currentPageNumber = 1 ;
164164
165- // TODO: Enable the FindBar *AFTER* the pagesPromise in the load function
166- // got resolved
167165//#include pdf_find_bar.js
168166//#include pdf_find_controller.js
169167//#include pdf_history.js
@@ -941,6 +939,8 @@ var PDFView = {
941939 pagePromises .push (pagePromise );
942940 }
943941
942+ PDFFindController .firstPagePromise .resolve ();
943+
944944 PDFJS .Promise .all (pagePromises ).then (function (pages ) {
945945 pagesPromise .resolve (pages );
946946 });
You can’t perform that action at this time.
0 commit comments