Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(): rm isClick artifacts leftovers from #9434 #9478

Merged
merged 9 commits into from
Nov 12, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- chore(): expose `sendVectorToPlane` [#9479](https://github.com/fabricjs/fabric.js/pull/9479)
- BREAKING: remove absolute true/false from the api. [#9395](https://github.com/fabricjs/fabric.js/pull/9395)
- refactor(Canvas): BREAKING deprecate `getPointer`, add new getScenePoint and getViewportPoint methods, removed `restorePointerVpt`, extended mouse events data [#9175](https://github.com/fabricjs/fabric.js/pull/9175)
- chore(): rm isClick artifacts leftovers from #9434 [#9478](https://github.com/fabricjs/fabric.js/pull/9478)
- fix(Object): Fix detection of falsy shadows in Object.needsItsOwnCache method [#9469](https://github.com/fabricjs/fabric.js/pull/9469)
- feat(util): expose `calcPlaneRotation` [#9419](https://github.com/fabricjs/fabric.js/pull/9419)
- refactor(Canvas): BREAKING remove button from mouse events, delegate to event.button property [#9449](https://github.com/fabricjs/fabric.js/pull/9449)
Expand Down
26 changes: 13 additions & 13 deletions src/canvas/Canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ export class Canvas extends SelectableCanvas implements CanvasOptions {
const target = this._hoveredTarget;
const shared = {
e,
isClick: false,
...getEventPoints(this, e),
};
this.fire('mouse:out', { ...shared, target });
Expand Down Expand Up @@ -1296,7 +1295,6 @@ export class Canvas extends SelectableCanvas implements CanvasOptions {
e,
target: oldTarget,
nextTarget: target,
isClick: false,
...getEventPoints(this, e),
};
fireCanvas && this.fire(canvasOut, outOpt);
Expand All @@ -1308,7 +1306,6 @@ export class Canvas extends SelectableCanvas implements CanvasOptions {
e,
target,
previousTarget: oldTarget,
isClick: false,
...getEventPoints(this, e),
};
fireCanvas && this.fire(canvasIn, inOpt);
Expand Down Expand Up @@ -1511,7 +1508,7 @@ export class Canvas extends SelectableCanvas implements CanvasOptions {
* - selects objects that are contained in (and possibly intersecting) the selection bounding box
* - sets the active object
* ---
* runs on mouse up
* runs on mouse up after a mouse move
*/
protected handleSelection(e: TPointerEvent) {
if (!this.selection || !this._groupSelector) {
Expand All @@ -1522,8 +1519,7 @@ export class Canvas extends SelectableCanvas implements CanvasOptions {
point2 = point1.add(new Point(deltaX, deltaY)),
tl = point1.min(point2),
br = point1.max(point2),
size = br.subtract(tl),
isClick = point1.eq(point2);
ShaMan123 marked this conversation as resolved.
Show resolved Hide resolved
size = br.subtract(tl);

const collectedObjects = this.collectObjects(
{
Expand All @@ -1535,13 +1531,17 @@ export class Canvas extends SelectableCanvas implements CanvasOptions {
{ includeIntersecting: !this.selectionFullyContained }
) as FabricObject[];

const objects = isClick
? collectedObjects[0]
? [collectedObjects[0]]
: []
: collectedObjects.length > 1
? collectedObjects.filter((object) => !object.onSelect({ e })).reverse()
: collectedObjects;
const objects =
// though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down
// should it be handled as is?
point1.eq(point2)
? collectedObjects[0]
? [collectedObjects[0]]
: []
: collectedObjects.length > 1
? collectedObjects.filter((object) => !object.onSelect({ e })).reverse()
: // `setActiveObject` will call `onSelect(collectedObjects[0])` in this case
collectedObjects;

// set active object
if (objects.length === 1) {
Expand Down
7 changes: 0 additions & 7 deletions src/canvas/__tests__/__snapshots__/eventData.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ exports[`Canvas event data HTML event "dragenter" should fire a corresponding ca
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"pointer": Point {
"x": 50,
"y": 50,
Expand Down Expand Up @@ -302,7 +301,6 @@ exports[`Canvas event data HTML event "dragover" should fire a corresponding can
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"pointer": Point {
"x": 50,
"y": 50,
Expand Down Expand Up @@ -585,7 +583,6 @@ exports[`Canvas event data HTML event "mouseout" should fire a corresponding can
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"pointer": Point {
"x": 50,
"y": 50,
Expand Down Expand Up @@ -715,7 +712,6 @@ exports[`should fire mouse over/out events on target 1`] = `
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"pointer": Point {
"x": 5,
"y": 5,
Expand Down Expand Up @@ -769,7 +765,6 @@ exports[`should fire mouse over/out events on target 1`] = `
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"nextTarget": undefined,
"pointer": Point {
"x": 20,
Expand Down Expand Up @@ -828,7 +823,6 @@ exports[`should fire mouse over/out events on target 2`] = `
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"pointer": Point {
"x": 5,
"y": 5,
Expand Down Expand Up @@ -909,7 +903,6 @@ exports[`should fire mouse over/out events on target 2`] = `
"e": MouseEvent {
"isTrusted": false,
},
"isClick": false,
"nextTarget": undefined,
"pointer": Point {
"x": 20,
Expand Down
7 changes: 0 additions & 7 deletions test/unit/draggable_text.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(30, 15),
viewportPoint: new fabric.Point(30, 15),
scenePoint: new fabric.Point(30, 15),
isClick: false,
previousTarget: undefined
},
...dragEvents.slice(0, 32).map(e => ({
Expand Down Expand Up @@ -304,7 +303,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(123, 15),
viewportPoint: new fabric.Point(123, 15),
scenePoint: new fabric.Point(123, 15),
isClick: false,
nextTarget: undefined
},
{
Expand Down Expand Up @@ -366,7 +364,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(210, 15),
viewportPoint: new fabric.Point(210, 15),
scenePoint: new fabric.Point(210, 15),
isClick: false,
previousTarget: undefined
},
...dragEvents.slice(0, 6).map(e => ({
Expand All @@ -390,7 +387,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(220, -5),
viewportPoint: new fabric.Point(220, -5),
scenePoint: new fabric.Point(220, -5),
isClick: false,
nextTarget: undefined
},
]);
Expand Down Expand Up @@ -466,7 +462,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(100, 15),
viewportPoint: new fabric.Point(100, 15),
scenePoint: new fabric.Point(100, 15),
isClick: false,
previousTarget: undefined
},
...dragEvents.slice(0, 2).map(e => ({
Expand Down Expand Up @@ -537,7 +532,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(230, 15),
viewportPoint: new fabric.Point(230, 15),
scenePoint: new fabric.Point(230, 15),
isClick: false,
previousTarget: undefined
},
...dragEvents.slice(0, 2).map(e => ({
Expand Down Expand Up @@ -600,7 +594,6 @@ function assertDragEventStream(name, a, b) {
absolutePointer: new fabric.Point(230, 15),
viewportPoint: new fabric.Point(230, 15),
scenePoint: new fabric.Point(230, 15),
isClick: false,
previousTarget: undefined
},
...dragEvents.slice(0, 2).map(e => ({
Expand Down
Loading