From 1632540870c4a46be31a2ae949714296e8403383 Mon Sep 17 00:00:00 2001 From: Melissa Zhang Date: Thu, 6 Aug 2020 13:04:43 -0700 Subject: fixed LinkMenu position so that list of links stay with doc when zooming --- src/client/views/MainView.tsx | 2 +- src/client/views/linking/LinkMenu.tsx | 23 +++++++++++++++-------- src/client/views/nodes/DocumentLinksButton.tsx | 4 ---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index 007d531c8..d03cb1bb2 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -790,7 +790,7 @@ export class MainView extends React.Component {
{LinkDescriptionPopup.descriptionPopup ? : null} - {DocumentLinksButton.EditLink ? : (null)} + {DocumentLinksButton.EditLink ? : (null)} {LinkDocPreview.LinkInfo ? : (null)} diff --git a/src/client/views/linking/LinkMenu.tsx b/src/client/views/linking/LinkMenu.tsx index 7b5fb0127..8023928a1 100644 --- a/src/client/views/linking/LinkMenu.tsx +++ b/src/client/views/linking/LinkMenu.tsx @@ -19,7 +19,6 @@ interface Props { docView: DocumentView; changeFlyout: () => void; addDocTab: (document: Doc, where: string) => boolean; - location: number[]; } @observer @@ -85,17 +84,25 @@ export class LinkMenu extends React.Component { return linkItems; } + @computed + get position() { + const docView = this.props.docView; + const transform = (docView.props.ScreenToLocalTransform().scale(docView.props.ContentScaling())).inverse(); + const [sptX, sptY] = transform.transformPoint(0, 0); + const [bptX, bptY] = transform.transformPoint(docView.props.PanelWidth(), docView.props.PanelHeight()); + return { x: sptX, y: sptY, r: bptX, b: bptY }; + } + render() { + console.log("computed", this.position.x, this.position.b); const sourceDoc = this.props.docView.props.Document; const groups: Map = LinkManager.Instance.getRelatedGroupedLinks(sourceDoc); return
- {!this._editingLink ?
- {this.renderAllGroups(groups)} -
:
+ {!this._editingLink ? +
+ {this.renderAllGroups(groups)} +
: +
this._editingLink = undefined)} />
diff --git a/src/client/views/nodes/DocumentLinksButton.tsx b/src/client/views/nodes/DocumentLinksButton.tsx index cb79e1522..c2f27c85a 100644 --- a/src/client/views/nodes/DocumentLinksButton.tsx +++ b/src/client/views/nodes/DocumentLinksButton.tsx @@ -74,7 +74,6 @@ export class DocumentLinksButton extends React.Component Doc.BrushDoc(this.props.View.Document)); } else if (!this.props.InMenu) { DocumentLinksButton.EditLink = this.props.View; - DocumentLinksButton.EditLinkLoc = [e.clientX + 10, e.clientY]; } } @@ -147,8 +145,6 @@ export class DocumentLinksButton extends React.Component