Skip to content

Commit

Permalink
aborted flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Nov 21, 2023
1 parent 02a0a2d commit eeaabac
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/EventTypeDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export type TModificationEvents =

export interface ModifiedEvent<E extends Event = TPointerEvent> {
e?: E;
aborted: boolean;
transform: Transform;
target: FabricObject;
action: string;
Expand Down
2 changes: 1 addition & 1 deletion src/canvas/Canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions src/canvas/SelectableCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Point } from '../Point';
import { FabricObject } from '../shapes/Object/FabricObject';
import type {
CanvasEvents,
ModifiedEvent,
ModifierKey,
TOptionalModifierKey,
TPointerEvent,
Expand Down Expand Up @@ -650,16 +651,18 @@ export class SelectableCanvas<EventSpec extends CanvasEvents = CanvasEvents>
/**
* @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,
Expand Down Expand Up @@ -1206,7 +1209,7 @@ export class SelectableCanvas<EventSpec extends CanvasEvents = CanvasEvents>
resetObjectTransform(this._activeSelection);
}
if (this._currentTransform && this._currentTransform.target === obj) {
this.endCurrentTransform(e);
this.endCurrentTransform(e, true);
}
this._activeObject = undefined;
return true;
Expand Down

0 comments on commit eeaabac

Please sign in to comment.