aboutsummaryrefslogtreecommitdiff
path: root/src/views/nodes/DocumentView.tsx
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-01-29 12:20:13 -0500
committerbob <bcz@cs.brown.edu>2019-01-29 12:20:13 -0500
commited982a553d1831353e312ae8137afa95ef84ebe5 (patch)
tree6a6510f1cfe9aaa0bef3ae071eebeb63592bb1e0 /src/views/nodes/DocumentView.tsx
parent0402105238f24785a1229dbbb37f2e4dba958f88 (diff)
semi working docking, but zooming is now broken.
Diffstat (limited to 'src/views/nodes/DocumentView.tsx')
-rw-r--r--src/views/nodes/DocumentView.tsx19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index 3ee70213f..517d691f9 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -15,6 +15,7 @@ import { DocumentDecorations } from "../../DocumentDecorations";
import { ContextMenu } from "../ContextMenu";
import { Opt } from "../../fields/Field";
import { DragManager } from "../../util/DragManager";
+import { number } from "prop-types";
const JsxParser = require('react-jsx-parser').default;//TODO Why does this need to be imported like this?
interface DocumentViewProps {
@@ -193,14 +194,16 @@ export class DocumentView extends React.Component<DocumentViewProps> {
//
// Converts a point in the coordinate space of a document to a screen space coordinate.
//
- public TransformToScreenPoint(localX: number, localY: number, Ss: number = 1, Panxx: number = 0, Panyy: number = 0): { ScreenX: number, ScreenY: number } {
-
+ public TransformToScreenPoint(localX: number, localY: number, Ss: number = 1, Panxx: number = 0, Panyy: number = 0): { ScreenX: Opt<number>, ScreenY: Opt<number> } {
+ if (this.props.ContainingCollectionView != undefined && !(this.props.ContainingCollectionView instanceof CollectionFreeFormView)) {
+ return { ScreenX: undefined, ScreenY: undefined };
+ }
let W = this.props.Document.GetFieldValue(KeyStore.Width, NumberField, Number(0));
let H = CollectionFreeFormView.BORDER_WIDTH;
let Xx = this.props.Document.GetFieldValue(KeyStore.X, NumberField, Number(0));
let Yy = this.props.Document.GetFieldValue(KeyStore.Y, NumberField, Number(0));
- let parentX = (localX - W / 2) * Ss + (Xx + Panxx) + W / 2;
- let parentY = (localY - H) * Ss + (Yy + Panyy) + H;
+ let parentX: Opt<number> = (localX - W / 2) * Ss + (Xx + Panxx) + W / 2;
+ let parentY: Opt<number> = (localY - H) * Ss + (Yy + Panyy) + H;
// if this collection view is nested within another collection view, then
// first transform the local point into the parent collection's coordinate space.
@@ -295,11 +298,12 @@ export class DocumentView extends React.Component<DocumentViewProps> {
}
render() {
+ let freeStyling = this.props.ContainingCollectionView instanceof CollectionFreeFormView;
return (
<div className="node" ref={this._mainCont} style={{
- transform: this.transform,
- width: this.width,
- height: this.height,
+ transform: freeStyling ? this.transform : "",
+ width: freeStyling ? this.width : "100%",
+ height: freeStyling ? this.height : "100%",
}}
onContextMenu={this.onContextMenu}
onPointerDown={this.onPointerDown}>
@@ -307,5 +311,4 @@ export class DocumentView extends React.Component<DocumentViewProps> {
</div>
);
}
-
} \ No newline at end of file