-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
refactor(): getActiveControl
return value
#9515
Conversation
f1c6671
to
70f11a5
Compare
Build Stats
|
a21cc94
to
9594e0b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Made
Transform#action
optional so it is easier to manipulate transform. I want to do the same withcorner
but this is a big diff so i will in a dedicated PR. - squash
_beforeTransform
into_setupCurrentTransform
_setupCurrentTransform
return value void => transform- rm unused
Transform#reset
9594e0b
to
763daa6
Compare
bff373f
to
3dee2e3
Compare
src/canvas/SelectableCanvas.spec.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
migrated test from test/unit/canvas_events.js
@asturur I wish this to enter v6 so we don't break |
Also I have found something I should PR to fix if (target) {
const alreadySelected = target === this._activeObject;
+ const corner = target._findTargetCorner(
+ this.getViewportPoint(e),
+ isTouchEvent(e)
+ );
if (target.selectable && target.activeOn === 'down') {
this.setActiveObject(target, e);
}
- const corner = target._findTargetCorner(
- this.getViewportPoint(e),
- isTouchEvent(e)
- ); fabric.js/src/canvas/Canvas.ts Lines 1086 to 1110 in 3dee2e3
|
@asturur I want this in before we publish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just reviewed again
This is a focused PR IMO
next in line for possibly merging |
mouseDownHandler.call( | ||
control, | ||
e, | ||
this._currentTransform!, | ||
pointer.x, | ||
pointer.y | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
those changes here are applied by the minifier later on, but imho they take away on readibility. In the default safe lint or prettier profile are not considered, so i won't hold anything on it since may fall in the opinion realm
@@ -25,7 +25,7 @@ export const NOT_ALLOWED_CURSOR = 'not-allowed'; | |||
*/ | |||
export const getActionFromCorner = ( | |||
alreadySelected: boolean, | |||
corner: string, | |||
corner: string | undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not using the '?'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its usually better to init all props even if undefined, rather than having some missing and some not
that way browser engine can do smarter optimizations when objects have similar shapes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember
I agree with '?'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh because it can't be optional because it is not the last arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh i thought it was an object.
had a rough end of week, back on this now. |
Motivation
getActiveControl
is a convenient method we exposed in #9102 but not enough.Using it made me realize the need to expose both the control and the coord of the control with it.
For us it is easy to get that but for a dev it means they need to understand the cood system.
Also it is not convenient trying to access the control/coord if the control key is undefined
Description
Changes
getActiveControl(): string
=>getActiveControl(): { key: string; control: Control; coord: TOCoord; } | undefined
Transform#action
optional so it is easier to manipulate transform. I want to do the same withcorner
but this is a big diff so i will in a dedicated PR._beforeTransform
into_setupCurrentTransform
Transform#reset
Gist
In Action