aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx12
-rw-r--r--src/client/views/collections/CollectionViewBase.tsx16
2 files changed, 23 insertions, 5 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index 95b4f6f19..ea00ce751 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -59,17 +59,23 @@ export class CollectionFreeFormView extends CollectionViewBase {
drop = (e: Event, de: DragManager.DropEvent) => {
super.drop(e, de);
+ let screenX = de.x - (de.data["xOffset"] as number || 0);
+ let screenY = de.y - (de.data["yOffset"] as number || 0);
+ const [x, y] = this.getTransform().transformPoint(screenX, screenY);
if (!de.data["alias"]) {
const docView: DocumentView = de.data["documentView"];
const doc = docView ? docView.props.Document : de.data["document"]
//this should be able to use translate and scale methods on an Identity transform, no?
- let screenX = de.x - (de.data["xOffset"] as number || 0);
- let screenY = de.y - (de.data["yOffset"] as number || 0);
- const [x, y] = this.getTransform().transformPoint(screenX, screenY);
doc.SetNumber(KeyStore.X, x);
doc.SetNumber(KeyStore.Y, y);
this.bringToFront(doc);
}
+ else {
+ let newDoc: Document = de.data["newDoc"]
+ newDoc.SetNumber(KeyStore.X, x)
+ newDoc.SetNumber(KeyStore.Y, y)
+ this.bringToFront(newDoc)
+ }
}
@action
diff --git a/src/client/views/collections/CollectionViewBase.tsx b/src/client/views/collections/CollectionViewBase.tsx
index f3770056d..a662447cf 100644
--- a/src/client/views/collections/CollectionViewBase.tsx
+++ b/src/client/views/collections/CollectionViewBase.tsx
@@ -3,7 +3,7 @@ import { Document } from "../../../fields/Document";
import { ListField } from "../../../fields/ListField";
import React = require("react");
import { KeyStore } from "../../../fields/KeyStore";
-import { FieldWaiting } from "../../../fields/Field";
+import { FieldWaiting, Field } from "../../../fields/Field";
import { undoBatch } from "../../util/UndoManager";
import { DragManager } from "../../util/DragManager";
import { DocumentView } from "../nodes/DocumentView";
@@ -47,11 +47,23 @@ export class CollectionViewBase extends React.Component<SubCollectionViewProps>
protected drop(e: Event, de: DragManager.DropEvent) {
const docView: DocumentView = de.data["documentView"];
const doc: Document = de.data["document"]
+ if (de.data["alias"]) {
+ let newDoc = docView ? docView.props.Document.CreateAlias() : doc.CreateAlias()
+ de.data["newDoc"] = newDoc
+ let oldDoc = docView ? docView.props.Document : doc
+ oldDoc.GetAsync(KeyStore.Width, (f: Field) => {
+ newDoc.Set(KeyStore.Width, f)
+ })
+ oldDoc.GetAsync(KeyStore.Height, (f: Field) => {
+ newDoc.Set(KeyStore.Height, f)
+ })
+ }
+
if (docView && docView.props.ContainingCollectionView && docView.props.ContainingCollectionView !== this.props.CollectionView) {
if (docView.props.RemoveDocument && !de.data["alias"]) {
docView.props.RemoveDocument(docView.props.Document)
}
- this.props.addDocument(de.data["alias"] ? docView.props.Document.CreateAlias() : docView.props.Document)
+ this.props.addDocument(de.data["alias"] ? de.data["newDoc"] : docView.props.Document)
} else if (doc) {
if (!de.data["alias"]) {
this.props.removeDocument(doc)