diff --git a/src/EventTypeDefs.ts b/src/EventTypeDefs.ts index 09c2ea90b1a..4c6e849ae0c 100644 --- a/src/EventTypeDefs.ts +++ b/src/EventTypeDefs.ts @@ -104,6 +104,7 @@ export type TModificationEvents = export interface ModifiedEvent { e?: E; + aborted: boolean; transform: Transform; target: FabricObject; action: string; diff --git a/src/canvas/Canvas.ts b/src/canvas/Canvas.ts index da9e296a50b..70ae003cdb2 100644 --- a/src/canvas/Canvas.ts +++ b/src/canvas/Canvas.ts @@ -795,7 +795,7 @@ export class Canvas extends SelectableCanvas implements CanvasOptions { } let shouldRender = false; if (transform) { - this.endCurrentTransform(e); + this.endCurrentTransform(e, false); shouldRender = transform.actionPerformed; } if (!isClick) { diff --git a/src/canvas/SelectableCanvas.ts b/src/canvas/SelectableCanvas.ts index 08bdb06c4ed..e12f15f6552 100644 --- a/src/canvas/SelectableCanvas.ts +++ b/src/canvas/SelectableCanvas.ts @@ -4,6 +4,7 @@ import { Point } from '../Point'; import { FabricObject } from '../shapes/Object/FabricObject'; import type { CanvasEvents, + ModifiedEvent, ModifierKey, TOptionalModifierKey, TPointerEvent, @@ -650,16 +651,18 @@ export class SelectableCanvas /** * @private * @param {Event} e send the mouse event that generate the finalize down, so it can be used in the event + * @param {boolean} aborted flag passed down to the `modified` event indicating if the interaction was aborted */ - endCurrentTransform(e?: TPointerEvent) { + endCurrentTransform(e?: TPointerEvent, aborted = true) { const transform = this._currentTransform; if (!transform) { return; } const { target, action, actionPerformed } = transform; - const options = { + const options: ModifiedEvent = { e, + aborted, target, transform, action, @@ -1206,7 +1209,7 @@ export class SelectableCanvas resetObjectTransform(this._activeSelection); } if (this._currentTransform && this._currentTransform.target === obj) { - this.endCurrentTransform(e); + this.endCurrentTransform(e, true); } this._activeObject = undefined; return true;