aboutsummaryrefslogtreecommitdiff
path: root/src/views/nodes/DocumentView.tsx
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-01-26 23:33:47 -0500
committerTyler Schicke <tyler_schicke@brown.edu>2019-01-26 23:33:47 -0500
commitb6f8f3f6c75c330430cd593b543e682838f9865d (patch)
treea1e2744a058564dd9ce5133637ec5a6507dd6f1d /src/views/nodes/DocumentView.tsx
parentf8ce9c45eeba1eccb4244a08e2c752fe4cf39105 (diff)
Got drag drop mostly working
Diffstat (limited to 'src/views/nodes/DocumentView.tsx')
-rw-r--r--src/views/nodes/DocumentView.tsx40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index 33a126a7b..05f0928fb 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -14,6 +14,7 @@ import { SelectionManager } from "../../util/SelectionManager";
import { DocumentDecorations } from "../../DocumentDecorations";
import { ContextMenu } from "../ContextMenu";
import { Opt } from "../../fields/Field";
+import { DragManager } from "../../util/DragManager";
const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this?
interface IProps {
@@ -41,10 +42,7 @@ class DocumentContents extends React.Component<IProps> {
}
render() {
let doc = this.props.Document;
- let bindings: any = {
- doc: doc,
- // isSelected: this.props.isSelected
- };
+ let bindings = {...this.props} as any;
for (const key of this.layoutKeys) {
bindings[key.Name + "Key"] = key;
}
@@ -125,15 +123,25 @@ export class DocumentView extends React.Component<IProps> {
}
componentDidMount() {
- // if(this._mainCont.current) {
- // DragManager.MakeDraggable(this._mainCont.current, {
- // buttons: 2,
- // handlers: {
- // dragComplete: () => {},
- // dragStart: () => {}
- // }
- // })
- // }
+ const that = this;
+ if(this._mainCont.current) {
+ DragManager.MakeDraggable(this._mainCont.current, {
+ buttons: 2,
+ handlers: {
+ dragComplete: () => {},
+ dragStart: (e: DragManager.DragStartEvent) => {
+ if(!this.props.ContainingCollectionView) {
+ e.cancel();
+ return;
+ }
+ const rect = this.screenRect;
+ e.data["document"] = this;
+ e.data["xOffset"] = e.x - rect.left;
+ e.data["yOffset"] = e.y - rect.top;
+ }
+ }
+ })
+ }
}
@computed
@@ -147,8 +155,8 @@ export class DocumentView extends React.Component<IProps> {
this._lastX = e.pageX;
this._lastY = e.pageY;
this._contextMenuCanOpen = e.button == 2;
- document.removeEventListener("pointermove", this.onPointerMove);
- document.addEventListener("pointermove", this.onPointerMove);
+ // document.removeEventListener("pointermove", this.onPointerMove);
+ // document.addEventListener("pointermove", this.onPointerMove);
document.removeEventListener("pointerup", this.onPointerUp);
document.addEventListener("pointerup", this.onPointerUp);
}
@@ -238,7 +246,7 @@ export class DocumentView extends React.Component<IProps> {
onContextMenu={this.onContextMenu}
onPointerDown={this.onPointerDown}
onClick={this.onClick}>
- <DocumentContents {...this.props} />
+ <DocumentContents {...this.props} ContainingDocumentView={this} />
</div>
);
}