diff options
author | bobzel <zzzman@gmail.com> | 2024-04-03 17:24:12 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-04-03 17:24:12 -0400 |
commit | 6116b92bcd7da32d206383160562d6d9abf895f8 (patch) | |
tree | 87e9e1c36bb3e696262f029d1d2e8d69bdd81e0d | |
parent | e9769026573e66a45977b156338aa939287db65a (diff) |
fixed resizing from corners to snap properly
-rw-r--r-- | src/client/views/DocumentDecorations.tsx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx index 9e469ed1f..d7b89be4a 100644 --- a/src/client/views/DocumentDecorations.tsx +++ b/src/client/views/DocumentDecorations.tsx @@ -426,9 +426,10 @@ export class DocumentDecorations extends ObservableReactComponent<DocumentDecora SnappingManager.SetIsResizing(SelectionManager.Docs.lastElement()); // turns off pointer events on things like youtube videos and web pages so that dragging doesn't get "stuck" when cursor moves over them setupMoveUpEvents(this, e, this.onPointerMove, this.onPointerUp, emptyFunction); e.stopPropagation(); - this._resizeHdlId = e.currentTarget.className; + const id = (this._resizeHdlId = e.currentTarget.className); + const pad = id.includes('Left') || id.includes('Right') ? Number(getComputedStyle(e.target as any).width.replace('px', '')) / 2 : 0; const bounds = e.currentTarget.getBoundingClientRect(); - this._offset = { x: this._resizeHdlId.toLowerCase().includes('left') ? bounds.right - e.clientX : bounds.left - e.clientX, y: this._resizeHdlId.toLowerCase().includes('top') ? bounds.bottom - e.clientY : bounds.top - e.clientY }; + this._offset = { x: id.toLowerCase().includes('left') ? bounds.right - e.clientX - pad : bounds.left - e.clientX + pad, y: this._resizeHdlId.toLowerCase().includes('top') ? bounds.bottom - e.clientY - pad : bounds.top - e.clientY + pad }; this._resizeUndo = UndoManager.StartBatch('drag resizing'); this._snapPt = { x: e.pageX, y: e.pageY }; SelectionManager.Views.forEach(docView => docView.CollectionFreeFormView?.dragStarting(false, false)); |