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.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { AnnotationEditorType, shadow } from "pdfjs-lib";
|
||||||
import { CursorTool, PresentationModeState } from "./ui_utils.js";
|
import { CursorTool, PresentationModeState } from "./ui_utils.js";
|
||||||
import { AnnotationEditorType } from "pdfjs-lib";
|
|
||||||
import { GrabToPan } from "./grab_to_pan.js";
|
import { GrabToPan } from "./grab_to_pan.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,10 +38,6 @@ class PDFCursorTools {
|
|||||||
this.container = container;
|
this.container = container;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
this.handTool = new GrabToPan({
|
|
||||||
element: this.container,
|
|
||||||
});
|
|
||||||
|
|
||||||
this.#addEventListeners();
|
this.#addEventListeners();
|
||||||
|
|
||||||
// Defer the initial `switchTool` call, to give other viewer components
|
// Defer the initial `switchTool` call, to give other viewer components
|
||||||
@ -76,7 +72,7 @@ class PDFCursorTools {
|
|||||||
case CursorTool.SELECT:
|
case CursorTool.SELECT:
|
||||||
break;
|
break;
|
||||||
case CursorTool.HAND:
|
case CursorTool.HAND:
|
||||||
this.handTool.deactivate();
|
this._handTool.deactivate();
|
||||||
break;
|
break;
|
||||||
case CursorTool.ZOOM:
|
case CursorTool.ZOOM:
|
||||||
/* falls through */
|
/* falls through */
|
||||||
@ -90,7 +86,7 @@ class PDFCursorTools {
|
|||||||
break;
|
break;
|
||||||
case CursorTool.HAND:
|
case CursorTool.HAND:
|
||||||
disableActiveTool();
|
disableActiveTool();
|
||||||
this.handTool.activate();
|
this._handTool.activate();
|
||||||
break;
|
break;
|
||||||
case CursorTool.ZOOM:
|
case CursorTool.ZOOM:
|
||||||
/* falls through */
|
/* falls through */
|
||||||
@ -164,6 +160,19 @@ class PDFCursorTools {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
get _handTool() {
|
||||||
|
return shadow(
|
||||||
|
this,
|
||||||
|
"_handTool",
|
||||||
|
new GrabToPan({
|
||||||
|
element: this.container,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { PDFCursorTools };
|
export { PDFCursorTools };
|
||||||
|
Loading…
Reference in New Issue
Block a user