aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2019-02-12 21:08:04 -0500
committerbobzel <zzzman@gmail.com>2019-02-12 21:08:04 -0500
commite09ddf280d0e2bdef28477a6d7be06c57051dab6 (patch)
tree34843e07ff2fbcae30c9a534b3beb4e89590dca4 /src/client/views/nodes/CollectionFreeFormDocumentView.tsx
parent7a93f60c9529e5d175e617fc7c07145a9b33e572 (diff)
fixed up nested selections and scaling
Diffstat (limited to 'src/client/views/nodes/CollectionFreeFormDocumentView.tsx')
-rw-r--r--src/client/views/nodes/CollectionFreeFormDocumentView.tsx47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index 9cd42a069..7a895dd60 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -11,6 +11,7 @@ import "./NodeView.scss";
import React = require("react");
import { DocumentView, DocumentViewProps } from "./DocumentView";
import { Transform } from "../../util/Transform";
+import { COLLECTION_BORDER_WIDTH } from '../../views/collections/CollectionViewBase';
@observer
@@ -30,27 +31,17 @@ export class CollectionFreeFormDocumentView extends DocumentView {
return new DOMRect();
}
- @computed
- get x(): number {
- return this.props.Document.GetData(KeyStore.X, NumberField, Number(0));
- }
-
- @computed
- get y(): number {
- return this.props.Document.GetData(KeyStore.Y, NumberField, Number(0));
+ public LeftCorner(): number {
+ return this.props.Document.GetNumber(KeyStore.X, 0) + super.LeftCorner();
}
- set x(x: number) {
- this.props.Document.SetData(KeyStore.X, x, NumberField)
- }
-
- set y(y: number) {
- this.props.Document.SetData(KeyStore.Y, y, NumberField)
+ public TopCorner(): number {
+ return this.props.Document.GetNumber(KeyStore.Y, 0) + super.TopCorner();
}
@computed
get transform(): string {
- return `scale(${this.props.Scaling}, ${this.props.Scaling}) translate(${this.x}px, ${this.y}px)`;
+ return `scale(${this.props.ParentScaling}, ${this.props.ParentScaling}) translate(${this.props.Document.GetNumber(KeyStore.X, 0)}px, ${this.props.Document.GetNumber(KeyStore.Y, 0)}px)`;
}
@computed
@@ -221,24 +212,26 @@ export class CollectionFreeFormDocumentView extends DocumentView {
}
getTransform = (): Transform => {
- return this.props.GetTransform().translated(this.x, this.y);
+ return this.props.GetTransform().translated(this.props.Document.GetNumber(KeyStore.X, 0), this.props.Document.GetNumber(KeyStore.Y, 0));
}
render() {
var freestyling = this.props.ContainingCollectionView instanceof CollectionFreeFormView;
+ var parentScaling = this.nativeWidth > 0 ? this.width / this.nativeWidth : 1;
return (
- <div className="node" ref={this._mainCont} style={{
- transformOrigin: "left top",
- transform: freestyling ? this.transform : "",
- width: freestyling ? this.width : "100%",
- height: freestyling ? this.height : "100%",
- position: freestyling ? "absolute" : "relative",
- zIndex: freestyling ? this.zIndex : 0,
- }}
+ <div className="node" ref={this._mainCont}
onContextMenu={this.onContextMenu}
- onPointerDown={this.onPointerDown}>
-
- <DocumentView {...this.props} Scaling={this.width / this.nativeWidth} GetTransform={this.getTransform} DocumentView={this} />
+ onPointerDown={this.onPointerDown}
+ style={{
+ transformOrigin: "left top",
+ transform: freestyling ? this.transform : "",
+ width: freestyling ? this.width : "100%",
+ height: freestyling ? this.height : "100%",
+ position: freestyling ? "absolute" : "relative",
+ zIndex: freestyling ? this.zIndex : 0,
+ }}>
+
+ <DocumentView {...this.props} ref={this._renderDoc} ParentScaling={parentScaling} GetTransform={this.getTransform} DocumentView={this} />
</div>
);
}