diff options
Diffstat (limited to 'src/views')
| -rw-r--r-- | src/views/collections/CollectionDockingView.tsx | 6 | ||||
| -rw-r--r-- | src/views/collections/CollectionFreeFormView.tsx | 18 | ||||
| -rw-r--r-- | src/views/nodes/DocumentView.tsx | 6 |
3 files changed, 11 insertions, 19 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx index b6fff6ba0..a59a40b33 100644 --- a/src/views/collections/CollectionDockingView.tsx +++ b/src/views/collections/CollectionDockingView.tsx @@ -132,13 +132,13 @@ export class CollectionDockingView extends React.Component<CollectionViewProps> console.log("Gettting " + component); const { fieldKey, Document: Document } = this.props; const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []); - if (component === "doc1") { + if (component === "doc1" && value.length > 0) { return (<DocumentView key={value[ 0 ].Id} ContainingCollectionView={this} Document={value[ 0 ]} ContainingDocumentView={this.props.ContainingDocumentView} />); } - if (component === "doc2") { + if (component === "doc2" && value.length > 1) { return (<DocumentView key={value[ 1 ].Id} ContainingCollectionView={this} Document={value[ 1 ]} ContainingDocumentView={this.props.ContainingDocumentView} />); } - if (component === "doc3") { + if (component === "doc3" && value.length > 2) { return (<DocumentView key={value[ 2 ].Id} ContainingCollectionView={this} Document={value[ 2 ]} ContainingDocumentView={this.props.ContainingDocumentView} />); } if (component === "text") { diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx index a1224f4da..c84b8e3e5 100644 --- a/src/views/collections/CollectionFreeFormView.tsx +++ b/src/views/collections/CollectionFreeFormView.tsx @@ -34,25 +34,17 @@ export class CollectionFreeFormView extends React.Component<CollectionViewProps> } drop = (e: Event, de: DragManager.DropEvent) => { - const ele = this._canvasRef.current; - if (!ele) { - return; - } const doc = de.data[ "document" ]; - const xOffset = de.data[ "xOffset" ] as number || 0; - const yOffset = de.data[ "yOffset" ] as number || 0; if (doc instanceof DocumentView) { if (doc.props.ContainingCollectionView && doc.props.ContainingCollectionView !== this) { doc.props.ContainingCollectionView.removeDocument(doc.props.Document); this.addDocument(doc.props.Document); } - const { scale, translateX, translateY } = Utils.GetScreenTransform(ele); - const screenX = de.x - xOffset; - const screenY = de.y - yOffset; - const docX = (screenX - translateX) / scale; - const docY = (screenY - translateY) / scale; - doc.x = docX; - doc.y = docY; + const xOffset = de.data[ "xOffset" ] as number || 0; + const yOffset = de.data[ "yOffset" ] as number || 0; + let { LocalX, LocalY } = this.props.ContainingDocumentView!.TransformToLocalPoint(de.x - xOffset, de.y - yOffset); + doc.x = LocalX; + doc.y = LocalY; } e.stopPropagation(); } diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx index 0df97d62a..5ce64b347 100644 --- a/src/views/nodes/DocumentView.tsx +++ b/src/views/nodes/DocumentView.tsx @@ -193,9 +193,9 @@ 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: Opt<number>, ScreenY: Opt<number> } { - if (this.props.ContainingCollectionView != undefined && !(this.props.ContainingCollectionView instanceof CollectionFreeFormView)) { - return { ScreenX: undefined, ScreenY: undefined }; - } + // if (this.props.ContainingCollectionView != undefined && !(this.props.ContainingCollectionView instanceof CollectionFreeFormView)) { + // return { ScreenX: undefined, ScreenY: undefined }; + // } let W = CollectionFreeFormView.BORDER_WIDTH; // 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)); |
