From 5a9653ef22ba81226f1bc7fe4de14d3edced73e0 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 30 Sep 2020 18:53:14 -0400 Subject: added restriction of link lines to stay mostly in their container intstead of dangling in space. --- .../CollectionFreeFormLinkView.tsx | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx index 011e10b88..8e01d9357 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx @@ -26,7 +26,7 @@ export class CollectionFreeFormLinkView extends React.Component (Date.now() < this._start++ + 1000) && setTimeout(this.timeout, 25) + timeout = action(() => (Date.now() < this._start++ + 1000) && (this._timeout = setTimeout(this.timeout, 25))) componentDidMount() { this._anchorDisposer = reaction(() => [this.props.A.props.ScreenToLocalTransform(), this.props.B.props.ScreenToLocalTransform(), this.props.A.isSelected() || Doc.IsBrushed(this.props.A.props.Document), this.props.A.isSelected() || Doc.IsBrushed(this.props.A.props.Document)], action(() => { @@ -113,7 +113,7 @@ export class CollectionFreeFormLinkView extends React.Component { + let rect = el.getBoundingClientRect(); + const left = rect.left, width = rect.width; + var el = el.parentNode; + do { + rect = el.getBoundingClientRect(); + if (left <= rect.right === false && getComputedStyle(el).overflow === "hidden") return rect.right; + // Check if the element is out of view due to a container scrolling + if ((left + width) <= rect.left && getComputedStyle(el).overflow === "hidden") return rect.left; + el = el.parentNode; + } while (el !== document.body); + // Check its within the document viewport + return left; //top <= document.documentElement.clientHeight && getComputedStyle(document.documentElement).overflow === "hidden"; + } @computed.struct get renderData() { this._start; SnappingManager.GetIsDragging(); @@ -138,16 +152,18 @@ export class CollectionFreeFormLinkView extends React.Component - + {textX === undefined ? (null) : {StrCast(this.props.LinkDocs[0].description)} - + } ); } } \ No newline at end of file -- cgit v1.2.3-70-g09d2