-
-
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
patch(): Control#shouldActivate
#8934
Conversation
Build Stats
|
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.
Is there a need for a test?
I feel like not adding non crucial tests until jest is in
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 it simpler by reverting isPointerOverControl
Control#shouldActivate
, Object#isPointerOverControl
Control#shouldActivate
09b27f1
to
b405989
Compare
094ea1c
to
c58c7a9
Compare
One day I will refactor the control visibility awkward code. But not soon. |
Update CHANGELOG.md
4e254cb
to
c61b4e4
Compare
c61b4e4
to
21651d8
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.
DONE
if (xPoints !== 0 && xPoints % 2 === 1) { | ||
this.__corner = key; | ||
return key; | ||
} |
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.
looks like that both getImageLines and findCrossPoints are object method that are more utils than anyhitng else.
Take some parameter in, do not used this
at all and give a result.
If you want to have the control class being the owner of the decision if the cursor is in the control, you can do that moving those to utils and exposing a method that uses the utils.
What made you change the idea around the pointer thing? something bad happens when doing that? |
a4c0f62#diff-fe6477e182894fdb5db40e4d3bffa1f12e02af91a158b9619752aca781441332R199-R201 This can easily be exposed on the control |
That is there just for backward compatibility not because we like it. |
@@ -169,6 +169,14 @@ export class Control { | |||
*/ | |||
declare mouseUpHandler?: ControlActionHandler; | |||
|
|||
shouldActivate(controlKey: string, fabricObject: InteractiveFabricObject) { | |||
// TODO: locking logic can be handled here instead of in the control handler logic |
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.
You mean we could look at actionName and the relevant lockProperties?
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.
yes
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.
or better off, move the lock property to the control
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.
well lock is by object and controls could be generic.
That is the same issue we have with visibility.
The PR is fine, i m merging. |
Motivation
I need the control api to be more flexible
Description
Introduce the ability for a control to decide if it should be activated or not.
Before this was handled by the canvas in an hardcoded way with:
as an early return and later on on the control check if the control is visible.
Now the first early return doesn't take care of the object being selected, but the control later has a new method
shouldActivate
that by default return true only if the object is the active one and if the control is visible.The developer can override this in a custom control and apply the logic that prefers.
Default behaviour does not change
Changes
Control#shouldActivate
- for overridingGist
In Action