Create a GrabToPan
-instance lazily in the PDFCursorTools
class
Unless the user enables the "HandTool" we don't actually need to create a `GrabToPan`-instance.
This commit is contained in:
parent
789e318cf7
commit
4f82dd3932
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AnnotationEditorType, shadow } from "pdfjs-lib";
|
||||
import { CursorTool, PresentationModeState } from "./ui_utils.js";
|
||||
import { AnnotationEditorType } from "pdfjs-lib";
|
||||
import { GrabToPan } from "./grab_to_pan.js";
|
||||
|
||||
/**
|
||||
@ -38,10 +38,6 @@ class PDFCursorTools {
|
||||
this.container = container;
|
||||
this.eventBus = eventBus;
|
||||
|
||||
this.handTool = new GrabToPan({
|
||||
element: this.container,
|
||||
});
|
||||
|
||||
this.#addEventListeners();
|
||||
|
||||
// Defer the initial `switchTool` call, to give other viewer components
|
||||
@ -76,7 +72,7 @@ class PDFCursorTools {
|
||||
case CursorTool.SELECT:
|
||||
break;
|
||||
case CursorTool.HAND:
|
||||
this.handTool.deactivate();
|
||||
this._handTool.deactivate();
|
||||
break;
|
||||
case CursorTool.ZOOM:
|
||||
/* falls through */
|
||||
@ -90,7 +86,7 @@ class PDFCursorTools {
|
||||
break;
|
||||
case CursorTool.HAND:
|
||||
disableActiveTool();
|
||||
this.handTool.activate();
|
||||
this._handTool.activate();
|
||||
break;
|
||||
case CursorTool.ZOOM:
|
||||
/* falls through */
|
||||
@ -164,6 +160,19 @@ class PDFCursorTools {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
get _handTool() {
|
||||
return shadow(
|
||||
this,
|
||||
"_handTool",
|
||||
new GrabToPan({
|
||||
element: this.container,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { PDFCursorTools };
|
||||
|
Loading…
Reference in New Issue
Block a user