Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions web/libs/editor/src/components/KonvaVector/KonvaVector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,8 @@ export const KonvaVector = forwardRef<KonvaVectorRef, KonvaVectorProps>((props,
disabled,
transformMode,
disableInternalPointAddition,
handleTransformStart,
handleTransformEnd,
pointCreationManager,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ export function createMouseDownHandler(props: EventHandlerProps, handledSelectio
controlIndex: 1,
});
props.isDragging.current = true;
// Fire transform start event when control point dragging begins
props.handleTransformStart?.();
props.lastPos.current = {
x: e.evt.clientX,
y: e.evt.clientY,
Expand All @@ -233,6 +235,8 @@ export function createMouseDownHandler(props: EventHandlerProps, handledSelectio
controlIndex: 2,
});
props.isDragging.current = true;
// Fire transform start event when control point dragging begins
props.handleTransformStart?.();
props.lastPos.current = {
x: e.evt.clientX,
y: e.evt.clientY,
Expand Down Expand Up @@ -448,6 +452,8 @@ export function createMouseMoveHandler(props: EventHandlerProps, handledSelectio
// If we haven't started dragging yet, check if we should start
if (!props.isDragging.current && (mouseDeltaX > dragThreshold || mouseDeltaY > dragThreshold)) {
props.isDragging.current = true;
// Fire transform start event when point dragging begins
props.handleTransformStart?.();
}

// Only proceed with dragging if we're actually dragging
Expand Down Expand Up @@ -775,6 +781,13 @@ export function createMouseUpHandler(props: EventHandlerProps) {
}
}

// Fire transform end event if we were dragging (point or control point)
const wasDragging =
props.isDragging.current || props.draggedPointIndex !== null || props.draggedControlPoint !== null;
if (wasDragging) {
props.handleTransformEnd?.(e);
}

// Reset dragging state
props.isDragging.current = false;
props.setDraggedPointIndex(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export interface EventHandlerProps {
disabled?: boolean;
transformMode?: boolean;
disableInternalPointAddition?: boolean;
handleTransformStart?: () => void;
handleTransformEnd?: (e?: KonvaEventObject<MouseEvent>) => void;
pointCreationManager?: {
isCreating: () => boolean;
createRegularPointAt: (x: number, y: number, prevPointId?: string) => boolean;
Expand Down
3 changes: 3 additions & 0 deletions web/libs/editor/src/tools/Vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ const _Tool = types

const currentArea = area && isAlive(area) ? area : null;

self.annotation.history.freeze();

// Only create new region if we don't have an existing one
if (!currentArea) {
self.currentArea = self.createRegion(self.createRegionOptions(), true);
Expand Down Expand Up @@ -318,6 +320,7 @@ const _Tool = types
// skipping a frame to let KonvaVector render and update properly
setTimeout(() => {
self.currentArea?.commitPoint?.(rx, ry);
self.annotation.history.unfreeze();
self.finishDrawing();
});
},
Expand Down
Loading