aboutsummaryrefslogtreecommitdiff
path: root/src/util/DragManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/DragManager.ts')
-rw-r--r--src/util/DragManager.ts15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/util/DragManager.ts b/src/util/DragManager.ts
index 5a854c76d..a864a2bbe 100644
--- a/src/util/DragManager.ts
+++ b/src/util/DragManager.ts
@@ -6,7 +6,14 @@ import { CollectionDockingView } from "../views/collections/CollectionDockingVie
import { Document } from "../fields/Document";
export namespace DragManager {
- export let rootId = "root";
+ export function Root() {
+ const root = document.getElementById("root");
+ if (!root) {
+ throw new Error("No root element found");
+ }
+ return root;
+ }
+
let dragDiv: HTMLDivElement;
export enum DragButtons {
@@ -63,12 +70,8 @@ export namespace DragManager {
let _lastPointerY: number = 0;
export function StartDrag(ele: HTMLElement, dragData: { [ id: string ]: any }, options: DragOptions) {
if (!dragDiv) {
- const root = document.getElementById(rootId);
- if (!root) {
- throw new Error("No root element found");
- }
dragDiv = document.createElement("div");
- root.appendChild(dragDiv);
+ DragManager.Root().appendChild(dragDiv);
}
const w = ele.offsetWidth, h = ele.offsetHeight;
const rect = ele.getBoundingClientRect();