diff options
| author | bobzel <zzzman@gmail.com> | 2020-10-15 15:29:18 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2020-10-15 15:29:18 -0400 |
| commit | 9ebb6c94f35c7d53b0bb4e9842784e99d3b28c07 (patch) | |
| tree | 5c042f6b0788163764e001188015aecc128c499c /src/client/views/presentationview/PresElementBox.tsx | |
| parent | f1ee3a6baffb22093d81e123d70f6ec9631c2075 (diff) | |
| parent | 377d5c987728c2678ab38565328f1f7ad9f3d135 (diff) | |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/views/presentationview/PresElementBox.tsx')
| -rw-r--r-- | src/client/views/presentationview/PresElementBox.tsx | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx index 1d6721bca..56a1cd116 100644 --- a/src/client/views/presentationview/PresElementBox.tsx +++ b/src/client/views/presentationview/PresElementBox.tsx @@ -189,20 +189,18 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps, PresDoc } onPointerMove = (e: PointerEvent) => { - const slide = this._itemRef.current; - if (slide) { + const slide = this._itemRef.current!; + if (slide && DragManager.docsBeingDragged.length > 0) { const rect = slide.getBoundingClientRect(); - const y = e.clientY - rect.top; //y position within the element. - const height = slide.clientHeight; - const halfLine = height / 2; - if (DragManager.docsBeingDragged.length) { - if (y <= halfLine) { - slide.style.borderTop = "solid 2px #5B9FDD"; - slide.style.borderBottom = "0px"; - } else if (y > halfLine) { - slide.style.borderTop = "0px"; - slide.style.borderBottom = "solid 2px #5B9FDD"; - } + let y = e.clientY - rect.top; //y position within the element. + let height = slide.clientHeight; + let halfLine = height / 2; + if (y <= halfLine) { + slide.style.borderTop = "solid 2px #5B9FDD"; + slide.style.borderBottom = "0px"; + } else if (y > halfLine) { + slide.style.borderTop = "0px"; + slide.style.borderBottom = "solid 2px #5B9FDD"; } } document.removeEventListener("pointermove", this.onPointerMove); @@ -244,6 +242,23 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps, PresDoc PresBox.Instance._dragArray.push(this._dragRef.current!); } + @undoBatch + @action + pinWithView = (targetDoc: Doc, activeItem: Doc) => { + console.log(targetDoc.type); + if (targetDoc.type === DocumentType.PDF || targetDoc.type === DocumentType.WEB || targetDoc.type === DocumentType.RTF) { + const scroll = targetDoc._scrollTop; + activeItem.presPinViewScroll = scroll; + } else { + const x = targetDoc._panX; + const y = targetDoc._panY; + const scale = targetDoc._viewScale; + activeItem.presPinViewX = x; + activeItem.presPinViewY = y; + activeItem.presPinViewScale = scale; + } + } + @computed get mainItem() { const isSelected: boolean = PresBox.Instance._selectedArray.includes(this.rootDoc); const toolbarWidth: number = PresBox.Instance.toolbarWidth; @@ -301,14 +316,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps, PresDoc <div className={"presItem-slideButtons"}> <Tooltip title={<><div className="dash-tooltip">{"Update view"}</div></>}> <div className="slideButton" - onClick={e => { - const x = targetDoc._panX; - const y = targetDoc._panY; - const scale = targetDoc._viewScale; - activeItem.presPinViewX = x; - activeItem.presPinViewY = y; - activeItem.presPinViewScale = scale; - }} + onClick={() => this.pinWithView(targetDoc, activeItem)} style={{ fontWeight: 700, display: activeItem.presPinView ? "flex" : "none" }}>V</div> </Tooltip> <Tooltip title={<><div className="dash-tooltip">{this.rootDoc.presExpandInlineButton ? "Minimize" : "Expand"}</div></>}><div className={"slideButton"} onClick={e => { e.stopPropagation(); this.presExpandDocumentClick(); }}> @@ -322,7 +330,7 @@ export class PresElementBox extends ViewBoxBaseComponent<FieldViewProps, PresDoc </div> {this.renderEmbeddedInline} </div> - </div>); + </div >); } render() { |
