From 06098b7bdd6a83f6b9cc07d2377f2a19cc0ecaa6 Mon Sep 17 00:00:00 2001
From: Philipp Eichmann <philipp.eichmann@gmail.com>
Date: Fri, 21 Dec 2018 18:45:24 -0500
Subject: added code

---
 src/views/nodes/TopBar.tsx | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 src/views/nodes/TopBar.tsx

(limited to 'src/views/nodes/TopBar.tsx')

diff --git a/src/views/nodes/TopBar.tsx b/src/views/nodes/TopBar.tsx
new file mode 100644
index 000000000..bb126e8b5
--- /dev/null
+++ b/src/views/nodes/TopBar.tsx
@@ -0,0 +1,46 @@
+import { observer } from "mobx-react";
+import { NodeStore } from "../../stores/NodeStore";
+import "./NodeView.scss";
+import React = require("react");
+
+interface IProps {
+    store: NodeStore;
+}
+
+@observer
+export class TopBar extends React.Component<IProps> {
+
+    private _isPointerDown = false;
+
+    onPointerDown = (e: React.PointerEvent): void => {
+        e.stopPropagation();
+        e.preventDefault();
+        this._isPointerDown = true;
+        document.removeEventListener("pointermove", this.onPointerMove);
+        document.addEventListener("pointermove", this.onPointerMove);
+        document.removeEventListener("pointerup", this.onPointerUp);
+        document.addEventListener("pointerup", this.onPointerUp);
+    }
+
+    onPointerUp = (e: PointerEvent): void => {
+        e.stopPropagation();
+        e.preventDefault();
+        this._isPointerDown = false;
+        document.removeEventListener("pointermove", this.onPointerMove);
+        document.removeEventListener("pointerup", this.onPointerUp);
+    }
+
+    onPointerMove = (e: PointerEvent): void => {
+        e.stopPropagation();
+        e.preventDefault();
+        if (!this._isPointerDown) {
+            return;
+        }
+        this.props.store.X += e.movementX;
+        this.props.store.Y += e.movementY;
+    }
+
+    render() {
+        return <div className="top" onPointerDown={this.onPointerDown}></div>
+    }
+}
-- 
cgit v1.2.3-70-g09d2

