fix: add deletion to the history after backspace is pressed (#310)
* fix: add deletion to the history after BACKSPACE is pressed * Add updateBoundShapes too * fix bug on deleting bound shapes Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
This commit is contained in:
parent
6e72b78e91
commit
d5d999e86d
3 changed files with 12 additions and 7 deletions
|
@ -29,6 +29,9 @@ export function getBoundHandlePoint(
|
|||
// If the other handle is also bound to a shape, use that other shape's center instead
|
||||
// of the handle's actual point
|
||||
const otherToShape = data.page.shapes[oppositeBinding.toId]
|
||||
|
||||
if (!otherToShape) return
|
||||
|
||||
oppositePoint = getShapeUtils(otherToShape).getCenter(otherToShape)
|
||||
} else {
|
||||
oppositePoint = Vec.add(fromShape.point, oppositeHandle.point)
|
||||
|
|
|
@ -27,12 +27,14 @@ export const updateBoundShapes: Action = (data) => {
|
|||
const boundHandle = fromShape.handles[binding.handleId]
|
||||
const intersection = getBoundHandlePoint(data, fromShape, toShape, boundHandle.id)
|
||||
|
||||
if (!Vec.isEqual(boundHandle.point, intersection)) {
|
||||
boundHandle.point = Vec.sub(intersection, fromShape.point)
|
||||
const handles = Object.values(fromShape.handles)
|
||||
const offset = Utils.getCommonTopLeft(handles.map((handle) => handle.point))
|
||||
fromShape.point = Vec.add(fromShape.point, offset)
|
||||
handles.forEach((handle) => (handle.point = Vec.sub(handle.point, offset)))
|
||||
if (intersection) {
|
||||
if (!Vec.isEqual(boundHandle.point, intersection)) {
|
||||
boundHandle.point = Vec.sub(intersection, fromShape.point)
|
||||
const handles = Object.values(fromShape.handles)
|
||||
const offset = Utils.getCommonTopLeft(handles.map((handle) => handle.point))
|
||||
fromShape.point = Vec.add(fromShape.point, offset)
|
||||
handles.forEach((handle) => (handle.point = Vec.sub(handle.point, offset)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ export const machine = createState({
|
|||
SELECTED_ALL: 'selectAllShapes',
|
||||
DESELECTED_ALL: 'deselectAllShapes',
|
||||
CANCELLED: ['deselectAllShapes', 'updateBoundShapes'],
|
||||
DELETED: ['deleteSelectedShapes', 'updateBoundShapes'],
|
||||
DELETED: ['deleteSelectedShapes', 'updateBoundShapes', 'addToHistory'],
|
||||
UNDO: 'undo',
|
||||
REDO: 'redo',
|
||||
HOVERED_SHAPE: 'setHoveredShape',
|
||||
|
|
Loading…
Reference in a new issue