diff options
| author | bobzel <zzzman@gmail.com> | 2021-03-25 23:52:33 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2021-03-25 23:52:33 -0400 |
| commit | 7878bc22a6dec8bff17f38aa3ffad897babb9e16 (patch) | |
| tree | 1dbf8138ee2e4e420a0b96f247270ff7d6b75810 /src/client/views/DocumentDecorations.tsx | |
| parent | baa2152a35bac6e0a18ff916817af9bb566a549f (diff) | |
cleaned up dragmanager a bit and fixed issues with document shifting on drop when dragged via DocDecorations and
Diffstat (limited to 'src/client/views/DocumentDecorations.tsx')
| -rw-r--r-- | src/client/views/DocumentDecorations.tsx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 50065c17a..da50ba4d8 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -94,7 +94,7 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b setupMoveUpEvents(this, e, e => this.onBackgroundMove(true, e), (e) => { }, action((e) => { !this._edtingTitle && (this._accumulatedTitle = this._titleControlString.startsWith("#") ? this.selectionTitle : this._titleControlString); this._edtingTitle = true; - setTimeout(() => this._keyinput.current!.focus(), 0); + this._keyinput.current && setTimeout(this._keyinput.current!.focus); })); } @@ -103,13 +103,12 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b @action onBackgroundMove = (dragTitle: boolean, e: PointerEvent): boolean => { const dragDocView = SelectionManager.Views()[0]; - const dragData = new DragManager.DocumentDragData(SelectionManager.Views().map(dv => dv.props.Document)); const { left, top } = dragDocView.getBounds() || { left: 0, top: 0 }; - dragData.offset = dragDocView.props.ScreenToLocalTransform().scale(dragDocView.ContentScale()).transformDirection(e.x - left, e.y - top); + const dragData = new DragManager.DocumentDragData(SelectionManager.Views().map(dv => dv.props.Document), dragDocView.props.dropAction); + dragData.offset = dragDocView.props.ScreenToLocalTransform().transformDirection(e.x - left, e.y - top); dragData.moveDocument = dragDocView.props.moveDocument; dragData.isSelectionMove = true; dragData.canEmbed = dragTitle; - dragData.dropAction = dragDocView.props.dropAction; this._hidden = this.Interacting = true; DragManager.StartDocumentDrag(SelectionManager.Views().map(dv => dv.ContentDiv!), dragData, e.x, e.y, { dragComplete: action(e => { @@ -228,7 +227,7 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b onPointerMove = (e: PointerEvent, down: number[], move: number[]): boolean => { const first = SelectionManager.Views()[0]; - let thisPt = { thisX: e.clientX - this._offX, thisY: e.clientY - this._offY }; + let thisPt = { x: e.clientX - this._offX, y: e.clientY - this._offY }; var fixedAspect = Doc.NativeAspect(first.layoutDoc); InkStrokeProperties.Instance?._lock && SelectionManager.Views().filter(dv => dv.rootDoc.type === DocumentType.INK) .forEach(dv => fixedAspect = Doc.NativeAspect(dv.rootDoc)); @@ -250,10 +249,10 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b thisPt = DragManager.snapDrag(e, -this._offX, -this._offY, this._offX, this._offY); } - move[0] = thisPt.thisX - this._snapX; - move[1] = thisPt.thisY - this._snapY; - this._snapX = thisPt.thisX; - this._snapY = thisPt.thisY; + move[0] = thisPt.x - this._snapX; + move[1] = thisPt.y - this._snapY; + this._snapX = thisPt.x; + this._snapY = thisPt.y; let dragBottom = false, dragRight = false, dragBotRight = false; let dX = 0, dY = 0, dW = 0, dH = 0; switch (this._resizeHdlId) { |
