aboutsummaryrefslogtreecommitdiff
path: root/src/client/views
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views')
-rw-r--r--src/client/views/TemplateMenu.tsx41
-rw-r--r--src/client/views/nodes/CollectionFreeFormDocumentView.tsx1
-rw-r--r--src/client/views/nodes/DocumentView.tsx2
3 files changed, 20 insertions, 24 deletions
diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index e6116ca09..8d9dc4cf7 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -63,31 +63,24 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> {
SelectionManager.DeselectAll();
const topDocView = this.props.docs[0];
const topDoc = topDocView.props.Document;
- const xf = topDocView.props.ScreenToLocalTransform();
- const ex = e.target.clientLeft;
- const ey = e.target.clientTop;
+ const ex = e.target.getBoundingClientRect().left;
+ const ey = e.target.getBoundingClientRect().top;
+ const de = new DragManager.DocumentDragData([topDoc]);
+ de.dragDivName = topDocView.props.dragDivName;
+ de.moveDocument = topDocView.props.moveDocument;
undoBatch(action(() => topDoc.z = topDoc.z ? 0 : 1))();
- if (e.target.checked) {
- setTimeout(() => {
- const newDocView = DocumentManager.Instance.getDocumentView(topDoc);
- if (newDocView) {
- const de = new DragManager.DocumentDragData([topDoc]);
- de.moveDocument = topDocView.props.moveDocument;
- const xf = newDocView.ContentDiv!.getBoundingClientRect();
- DragManager.StartDocumentDrag([newDocView.ContentDiv!], de, ex, ey, {
- offsetX: (ex - xf.left), offsetY: (ey - xf.top),
- handlers: { dragComplete: () => { }, },
- hideSource: false
- });
- }
- }, 10);
- } else if (topDocView.props.ContainingCollectionView) {
- const collView = topDocView.props.ContainingCollectionView;
- const [sx, sy] = xf.inverse().transformPoint(0, 0);
- const [x, y] = collView.props.ScreenToLocalTransform().transformPoint(sx, sy);
- topDoc.x = x;
- topDoc.y = y;
- }
+ setTimeout(() => {
+ const newDocView = DocumentManager.Instance.getDocumentView(topDoc);
+ if (newDocView) {
+ const contentDiv = newDocView.ContentDiv!;
+ const xf = contentDiv.getBoundingClientRect();
+ DragManager.StartDocumentDrag([contentDiv], de, ex, ey, {
+ offsetX: ex - xf.left, offsetY: ey - xf.top,
+ handlers: { dragComplete: () => { }, },
+ hideSource: true
+ });
+ }
+ }, 0);
}
@undoBatch
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index d599de56e..261a88deb 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -104,6 +104,7 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF
zIndex: this.Document.zIndex || 0,
}} >
<DocumentView {...this.props}
+ dragDivName={"collectionFreeFormDocumentView-container"}
ContentScaling={this.contentScaling}
ScreenToLocalTransform={this.getTransform}
backgroundColor={this.clusterColorFunc}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 11c012252..1b2d92027 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -57,6 +57,7 @@ export interface DocumentViewProps {
LibraryPath: Doc[];
fitToBox?: boolean;
onClick?: ScriptField;
+ dragDivName?: string;
addDocument?: (doc: Doc) => boolean;
removeDocument?: (doc: Doc) => boolean;
moveDocument?: (doc: Doc, targetCollection: Doc, addDocument: (document: Doc) => boolean) => boolean;
@@ -130,6 +131,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
dragData.dropAction = dropAction;
dragData.moveDocument = this.Document.onDragStart ? undefined : this.props.moveDocument;
dragData.applyAsTemplate = applyAsTemplate;
+ dragData.dragDivName = this.props.dragDivName;
DragManager.StartDocumentDrag([this._mainCont.current], dragData, x, y, {
handlers: {
dragComplete: action((emptyFunction))