Skip to content

Commit

Permalink
feat(fabric.Canvas): fire an extra mouse up for the original control …
Browse files Browse the repository at this point in the history
…of the initial target (fabricjs#7612)
  • Loading branch information
asturur authored and rockerBOO committed Jan 28, 2022
1 parent 8436279 commit 5615237
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/canvas.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
* @fires dragover
* @fires dragenter
* @fires dragleave
* @fires drop:before before drop event. same native event. This is added to handle edge cases
* @fires drop
* @fires after:render at the end of the render process, receives the context in the callback
* @fires before:render at start the render process, receives the context in the callback
Expand Down
19 changes: 14 additions & 5 deletions src/mixins/canvas_events.mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,25 +462,34 @@
);
}
}
var corner, pointer;
if (target) {
corner = target._findTargetCorner(
this.getPointer(e, true),
fabric.util.isTouchEvent(e)
);
if (target.selectable && target !== this._activeObject && target.activeOn === 'up') {
this.setActiveObject(target, e);
shouldRender = true;
}
else {
var corner = target._findTargetCorner(
this.getPointer(e, true),
fabric.util.isTouchEvent(e)
);
var control = target.controls[corner],
mouseUpHandler = control && control.getMouseUpHandler(e, target, control);
if (mouseUpHandler) {
var pointer = this.getPointer(e);
pointer = this.getPointer(e);
mouseUpHandler(e, transform, pointer.x, pointer.y);
}
}
target.isMoving = false;
}
// if we are ending up a transform on a different control or a new object
// fire the original mouse up from the corner that started the transform
if (transform && (transform.target !== target || transform.corner !== corner)) {
var originalControl = transform.target && transform.target.controls[transform.corner],
originalMouseUpHandler = originalControl && originalControl.getMouseUpHandler(e, target, control);
pointer = pointer || this.getPointer(e);
originalMouseUpHandler && originalMouseUpHandler(e, transform, pointer.x, pointer.y);
}
this._setCursorFromEvent(e, target);
this._handleEvent(e, 'up', LEFT_CLICK, isClick);
this._groupSelector = null;
Expand Down

0 comments on commit 5615237

Please sign in to comment.