-
-
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(controls): deprecate 🚫 SHARED 🚫 controls #7914
Conversation
support circular refs!
I don't know why there's a bug but I am really fed up with all this old js
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.
1 failing test - why does it fail?
1 comment
Besides this is good to go.
@@ -1002,6 +1004,9 @@ | |||
else if (key === 'shadow' && value && !(value instanceof fabric.Shadow)) { | |||
value = new fabric.Shadow(value); | |||
} | |||
else if (key === 'controls') { | |||
value.attach(this); |
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.
not sure we need this because I couldn't get controls
to be set in setOptions
without breaking all tests
I don't know custom controls works, this a change in name of best practices of which i see very little utility. |
Didn't understand
Absolutely. And the TS rewrite will introduce even more. |
actionHandler: scalingXOrSkewingY, | ||
getActionName: scaleOrSkewActionName, | ||
}); | ||
class ObjectControls { |
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.
since we are not migrating yet, this should still be the function + prototype class.
To be clear i see this is more polished. Also i have questions, if i have a control group class for each object, as soon as i want to add a single control to all objects, like a delete button, how do i do for the instantiated objects? I have to loop and reassign controls. What is good of the current pattern is that you may have multiple control set ready to be used by object, for example:
With this i meant, i don't like to fix what is not broken, in the name of |
I don't think the control API is horrible at all. Anyways you indulge me with the things I want/need/think are important so now it's my turn. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR refactors
Object#controls
from a shared object attached to the prototype into a unique object attached to an instance.Motivation
#7596 (comment)
I hate the shared controls and the shared concept altogether.
It's extremely unintuitive and many issues were raised because of this. I have spoken to fabric devs and they all mentioned this.
IMO sharing instances should never be done in fabric (and maybe even at all - except for mega perf enhancements) and anyways rewriting JS to use
class
will and MUST deprecate this bad practice in favor ofstatic
properties/methods or simply bound properties/methods.Gist
created
ObjectControls
,TextboxControls
classes that hold the default controls.controls
must have anattach
method - best practice is to subclassObjectControls | TextboxControls
. When migrating to TS we could/should use an abstract class to define this class that the dev will have to subclass.BREAKING control API since
fabricObject
is no longer needed as it is referenced in thecontrol.object
I have no idea why this test fails.
Migration
If a dev needs to change controls across many objects they can subclass or they can pass a controls object in initialization. But it cannot be SHARED
Post PR
We should consider moving control logic from
src/mixins/object_interactivity.mixin.js
toObjectControls