aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/DragManager.ts
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-07-11 12:36:34 -0400
committeryipstanley <stanley_yip@brown.edu>2019-07-11 12:36:34 -0400
commita69a43015ec414bd1a9577c03fbeb5c3b27fb55f (patch)
tree45c5e3ed0d00b88df7940f77269a14901b964d23 /src/client/util/DragManager.ts
parentb1b69f8a4f9e34f0c8e667ec95f9fe16ebc8b2e4 (diff)
fixes
Diffstat (limited to 'src/client/util/DragManager.ts')
-rw-r--r--src/client/util/DragManager.ts35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index cb71db2c5..8e44631a3 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -61,16 +61,18 @@ export function SetupDrag(
export async function DragLinkAsDocument(dragEle: HTMLElement, x: number, y: number, linkDoc: Doc, sourceDoc: Doc) {
let draggeddoc = LinkManager.Instance.getOppositeAnchor(linkDoc, sourceDoc);
- let moddrag = await Cast(draggeddoc.annotationOn, Doc);
- let dragdocs = moddrag ? [moddrag] : [draggeddoc];
- let dragData = new DragManager.DocumentDragData(dragdocs, dragdocs);
- dragData.dropAction = "alias" as dropActionType;
- DragManager.StartLinkedDocumentDrag([dragEle], sourceDoc, dragData, x, y, {
- handlers: {
- dragComplete: action(emptyFunction),
- },
- hideSource: false
- });
+ if (draggeddoc) {
+ let moddrag = await Cast(draggeddoc.annotationOn, Doc);
+ let dragdocs = moddrag ? [moddrag] : [draggeddoc];
+ let dragData = new DragManager.DocumentDragData(dragdocs, dragdocs);
+ dragData.dropAction = "alias" as dropActionType;
+ DragManager.StartLinkedDocumentDrag([dragEle], sourceDoc, dragData, x, y, {
+ handlers: {
+ dragComplete: action(emptyFunction),
+ },
+ hideSource: false
+ });
+ }
}
export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: number, sourceDoc: Doc) {
@@ -80,9 +82,16 @@ export async function DragLinksAsDocuments(dragEle: HTMLElement, x: number, y: n
if (srcTarg) {
let linkDocs = LinkManager.Instance.getAllRelatedLinks(srcTarg);
if (linkDocs) {
- draggedDocs = linkDocs.map(link => {
- return LinkManager.Instance.getOppositeAnchor(link, sourceDoc);
- });
+ linkDocs.forEach((doc) => {
+ let opp = LinkManager.Instance.getOppositeAnchor(doc, sourceDoc);
+ if (opp) {
+ draggedDocs.push(opp);
+ }
+ }
+ )
+ // draggedDocs = linkDocs.map(link => {
+ // return LinkManager.Instance.getOppositeAnchor(link, sourceDoc);
+ // });
}
}
if (draggedDocs.length) {